CMake LSP Implementation.
Alpha Stage, work in progress.
- Builtin command completion
- Documentation for commands and variables on hover
- Formatting (by
cmake-format)
cmake-language-server: LSP server
$ pip install cmake-language-server- Neovim (neoclide/coc.nvim, prabirshrestha/vim-lsp)
if executable('cmake-language-server')
au User lsp_setup call lsp#register_server({
\ 'name': 'cmake',
\ 'cmd': {server_info->['cmake-language-server']},
\ 'root_uri': {server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'build/'))},
\ 'whitelist': ['cmake'],
\ 'initialization_options': {
\ 'buildDirectory': 'build',
\ }
\})
endifbuildDirectoryThis language server uses CMake's file API to get cached variables. The API communicates using<buildDirectory>/.cmake/api/.buildDirectoryis relative path to the root uri of the workspace. To configure the build tree, you need to run the cmake command such ascmake .. -DFOO=bar.