Skip to content

Editor Support

Oliver Atkinson edited this page May 31, 2026 · 1 revision

Editor Support

lexicon-lsp is a sidecar language server for Lexicon-aware completions and diagnostics.

It is intentionally small today. It supports:

  • workspace initialization
  • open/change document tracking
  • completions
  • diagnostics
  • project configuration discovery

It does not currently provide hover, go-to-definition, rename, formatting, code actions, or semantic tokens.

What It Indexes

The server builds an index from the composed live graph. That means it includes:

  • imported lexicons
  • node-level grafts
  • inherited paths from types
  • synonym paths
  • connected root vocabulary

The editor sees the same graph that generation sees.

Where Completion Works

Lexicon document references:

submit:
	+ commerce.type.boolean
active:
	= enabled
selected:
	? @ commerce.ui.checkout.button.primary

Go exact-path calls:

l("commerce.api.order.submit")

Rust exact-path macros:

l!(commerce.api.order.submit)

Diagnostics

Diagnostics include:

  • unknown Lexicon paths in supported reference contexts
  • invalid Lexicon LSP configuration
  • composition failures
  • leading-space indentation in .lexicon files

The indentation diagnostic matters because Lexicon hierarchy uses tabs. Spaces in leading indentation are ignored for hierarchy.

Project Configuration

Put lexicon-lsp.json at the workspace root:

{
  "lexicon": "lexicons/commerce.lexicon"
}

For multiple independent roots:

{
  "lexicons": [
    { "scope": "apps/storefront", "lexicon": "lexicons/storefront.lexicon" },
    { "scope": "packages/payments", "lexicon": "packages/payments/payments.lexicon" }
  ]
}

The longest matching scope wins for each opened file.

Accepted configuration filenames:

  • lexicon-lsp.json
  • .lexicon-lsp.json
  • lexicon.conf
  • .lexicon.conf

See Project Configuration.

Editor Pages

  • Zed - currently the best-supported editor path because this repo includes a Zed dev extension.
  • VS Code - use a thin language-client extension or a generic LSP client for experimentation.
  • GoLand and JetBrains - CLI validation works now; full LSP requires a JetBrains plugin wrapper.
  • Generic LSP Clients - Neovim, Helix, and other clients that can launch a stdio LSP server.

Build the Language Server

swift build -c release --product lexicon-lsp

Use the absolute path in editor configuration:

/absolute/path/to/Lexicon/.build/release/lexicon-lsp

Or put the binary on PATH:

cp .build/release/lexicon-lsp /usr/local/bin/lexicon-lsp

External Editor Docs

These editor docs are useful when wiring lexicon-lsp into an editor:

Clone this wiki locally