wefti-lsp, a CMake language server that evaluates your project
wefti-lsp is a Language Server Protocol (LSP) server for CMakeLists.txt and *.cmake files. It evaluates your project in memory with the same CMake 4.5.1 engine that wefti uses to configure. Hover, diagnostics, and dimmed branches show evaluated results. It works in VS Code, Cursor, Zed, Neovim, Helix, Emacs, and other LSP clients.
wefti-lsp is a CMake language server that evaluates your project in memory. It provides evaluated hover, dimmed inactive branches, completion, rename, 12 lint rules with quick fixes, and formatting. It works with VS Code, Cursor, Windsurf, Zed, Neovim, and other LSP clients.
What the evaluator adds
Most CMake language servers read only the text of a listfile. wefti-lsp also configures the project in memory over your unsaved buffers. Thus it can show what CMake will do, not only what the file contains.
- Evaluated hover. Hover shows the value of a variable or cache variable after evaluation. On a target, hover lists the resolved usage requirements and tells where each entry comes from, directly or through a transitive link.
- Inactive branch dimming. Diagnostics with
DiagnosticTag.Unnecessarydimif()branches that did not run in the current configuration. - Lint diagnostics and quick fixes. The server runs all 12 wefti lint rules. Each automatic fix is a
quickfixcode action, and safe fixes are the preferred action. - Lossless formatting. Formatting uses the
wefti fmtengine and the[fmt]table of.wefti.toml. - Workspace references and rename. References and rename work across workspace files for targets, aliases, functions, macros, and normal, cache, and option variables. A rename of a variable that a function, macro, or block declares changes only that scope.
compile_commands.jsonsync. After you save a listfile, the server waits 500 ms and writes<build>/compile_commands.jsonfrom the in-memory result.clangdthen sees new sources and flags.*.cmake.intemplates. The server replaces@NAME@placeholders at command position, such as@PACKAGE_INIT@, with spaces of the same length before it parses. Diagnostics and positions stay correct.
| Feature | wefti-lsp 0.3.0 | Syntax-only CMake language server |
|---|---|---|
| Completion, go to definition, document symbols | Yes, with semantic tokens | Usually yes |
| Hover on a variable | Evaluated value from the in-memory configure | Command documentation or the literal text |
| Hover on a target | Resolved usage requirements with their source | Not possible without a project evaluator |
Inactive if() branches | Dimmed with DiagnosticTag.Unnecessary | Not possible without a project evaluator |
| Lint | 12 rules with quickfix code actions | Varies by server |
| Formatting | Lossless wefti fmt with a syntax tree check | Varies by server, often an external formatter |
| References and rename | Across the workspace, with scoped variable rename | Varies by server |
compile_commands.json | Written on save from the evaluated project | Needs a separate configure run |
| Debugger | DAP server through wefti --debugger | Separate tool, such as cmake --debugger |
The evaluated mode needs the bundled CMake 4.5.1 modules. Release archives include them. When the server has no evaluated result, it uses lexical analysis and static lint.
How the server evaluates your project
In evaluated mode, the server reads unsaved edits instead of files on disk. It keeps configure writes in an in-memory overlay and blocks configure from starting external processes. When new edits arrive, it cancels the old evaluation. A result from an incomplete configure or an earlier edit is marked as provisional.
The server selects a build directory in this order:
- The client settings
buildDirectoryandconfigurePreset. - The
[lsp]table of.wefti.toml, withbuild_dirandpreset. - A configure preset whose
binaryDircontainsCMakeCache.txt, or the only visible configure preset. - A configured
build,out/build/*, orcmake-build-*directory whose cache names the workspace. The newest cache wins. <workspace>/.wefti-lspwith an empty cache.
The compile_commands.json sync runs when the build directory belongs to the workspace and the setting is not false. One more condition must be true. The setting is true, the cache sets CMAKE_EXPORT_COMPILE_COMMANDS to a true value, or the file already exists. The server writes only when the evaluation is valid and the content changed.
Set up wefti-lsp in your editor
- Install the server. Install a wefti release. The archives and install scripts put wefti-lsp next to wefti. You can also start the same server as wefti lsp --stdio. See the installation guide.
wefti-lsp --version
- Set up VS Code or Cursor. Build the extension in editors/vscode and install the .vsix file. The extension finds wefti-lsp without configuration. In Cursor or Windsurf, replace code with the command of your editor.
cd editors/vscode
npm install
npm run package
code --install-extension wefti-0.3.0.vsix
Until the extensions are in the Marketplace, Open VSX, and the Zed extension registry, install them from a source checkout. The VS Code extension adds the commands wefti.restartLsp, wefti.selectPreset, and wefti.syncCompileCommands. All settings are optional.
{
"wefti.lspPath": "",
"wefti.executablePath": "",
"wefti.buildDirectory": "${workspaceFolder}/build",
"wefti.configurePreset": "dev",
"wefti.dimInactiveBranches": true,
"wefti.syncCompileCommandsOnSave": true
}
Other editors can share the same settings through the [lsp] table of .wefti.toml. A client setting has priority over the matching key.
[lsp]
build_dir = "build/debug"
preset = "dev"
dim_inactive_branches = true
sync_compile_commands = true
- Set up Zed. Run zed: install dev extension and select the editors/zed directory. The extension uses lsp.wefti-lsp.binary.path, then wefti-lsp on PATH, then wefti lsp --stdio, and then downloads the latest release.
{
"lsp": {
"wefti-lsp": {
"binary": { "path": "/absolute/path/to/wefti-lsp" },
"settings": { "configurePreset": "dev" }
}
},
"languages": {
"CMake": { "format_on_save": "on" }
}
}
- Set up Neovim. On Neovim 0.11 and later, call vim.lsp.config with the wefti-lsp command and the cmake file type, then call vim.lsp.enable. With nvim-lspconfig, register a custom wefti server.
vim.lsp.config("wefti", {
cmd = { "wefti-lsp" }, -- or { "wefti", "lsp", "--stdio" }
filetypes = { "cmake" },
root_markers = { "CMakePresets.json", ".git" },
})
vim.lsp.enable("wefti")
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.wefti then
configs.wefti = {
default_config = {
cmd = { "wefti-lsp" },
filetypes = { "cmake" },
root_dir = lspconfig.util.root_pattern("CMakePresets.json", ".git"),
},
}
end
lspconfig.wefti.setup({})
- Set up Helix or Emacs. In Helix, add wefti-lsp to languages.toml and run hx --health cmake. In Emacs, add wefti-lsp to eglot-server-programs and run M-x eglot in a CMake buffer.
# ~/.config/helix/languages.toml
[language-server.wefti-lsp]
command = "wefti-lsp"
[[language]]
name = "cmake"
language-servers = ["wefti-lsp"]
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'((cmake-mode cmake-ts-mode) . ("wefti-lsp"))))
In CLion and other JetBrains IDEs, install the LSP4IJ plugin and set the server command to the absolute path of wefti-lsp. Any other LSP client can start wefti-lsp over standard input and output. Disable other CMake language servers, such as neocmake or cmake-language-server, on the same buffers to prevent duplicate results.
Debug configure runs and scripts
wefti includes a CMake 4.5.1 Debug Adapter Protocol (DAP) server for configure runs and -P scripts. Use a Unix domain socket path on macOS and Linux, or \\.\pipe\<name> on Windows. Add --debugger-dap-log=<file> to record protocol messages. The debugger turns off incremental replay, so breakpoints stop in live execution.
wefti -S . -B build --debugger --debugger-pipe=/tmp/wefti-dap.sock
The VS Code extension adds a wefti debug type with configure and script modes. Put this configuration in .vscode/launch.json.
{
"version": "0.2.0",
"configurations": [
{
"type": "wefti",
"request": "launch",
"name": "Debug CMake configure",
"mode": "configure",
"sourceDirectory": "${workspaceFolder}",
"buildDirectory": "${workspaceFolder}/build"
}
]
}
The language server and the command line share one engine. For the command-line tools, read the better CMake guide. For compatibility data, read the compatibility report. To try the engine in a browser, open the playground.
Frequently asked questions
How do I set up a CMake language server in VS Code or Cursor?
Build the extension in editors/vscode with npm install and npm run package, then install the .vsix file. The extension finds wefti-lsp without configuration. Set wefti.buildDirectory or wefti.configurePreset to select a build.
How is wefti-lsp different from cmake-language-server and neocmakelsp?
wefti-lsp evaluates the project in memory with the wefti CMake 4.5.1 engine. Hover shows evaluated variable values and target usage requirements, and the server dims if() branches that did not run. A server that reads only the file text cannot show these results.
How do I use wefti-lsp in Neovim?
On Neovim 0.11 and later, call vim.lsp.config with cmd set to wefti-lsp and filetypes set to cmake, then call vim.lsp.enable. You can also use wefti lsp --stdio as the command. Disable other CMake language servers on the same buffers.
Can wefti-lsp keep compile_commands.json up to date for clangd?
Yes. After you save a listfile, the server waits 500 ms and writes compile_commands.json from the in-memory configure result. It writes only when the evaluation is valid and the content changed. Set syncCompileCommandsOnSave to false to turn it off.
Does wefti-lsp run commands from my CMake project?
No. In evaluated mode, the server blocks configure from starting external processes and keeps configure writes in an in-memory overlay. It reads unsaved editor buffers instead of files on disk.
Can I debug CMake scripts with breakpoints?
Yes. wefti --debugger starts a Debug Adapter Protocol (DAP) server for configure runs and -P scripts. Pass --debugger-pipe with a Unix domain socket path on macOS and Linux, or a named pipe on Windows. The VS Code extension adds a wefti debug type.