Language Server Protocol¶
behave-lint includes an LSP server for real-time diagnostics in any LSP-compatible editor (VS Code, Neovim, Emacs, etc.).
Installation¶
Install with the lsp optional dependency:
Or with uv:
Usage¶
The LSP server communicates over stdio:
Editor configuration¶
VS Code¶
Add the following to .vscode/settings.json:
Or use a custom extension that connects to the server.
Neovim (nvim-lspconfig)¶
local lspconfig = require('lspconfig')
lspconfig.behave_lint.setup({
cmd = { 'behave-lint-lsp' },
filetypes = { 'gherkin', 'feature' },
root_dir = function(bufnr, callback)
callback(vim.fn.getcwd())
end,
})
Emacs (eglot)¶
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'((feature-mode) "behave-lint-lsp")))
Generic LSP client¶
Any LSP client that supports stdio transport can connect to
behave-lint-lsp. The server advertises:
textDocument/didOpen— lint on file opentextDocument/didChange— re-lint on every edit (full sync)textDocument/didSave— re-lint on savetextDocument/didClose— clear diagnostics
Features¶
- Real-time diagnostics — errors, warnings, and info from all 41 built-in rules
- Full document sync — the server receives the complete document content on every change
- Source attribution — all diagnostics are tagged with
source: behave-lint - Rule codes — each diagnostic includes the rule ID (e.g.
BC001,BS001) as the diagnostic code
Limitations¶
- No auto-fix via LSP yet (planned for future versions)
- No configuration via LSP workspace configuration yet (uses
pyproject.tomlif present, otherwise defaults) - Full document sync only (no incremental sync)