I created this plugin in order to improve integration CMake to the Vim editor. I tried different plugins for vim which allow to work with cmake but I didn't find the plugin which was satisfied my requrements.
- Written in pure Vimscript
- The plugin supports next CMake Generators:
- Unix Makefiles
- Visual Studio
- Ninja
- The plugin shows cmake results using quickfix list. If you have installed vim-dispatch plugin, plugin will use it, this means that if you are using vim with tmux, cmake output will be printed in a separate window. In other case plugin will use
jobsto async run if your Vim editor supports it. - The plugin allows to specify cmake targets in order to avoid building of all project.
- The plugin has an integration with next fuzzy finder plugins:
- The plugin allows to specify make arguments for native build system (for example -jN and something else for Unix Make).
- The plugin parses the output of cmake command and supports jump to warnings or errors.
- Supports work with multiple build types
- For CMake newer than 3.13 the plugin uses the CMake file API
You can use VimPlug for installation:
Plug 'ilyachur/cmake4vim'Or Pathogen:
cd ~/.vim/bundle
git clone https://github.com/ilyachur/cmake4vimThe current version of the plugin supports next commands:
:CMakecreates a build directory (if it is necessary) and generates cmake project.:CMakeBuildbuilds current cmake project. The command allows to specify cmake target.:CTestruns tests. The command allow to specify Ctest arguments:CMakeInfocreates a window with CMake information.:CMakeResetAndReloadremoves cmake cache and re-generates cmake project.:CMakeResetremoves cmake cache (this command removes the cmake build directory).:CMakeCleancleans the project (it is equal of the executionmake clean).:CMakeSelectTargetselects a target for project. You should put target name as a command line argument.:CtrlPCMakeTargetyou can use CtrlP in order to select a target for project.:FZFCMakeSelectTargetyou can use FZF in order to select a target for project.:CMakeSelectBuildTypeChange the cmake build type with argument passed and call:CMake.
Plugin supports special global variables which are allow to change behaviour of commands (you can change them in your .vimrc):
g:cmake_reload_after_saveif this variable is not equal 0, plugin will reload CMake project after saving CMake files. Default is 0.g:cmake_change_build_commandif this variable is not equal 0, plugin will change the make command. Default is 1.g:cmake_build_dirallows to set cmake build directory. Default is ''. If variable is empty the plugin will use the prefix plus build type.g:cmake_src_dirallows to set cmake source directory. Default is '' which evaluates to the current working directory.g:cmake_build_dir_prefixallows to set cmake build directory prefix. Default is 'cmake-build-'.g:cmake_build_targetset the target name for build. Default is empty and default value depends on CMake Generatorg:make_argumentsallows to set custom parameters for make command. Default is empty. If variable is empty, plugin launchesmakewithout arguments.g:cmake_project_generatorallows to set the project generator for build scripts. Default is empty.g:cmake_install_prefixallows to change-DCMAKE_INSTALL_PREFIX. Default is empty.g:cmake_build_typeallows to change-DCMAKE_BUILD_TYPE. Default is empty. If variable is empty, plugin tries to detect cached build type. And selects 'Release' type if cmake cache doesn't exist.g:cmake_c_compilerallows to change-DCMAKE_C_COMPILER. Default is empty.g:cmake_cxx_compilerallows to change-DCMAKE_CXX_COMPILER. Default is empty.g:cmake_usr_argsallows to set user arguments for cmake. Default is empty.g:cmake_compile_commandsif this variable is not equal 0, plugin will generate compile commands data base. Default is 0.g:cmake_compile_commands_linkset the path for a link on compile_commands.json. Default is empty.g:cmake_build_executorallows to force set the build executor. Available values are 'job', 'dispatch', 'system' and ''. Default is empty.
Plugin is closely integrated with quickfix list and allows to use quickfix features to jump between error or warning messages.
- :cp[revious] command jumps to previous error/warning message
- :cn[ext] command jumps to next error/warning message
Bug reports, feedback, feature and other pull requests are appreciated. Check the Contributing Guidelines for how to create a feature request, submit a pull request or post an issue.
Ilya Churaev ilyachur@gmail.com
GPL-3.0




