Thanks to visit codestin.com
Credit goes to github.com

Skip to content

nnash/cmake-tools.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CMake Tools for Neovim

It is a fork from the brilliant neovim-cmake. Since I change too much of it, So I make a new repo to develop it.

🔥CMake Tools for Neovim written in pure lua that requires Neovim 0.7+.🔥

It uses CMake file api to generate CMake file structure.

It uses terminal to execute targets.

(optional) It uses nvim-dap to debug.

New Feature

CMake Presets

Not it supports CMake[User]Presets.json.

Attention: If CMake[User]Presets.json is provided, then CMakeKits.json or CMakeVariants.[json|yaml] won't have any effect.

CMake Kits

CMake Kits

And, It doesn't support Visual Studio currently.

CMake Variants

Thanks @toolcreator for supporting CMake Variants which raised by VsCode's CMake Tools.

CMake Variants

Installation

  • Require Neovim (>=0.7)
  • Require plenary
  • Install it like any other Neovim plugin.

Todo: Add help.txt

Usage

Command Description
CMakeGenerate[!] Generate native makefiles and workspaces that can be used next. Additional arguments will be passed to CMake. eg. Use CMakeGenerate -G MinGW\ Makefiles to specify another generator.
CMakeBuild Build target, if not generate makefiles yet, it will automatically invoke CMake, if not select build target, it will automatically invoke CMakeSelectBuildTarget . Additional arguments will be passed to CMake.
CMakeRun Run launch target, if not generate makefiles yet, it will automatically invoke CMakeGenerate, if not select launch target, it will automatically invoke CMakeSelectLaunchTarget, if not built, it will automatically invoke CMakeBuild. Additional arguments will be passed to CMakeGenerate and CMakeBuild.
CMakeDebug Use nvim-dap to debug launch target, works like CMakeRun
CMakeSelectBuildType Select build type, include "Debug", "Release", "RelWithDebInfo", "MinSizeRel" for default. cmake-tools.nvim also support cmake variants, when "cmake-variants.yaml" or "cmake-variants.json" is provided, it will read configuration from it
CMakeSelectBuildTarget Select build target, include executable and library targets
CMakeSelectLaunchTarget Select launch target, only include executable targets
CMakeOpen Open CMake console
CMakeClose Close CMake console
CMakeInstall Install CMake targets. Additional arguments will be passed to CMake.
CMakeClean Clean target
CMakeStop Stop CMake process

Demos

CMakeGenerate

CMakeGenerate

CMakeBuild

CMakeBuild

CMakeRun

CMakeRun

CMakeDebug (require nvim-dap)

CMakeDebug

CMakeSelectBuildType

CMakeSelectBuildType

When cmake-variants.json or cmake-variants.yaml is provided:

CMakeSelectBuildType with variants

CMakeSelectBuildTarget

CMakeSelectBuildTarget

CMakeSelectLaunchTarget

CMakeSelectLaunchTarget

Setup

require("cmake-tools").setup {
  cmake_command = "cmake",
  cmake_build_directory = "build",
  cmake_generate_options = { "-D", "CMAKE_EXPORT_COMPILE_COMMANDS=1" },
  cmake_build_options = {},
  cmake_console_size = 10, -- cmake output window height
  cmake_show_console = "always", -- "always", "only_on_error"
  cmake_dap_configuration = { name = "cpp", type = "codelldb", request = "launch" }, -- dap configuration, optional
  cmake_dap_open_command = require("dap").repl.open, -- optional
  cmake_variants_message = {
    short = { show = true },
    long = { show = true, max_length = 40 }
  }
}

LICENCE

GPL-3.0 License © Civitasv

Reference

  1. Inspired by neovim-cmake which is made by Shatur, GPL-3.0 license.
  2. plenary, MIT LICENSE.

About

CMake integration in Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%