Skip to content

chant serve lsp

chant serve lsp [path]

chant serve lsp starts a Language Server Protocol server over stdio with Content-Length framing. This enables editor features like completions, hover documentation, diagnostics, and code actions for chant projects.

You typically don’t invoke this directly — your editor or IDE plugin launches the server automatically.

The server advertises capabilities based on which lexicon plugin providers are available:

CapabilityConditionDescription
textDocumentSyncAlwaysFull document sync on open/change
diagnosticProviderAlwaysLint diagnostics for open .ts files
completionProviderPlugin has completionProvider()Resource and property name completions
hoverProviderPlugin has hoverProvider()Hover documentation for resource types
codeActionProviderPlugin has codeActionProvider()Quick-fix code actions

When a lexicon plugin provides completions, the server triggers on these characters:

. (space) " ' ` (

Completions include resource type names, property names, intrinsic functions, and cross-file resource references.

The server runs lint rules on every document open and change, publishing diagnostics in real time. Only .ts files are linted — other file types return empty diagnostics.

Diagnostics use the same rule set as chant lint, including all configured core rules (COR, EVL) and lexicon-specific rules.

When a lexicon plugin provides hover, the server returns documentation for resource types, property types, and attribute references at the cursor position.

Add this to your .vscode/settings.json or configure a VS Code extension that launches stdio-based LSP servers:

{
"chant.lsp.path": "npx",
"chant.lsp.args": ["chant", "serve", "lsp"]
}
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
configs.chant = {
default_config = {
cmd = { 'npx', 'chant', 'serve', 'lsp' },
filetypes = { 'typescript' },
root_dir = lspconfig.util.root_pattern('chant.config.ts', 'package.json'),
},
}
lspconfig.chant.setup({})

Any editor that supports stdio-based LSP servers can use chant. The command is:

Terminal window
chant serve lsp

The server communicates over stdin/stdout using the standard LSP protocol with Content-Length framing.

CodeMeaning
0Clean shutdown
1Unknown subcommand or startup failure