Wefti

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.

wefti-lsp and syntax-only CMake language servers
Featurewefti-lsp 0.3.0Syntax-only CMake language server
Completion, go to definition, document symbolsYes, with semantic tokensUsually yes
Hover on a variableEvaluated value from the in-memory configureCommand documentation or the literal text
Hover on a targetResolved usage requirements with their sourceNot possible without a project evaluator
Inactive if() branchesDimmed with DiagnosticTag.UnnecessaryNot possible without a project evaluator
Lint12 rules with quickfix code actionsVaries by server
FormattingLossless wefti fmt with a syntax tree checkVaries by server, often an external formatter
References and renameAcross the workspace, with scoped variable renameVaries by server
compile_commands.jsonWritten on save from the evaluated projectNeeds a separate configure run
DebuggerDAP server through wefti --debuggerSeparate 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:

  1. The client settings buildDirectory and configurePreset.
  2. The [lsp] table of .wefti.toml, with build_dir and preset.
  3. A configure preset whose binaryDir contains CMakeCache.txt, or the only visible configure preset.
  4. A configured build, out/build/*, or cmake-build-* directory whose cache names the workspace. The newest cache wins.
  5. <workspace>/.wefti-lsp with 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

  1. 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
  1. 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
  1. 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" }
  }
}
  1. 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({})
  1. 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.