Skip to content

Editor Generic LSP Clients

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

Generic LSP Clients

Any editor that can launch a stdio language server can use lexicon-lsp.

The server command is:

lexicon-lsp

or:

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

It reads and writes normal LSP messages over stdin/stdout.

Build

swift build -c release --product lexicon-lsp

Project Config

At the workspace root:

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

For multiple roots:

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

Neovim

Minimal Lua setup:

vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
  pattern = "*.lexicon",
  callback = function()
    vim.bo.filetype = "lexicon"
    vim.bo.expandtab = false
    vim.bo.tabstop = 4
    vim.bo.shiftwidth = 4
  end
})

vim.api.nvim_create_autocmd("FileType", {
  pattern = { "lexicon", "go", "rust" },
  callback = function()
    vim.lsp.start({
      name = "lexicon-lsp",
      cmd = { "/absolute/path/to/Lexicon/.build/release/lexicon-lsp" },
      root_dir = vim.fs.root(0, { "lexicon-lsp.json", ".lexicon-lsp.json", ".git" })
    })
  end
})

This attaches the server to .lexicon, Go, and Rust buffers. Normal Go and Rust LSP servers can still run alongside it.

Helix

Add a language-server entry:

[language-server.lexicon-lsp]
command = "/absolute/path/to/Lexicon/.build/release/lexicon-lsp"

Then attach it to Lexicon files:

[[language]]
name = "lexicon"
scope = "source.lexicon"
file-types = ["lexicon"]
comment-token = "#"
indent = { tab-width = 4, unit = "\t" }
language-servers = ["lexicon-lsp"]

Attach it to Go or Rust only if your editor supports multiple language servers per language cleanly.

Expected Behavior

Completions should appear after a partial path:

node:
	+ commerce.api.
l("commerce.api.
l!(commerce.api.

Diagnostics should appear for unknown complete references:

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

Troubleshooting

  • Confirm the editor launches the server over stdio.
  • Confirm workspace root discovery includes lexicon-lsp.json.
  • Confirm the config path is relative to the config file.
  • Confirm lexicon-lsp is executable.
  • Open the editor's LSP log and check initialization errors.
  • Run swift run lexicon validate lexicons/commerce.lexicon outside the editor.

Clone this wiki locally