# 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 `<buildDirectory>/.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
Raw data
{
"_id": null,
"home_page": null,
"name": "cmake-language-server",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.14,>=3.8.0",
"maintainer_email": null,
"keywords": "cmake, completion, vim, lsp",
"author": "Regen",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/cf/ad/54c337fd2093a7c7c13528ac1393aeda009cdc16be954041834328845237/cmake_language_server-0.1.11.tar.gz",
"platform": null,
"description": "# cmake-language-server\n[](https://pypi.org/project/cmake-language-server)\n[](https://aur.archlinux.org/packages/cmake-language-server/)\n[](https://github.com/regen100/cmake-language-server/actions)\n[](https://codecov.io/gh/regen100/cmake-language-server)\n[](https://github.com/regen100/cmake-language-server/blob/master/LICENSE)\n\nCMake LSP Implementation.\n\nAlpha Stage, work in progress.\n\n## Features\n- [x] Builtin command completion\n- [x] Documentation for commands and variables on hover\n- [x] Formatting (by [`cmake-format`](https://github.com/cheshirekow/cmake_format))\n\n## Commands\n\n- `cmake-language-server`: LSP server\n\n## Installation\n\n```bash\n$ pip install cmake-language-server\n```\n\n### Tested Clients\n\n- Neovim ([neoclide/coc.nvim][coc.nvim], [prabirshrestha/vim-lsp][vim-lsp])\n\n#### Neovim\n\n##### coc.nvim\n\n```jsonc\n \"languageserver\": {\n \"cmake\": {\n \"command\": \"cmake-language-server\",\n \"filetypes\": [\"cmake\"],\n \"rootPatterns\": [\n \"build/\"\n ],\n \"initializationOptions\": {\n \"buildDirectory\": \"build\"\n }\n }\n }\n```\n\n##### vim-lsp\n\n```vim\nif executable('cmake-language-server')\n au User lsp_setup call lsp#register_server({\n \\ 'name': 'cmake',\n \\ 'cmd': {server_info->['cmake-language-server']},\n \\ 'root_uri': {server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'build/'))},\n \\ 'whitelist': ['cmake'],\n \\ 'initialization_options': {\n \\ 'buildDirectory': 'build',\n \\ }\n \\})\nendif\n```\n\n### Configuration\n* `buildDirectory`\n This language server uses CMake's file API to get cached variables.\n The API communicates using `<buildDirectory>/.cmake/api/`.\n `buildDirectory` is relative path to the root uri of the workspace.\n To configure the build tree, you need to run the cmake command such as `cmake .. -DFOO=bar`.\n\n\n[coc.nvim]: https://github.com/neoclide/coc.nvim\n[vim-lsp]: https://github.com/prabirshrestha/vim-lsp\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "CMake LSP Implementation",
"version": "0.1.11",
"project_urls": {
"repository": "https://github.com/regen100/cmake-language-server"
},
"split_keywords": [
"cmake",
" completion",
" vim",
" lsp"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "60b80ea1c0b86b8c6ca6c2dd5292762f282e779d6631c0641d043123bf8be164",
"md5": "f98306910fc3d8f9cb3b244049c8c551",
"sha256": "74ce1fa93a3db258776d881935172a87124ed621298404ac42f960eab6be8c04"
},
"downloads": -1,
"filename": "cmake_language_server-0.1.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f98306910fc3d8f9cb3b244049c8c551",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.8.0",
"size": 9619,
"upload_time": "2025-02-11T02:51:29",
"upload_time_iso_8601": "2025-02-11T02:51:29.976732Z",
"url": "https://files.pythonhosted.org/packages/60/b8/0ea1c0b86b8c6ca6c2dd5292762f282e779d6631c0641d043123bf8be164/cmake_language_server-0.1.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cfad54c337fd2093a7c7c13528ac1393aeda009cdc16be954041834328845237",
"md5": "b5718ad374096f9123dc2e059093448a",
"sha256": "005f48367ec569457a7229a58f6762044fddacac647858b39d725ae2b3cd695b"
},
"downloads": -1,
"filename": "cmake_language_server-0.1.11.tar.gz",
"has_sig": false,
"md5_digest": "b5718ad374096f9123dc2e059093448a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.14,>=3.8.0",
"size": 11849,
"upload_time": "2025-02-11T02:51:31",
"upload_time_iso_8601": "2025-02-11T02:51:31.481535Z",
"url": "https://files.pythonhosted.org/packages/cf/ad/54c337fd2093a7c7c13528ac1393aeda009cdc16be954041834328845237/cmake_language_server-0.1.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-11 02:51:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "regen100",
"github_project": "cmake-language-server",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "cmake-language-server"
}