An evaluated alternative to neocmakelsp and cmake-language-server
Most CMake language servers read the text of a file. wefti-lsp also configures the project in memory, so its answers come from what CMake would do.
wefti-lsp is a CMake language server that evaluates your project with the Wefti engine. It gives hover with the real value and its origin, dims if() branches that did not run, completes installed packages in find_package() and targets in target_link_libraries(), and writes compile_commands.json on save. It works in VS Code, Cursor, Windsurf, Zed, Neovim, Helix, Emacs, Sublime Text, and CLion.
What the evaluator adds
A server that reads only text cannot know which if() branch ran or what value a variable has after three include() calls. wefti-lsp configures the project in memory over your unsaved buffers, and it shows what CMake will do, not only what the file contains.
- Hover shows the evaluated value of a variable or cache variable. On a target, hover lists the resolved usage requirements and says whether each one is direct or comes from a transitive link.
- Inactive
if()branches get theinactive-branchhint andDiagnosticTag.Unnecessary, so editors dim them. - All 12
wefti lintrules run as diagnostics. Each automatic fix is aquickfixcode action, and safe fixes are the preferred action. - References and rename work across workspace files for targets, aliases, functions, macros, and normal, cache, and option variables.
- Formatting uses the
wefti fmtengine and the[fmt]table of.wefti.toml. - After you save a listfile, the server writes
<build>/compile_commands.jsonfrom the in-memory result. It waits 500 ms after the last save and writes only when the content changed.
The language server also handles *.cmake.in templates. It replaces @NAME@ placeholders at command position with spaces of the same length before it parses, so diagnostics and positions stay correct.
Completion for packages, targets, and presets
- Installed packages inside
find_package(). - Targets inside
target_link_libraries(). - Keys, preset names, and macros in
CMakePresets.jsonandCMakeUserPresets.json.
The Zed extension attaches the server to CMake files only. Zed opens CMakePresets.json as JSON, so preset completion is not available in Zed.
Editor support
| Editor | Setup | Notes |
|---|---|---|
| VS Code, Cursor, Windsurf | First-party extension in editors/vscode | Finds wefti-lsp without settings. Adds a preset picker and configure debugging. |
| Zed | First-party extension in editors/zed | Finds the server on PATH or downloads the latest release. |
| Neovim 0.11 and later | vim.lsp.config or editors/neovim/wefti.lua | Also works with nvim-lspconfig. |
| Helix | editors/helix/languages.toml | Run hx --health cmake to check the server. |
| Emacs | Eglot entry for wefti-lsp | Works with cmake-mode and cmake-ts-mode. |
| Sublime Text | LSP package client | Uses the source.cmake scope. |
| CLion | LSP4IJ plugin | Shows results next to the built-in CMake support. |
Turn off other CMake language servers on the same buffers, such as neocmake or cmake, so you do not get duplicate results.
-- Neovim 0.11 and later
vim.lsp.config("wefti", {
cmd = { "wefti-lsp" },
filetypes = { "cmake" },
root_markers = { "CMakePresets.json", ".git" },
})
vim.lsp.enable("wefti")
# Helix, in ~/.config/helix/languages.toml
[language-server.wefti-lsp]
command = "wefti-lsp"
[[language]]
name = "cmake"
language-servers = ["wefti-lsp"]
Set up wefti-lsp in your editor
These steps work in any editor. Only the second step changes.
- Install Wefti. The installer adds
wefti,wefti-lsp, and the CMake data. Make surewefti-lspis on yourPATH. - Connect your editor. Install the extension for VS Code, Cursor, Windsurf, or Zed, or add the Neovim or Helix setup shown below.
- Pick a build directory or preset. Set
buildDirectoryorconfigurePresetin the client, orbuild_dirandpresetin the[lsp]table of.wefti.toml. - Open a CMakeLists.txt file. Hover over a target to see where each usage requirement comes from. Branches of
if()that did not run are dimmed. - Check compile_commands.json. Save a listfile. After 500 ms the server writes
<build>/compile_commands.json, andclangdsees the new sources and flags.
Frequently asked questions
What is an alternative to neocmakelsp?
wefti-lsp is a CMake language server in Rust that also evaluates the project in memory. It gives hover with real values, dimmed dead branches, 12 lint rules with quick fixes, and compile_commands.json sync.
What is an alternative to cmake-language-server?
wefti-lsp needs no Python. Run it as wefti-lsp or wefti lsp over standard input and output, and it works in any editor with an LSP client.
Which CMake language server works in VS Code, Neovim, Zed, and Helix?
wefti-lsp works in all four. VS Code and Zed have first-party extensions. Neovim 0.11 and Helix need a few lines of configuration, and both are in the repository.
Does it complete find_package, target_link_libraries, and CMakePresets.json?
Yes. It completes installed packages in find_package(), targets in target_link_libraries(), and keys, preset names, and macros in preset files. The Zed extension does not attach to CMakePresets.json.
How does the server keep clangd up to date?
After you save a listfile, wefti-lsp waits 500 ms and writes <build>/compile_commands.json from the in-memory configure result. It needs a configured build directory and the setting must not be false.
Does the language server change my files?
No, except for formatting and quick fixes that you accept. Formatting uses wefti fmt, which confirms that the syntax tree and comments are unchanged before it writes.