Skip to content
LSP (experimental)

LSP Integration (experimental)

Ulmi can drive a Language Server Protocol (LSP) server in the background and expose its query capabilities to the agent as additional tools. This gives the model precise navigation primitives instead of having to grep the codebase.

The integration is experimental — opt in with the ULMI_EXPERIMENTAL_LSP=true environment variable.

The package is internal/lsp.

Enabling

ULMI_EXPERIMENTAL_LSP=true ulmi

When the variable is set, Ulmi scans the current workspace (3 levels deep, common ignored directories skipped), counts file extensions, and picks the first language server whose extensions match the workspace and whose binary is on PATH.

The detector is in internal/lsp/detect.go and the launch glue in internal/cli/tui.go (maybeStartLSP).

If no server is found you see:

warning: lsp: no LSP server found for workspace; skipping.

The TUI continues without LSP tools.

Supported language servers

In priority order:

LanguageDefault commandExtensions
Gogopls.go
TypeScript / JavaScripttypescript-language-server --stdio.ts, .tsx, .js, .jsx, .mjs, .cjs
Rustrust-analyzer.rs
Python (pyright)pyright-langserver --stdio.py
Python (pylsp)pylsp.py
C / C++clangd.c, .cpp, .h, .hpp, .cc, .cxx
Javajdtls.java
Rubysolargraph stdio.rb
Lualua-language-server.lua

The first matching server wins. Install the corresponding binary to opt into a language.

Tools registered

When LSP is active, five tools are added to the registry:

ToolPurpose
lsp_definitionGo to definition for a symbol at file:line:character.
lsp_referencesAll references to the symbol (declaration included).
lsp_hoverHover documentation as plain markdown text.
lsp_symbolsWorkspace symbol search by query string.
lsp_call_hierarchyIncoming or outgoing calls for a symbol (uses prepareCallHierarchy followed by incomingCalls / outgoingCalls).

Tool definitions are in internal/lsp/tools.go.

Lifecycle

The Manager lazily starts the language server on the first tool call:

  1. The configured command is launched as a subprocess.
  2. initialize is called with the workspace root URI.
  3. Subsequent calls share the same connection.
  4. Close(ctx) is called when the TUI exits, terminating the subprocess. Shutdown is cancelled by the parent context (quit / SIGINT) instead of waiting out the 3s timeout.

This means the LSP server only spins up if the agent actually uses one of the tools.

Limitations

  • Only one language is detected per workspace. Polyglot repositories pick whichever server appears first in the priority list.
  • Tools work on the file system that the language server already indexes. After large file rewrites the index may lag for a moment.
  • Errors from the server are surfaced as tool errors and the model can retry; persistent failures generally indicate a missing setup step (e.g. Go module not initialised, tsconfig.json missing).
  • Snapshot integration does not apply — LSP tools are read-only.

Examples

lsp_definition

{ "file": "internal/api/handler.go", "line": 42, "character": 18 }

Returns one or more file:line:character locations.

lsp_symbols

{ "query": "NewEngine" }

Returns matching symbol names and the files where they are declared.

lsp_call_hierarchy

{
  "file": "internal/agent/engine.go",
  "line": 100,
  "character": 18,
  "direction": "outgoing"
}

Returns the chain of functions called by the symbol at the given position.

Disabling LSP

Unset the environment variable. There is no per-language disable: the detector simply does not start anything.

Future work

The LSP layer is intentionally minimal — it covers the operations that map cleanly to short tool calls. Possibilities for future iterations:

  • Per-language overrides in ulmi.yaml.
  • Diagnostic streaming (e.g. surfacing compile errors after edits).
  • Code-action support.