vim-cmake
vim-cmake copied to clipboard
CMake Preset support
Request description
Can we support CMake presets? I would like to see an option which shows the available presets and let's the user tab complete it. And possibly change state variables like g:cmake_build_dir_location
based on selected preset.
Desired behavior
- After calling the
CMakePreset
command with the preferred preset,cmake --preset
should be called. - The
g:cmake_build_dir_location
,g:cmake_default_config
et al. should be updated to match selected preset fromCMakePresets.json
file. - The preset name should be displayed on the vim status line if enabled through any variable,
g:cmake_show_preset_in_status_line
maybe? - Plugin should be able to configure with
g:cmake_preset
and do steps 1-3
Alternatives solutions
I am able to do this via terminal. This is my flow
# list the presets, maybe this can be used for autocomplete?
cmake --list-presets
# generate cmake files based on the preset
cmake --preset x86_64-unknown-linux-gnu
# configure local .vimrc manually
# for pointing vim-cmake to the generated files
Hi, thanks a lot for requesting this. Looks interesting. I'm currently on holidays, I'll have a look at it when I'm back.
In my workflow I use all of the following commands:
cmake --list-presets
cmake --preset <my_config_preset>
cmake --build --list-presets
cmake --build --preset <my_build_preset>
ctest --list-presets
ctest --preset <my_test_preset>
These are all of the current preset commands as of CMake 3.22.0, so if all of these were supported then this plugin would have "full"-preset support - which would be great!
So far, none of the vim/neovim plugins seem to support this feature. But there are more and more projects that use it. In these projects, you can't use these plugins, which is a pity. The Cmake plugin from VSCode has this feature integrated right away. I really hope that the vim/neovim plugins will follow suit. The cmake-presets are very comfortable.
Hi, thanks for posting this comment. I absolutely agree that CMake presets should be supported, as you said more and more projects are using this feature. I just have little time to work on Vim-CMake at the moment, and I believe that adding support for presets requires some non-negligible amount of work to properly design and implement this addition. I can't promise anything for this month, but I'll try to find some time to at least sketch out what the feature should look like, so that in principle anyone could submit a PR.
Here comes the reference: https://github.com/microsoft/vscode-cmake-tools/blob/HEAD/docs/cmake-presets.md
It would be enough if the preset mode is activated as soon as a CMakePresets.json is present.
Then it only needs a few elements:
- Selecting one of the Configure/Build and Test presets from the existing ones.
- CMakeGenerate/Build/Test are called with the selected presets.