https://github.com/regen100/cmake-language-server
CMake LSP Implementation
https://github.com/regen100/cmake-language-server
Last synced: 7 months ago
JSON representation
CMake LSP Implementation
- Host: GitHub
- URL: https://github.com/regen100/cmake-language-server
- Owner: regen100
- License: mit
- Created: 2019-11-11T16:24:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-11T02:50:57.000Z (about 1 year ago)
- Last Synced: 2025-09-21T04:43:43.936Z (7 months ago)
- Language: Python
- Size: 172 KB
- Stars: 377
- Watchers: 9
- Forks: 28
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-cmake - cmake-language-server - CMake Language Server Protocol Implementation. [```[MIT]```][MIT] (Other)
README
# cmake-language-server
[](https://pypi.org/project/cmake-language-server)
[](https://aur.archlinux.org/packages/cmake-language-server/)
[](https://github.com/regen100/cmake-language-server/actions)
[](https://codecov.io/gh/regen100/cmake-language-server)
[](https://github.com/regen100/cmake-language-server/blob/master/LICENSE)
CMake LSP Implementation.
Alpha Stage, work in progress.
## Features
- [x] Builtin command completion
- [x] Documentation for commands and variables on hover
- [x] Formatting (by [`cmake-format`](https://github.com/cheshirekow/cmake_format))
## Commands
- `cmake-language-server`: LSP server
## Installation
```bash
$ pip install cmake-language-server
```
### Tested Clients
- Neovim ([neoclide/coc.nvim][coc.nvim], [prabirshrestha/vim-lsp][vim-lsp])
#### Neovim
##### coc.nvim
```jsonc
"languageserver": {
"cmake": {
"command": "cmake-language-server",
"filetypes": ["cmake"],
"rootPatterns": [
"build/"
],
"initializationOptions": {
"buildDirectory": "build"
}
}
}
```
##### vim-lsp
```vim
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',
\ }
\})
endif
```
### Configuration
* `buildDirectory`
This language server uses CMake's file API to get cached variables.
The API communicates using `/.cmake/api/`.
`buildDirectory` is relative path to the root uri of the workspace.
To configure the build tree, you need to run the cmake command such as `cmake .. -DFOO=bar`.
[coc.nvim]: https://github.com/neoclide/coc.nvim
[vim-lsp]: https://github.com/prabirshrestha/vim-lsp