LSP: Language-Server Intelligence & Edit Gate
Kompile's lsp tool exposes real language servers directly to agents — no grep approximations when type resolution, overload disambiguation, or compile/lint diagnostics are needed. One lsp tool handles navigation, refactoring, diagnostics, server lifecycle, and a fail-closed edit-verification gate (action=check).
Operations at a glance
| Action | Required Inputs | What It Does |
|---|---|---|
definition | Target (file_path + line + column or symbol) | Jumps to the exact symbol definition |
references | Target | Finds every semantic reference across the project |
call_hierarchy | Explicit file_path + line + column | Incoming (default) or outgoing call edges (max_depth=1, max_results=20 up to 100) |
hover | Target | Returns resolved type signature and documentation at a position |
symbols | file_path (or symbol) | Document outline with symbol kinds and line ranges |
workspace_symbols | query + (file_path or language) | Project-wide symbol search from the active language server |
rename | Target + new_name | Computes a WorkspaceEdit — dry_run=true by default (renders per-file diff preview) |
diagnostics | file_path (or symbol) | Returns compile/lint diagnostics; explicitly reports if the server never answered instead of pretending the file is clean |
check | file_paths=[...] | Fail-closed edit-verification gate across all touched files (and every required backend) |
servers | server_action=list|status|start|stop|restart | Inspect installed/running servers or control their lifecycle |
Addressing a target
For definition, references, hover, and rename, you can address a symbol in either of two ways:
- Explicit position:
file_path+line+column— 1-based (Kompile converts to LSP's 0-based UTF-16 coordinates internally). - By symbol name:
symbol(+ optionalproject_id) — resolved automatically through the Local Code Index (local_code_index action=indexfirst if the repo isn't indexed yet).
NOTE
call_hierarchy requires advertised language-server support and explicit declaration coordinates (file_path + line + column), not symbol lookup. If prepareCallHierarchy finds ambiguous overloads, Kompile returns the choices rather than guessing.
The fail-closed edit gate (lsp action=check)
lsp action=check is Kompile's semantic verification gate for touched files. Instead of returning a vague diagnostics dump, it produces a structured verdict per file per checking context, followed by an OVERALL verdict.
Verdict semantics
| Status | Meaning |
|---|---|
PASS | Checked cleanly with zero errors |
FAIL | Real compile/type errors reported by the language server (up to 25 errors reported per verdict) |
NOT_CHECKED | Could not verify — reason is explicitly reported (TIMEOUT, CHANGED_DURING_CHECK, NO_SERVER, SERVER_ERROR, BUSY). Never treated as a pass and never disguised as a compile error. |
NOT_APPLICABLE | That backend/compile database does not compile anything for this file |
OVERALL PASS rules:
- Every file in
file_pathsmust have at least onePASSand zeroFAILorNOT_CHECKEDverdicts. - A file that no backend/server checked fails the overall gate.
Checking contexts
| Context | When Used |
|---|---|
EXACT | C/C++/CUDA source file with its own row in compile_commands.json |
INCLUDER | C/C++/CUDA header (.h, .hh, .hpp, .hxx, .cuh, .inl, .ipp, .tpp) checked through translation units that directly include it (max_dependents, 0 = all) |
INFERRED | Header no TU includes, or a new source not yet in compile_commands.json (interpolated compile command — marked provisional, not CMake inclusion proof) |
PROJECT | All non-C-family languages checked by their project language server (jdtls, pyright, rust-analyzer, tsserver, etc.) |
Multi-backend C / C++ / CUDA (clangd)
For C, C++, and CUDA repos with multiple build configurations (e.g., CPU, CUDA, ARM), Kompile pools one clangd variant per compile database (root|language#variant):
- Auto-discovery: Reads
<project>/.kompile/lsp-check.json(which maps namedcompileDatabasessuch ascpuandcudato theircompile_commands.jsonpaths plusdefaultBackends), or falls back automatically tocompile_commands.jsonat the repo root orbuild/. You can ask the agent "Configure.kompile/lsp-check.jsonfor ourbuild-cpuandbuild-cudacompile databases as default backends" instead of writing it by hand. - Per-call overrides:
backend=["cpu", "cuda"]: Makes those databases and a verdict on each mandatory.compile_db=["NAME=PATH"]: Adds an ad-hoc compile database for the check.
- CUDA (
nvcc) handling: Kompile automatically rewritesnvcccompile rows into clang CUDA frontend flags soclangdcan type-check.cu/.cuhfiles. (Keep in mind: this checks clang's CUDA frontend, notnvccdevice codegen.)
Staged overlay checking (check before writing to the tree)
Pass overlay=<dir> (and optional overlay_root=<dir>, defaulting to the project root) to send <dir>/<rel> as unsaved in-memory buffers for <overlay_root>/<rel>. This lets agents or review pipelines run full LSP verification on staged/candidate edits without modifying the working tree.
Tuning parameters & scope
timeout_ms: Per-check timeout (default180000ms / 3 min)settle_ms: Diagnostics settle window after document sync (default1500ms)jobs: Parallelism across files/backends- What
checkdoes not prove: Syntax and semantic type-checking only — it is not a substitute for build-graph inclusion, linking, or runtime test execution.
Safe refactoring (lsp action=rename)
rename is dry-run by default (dry_run=true):
- First call
lsp action=renamewith your target andnew_name→ Kompile asks the language server for theWorkspaceEditand returns a per-file diff preview plus a summary. - Review the preview, then re-run with
dry_run=false(which also requireseditpermission) to apply the edits atomically across files.
How Kompile manages language servers (LspServerManager)
- Lazy startup & pooling: Servers start on first use and are pooled process-wide by
root|language(orroot|language#variantfor compile-database variants). - Idle reaping: A background reaper stops idle servers after 10 minutes (or 30 minutes for Java /
jdtls, whose initial project indexing is heavier). - Bounded crash restarts: Crashed servers auto-restart within a budget of 2 restarts per 10-minute window so a broken server never enters an infinite crash loop.
- Logs: Server stderr is drained to
~/.kompile/logs/lsp/for diagnostics. - Shutdown cleanup: All managed servers are torn down cleanly on session exit or restart.
Supported languages & custom overrides
Kompile ships built-in definitions for 45+ languages — the first installed binary in each fallback chain wins (run lsp action=servers server_action=list to see what is installed on your machine, or see Languages & Required Tools for exact install commands, root markers, and per-language build prerequisites):
- JVM: Java (
jdtls), Kotlin (kotlin-lsp|kotlin-language-server), Scala (metals), Groovy, Clojure - Systems / Native: C/C++/CUDA/ObjC (
clangd|ccls), Rust (rust-analyzer), Go (gopls), Zig (zls), Swift (sourcekit-lsp), Fortran (fortls), C# (csharp-ls|OmniSharp), F# (fsautocomplete) - Scripting / Data: Python (
pyright|basedpyright|pylsp|jedi-language-server), Ruby (ruby-lsp|solargraph), PHP (intelephense|phpactor), Lua, Perl, R, Julia, Bash, PowerShell - Functional: Haskell (
hls), OCaml (ocamllsp), Elixir, Erlang (elp|erlang_ls), Gleam, Elm, Dart - Web & Config: TypeScript/JavaScript (
typescript-language-server|vtsls), Vue, Svelte, Astro, HTML, CSS/SCSS/Less, GraphQL, JSON, YAML, TOML (taplo), XML (lemminx), Markdown (marksman), LaTeX (texlab), SQL, Dockerfile, Terraform, Nix (nil|nixd), CMake, Protobuf
Need a custom language-server binary or want to disable one? Ask the agent in chat (for example, "Switch Python LSP to basedpyright-langserver --stdio and disable the Markdown language server in ~/.kompile/lsp-servers.json"). Under the hood, per-user overrides live in ~/.kompile/lsp-servers.json (servers.<lang> supports enabled, command, alternatives, and filenames for extension-less files such as Dockerfile or CMakeLists.txt).
Next steps
- Coding Tools Overview
- Local Code Index & Code Graph — the offline structural index that powers
lspsymbol lookup - File Context, Notes & Multi-Agent Activity