forked from thousandyears/Lexicon
-
Notifications
You must be signed in to change notification settings - Fork 0
Editor Generic LSP Clients
Oliver Atkinson edited this page May 31, 2026
·
1 revision
Any editor that can launch a stdio language server can use lexicon-lsp.
The server command is:
lexicon-lspor:
/absolute/path/to/Lexicon/.build/release/lexicon-lspIt reads and writes normal LSP messages over stdin/stdout.
swift build -c release --product lexicon-lspAt 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" }
]
}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.
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.
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")- 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-lspis executable. - Open the editor's LSP log and check initialization errors.
- Run
swift run lexicon validate lexicons/commerce.lexiconoutside the editor.