This guide shows how to start the Glyim language server and wire it into an editor that speaks the Language Server Protocol.
Start the server
Section titled “Start the server”After building the workspace (see the getting started tutorial), the server binary is available at target/release/glyim-lsp:
./target/release/glyim-lspThe server communicates over stdio, the standard LSP transport, and publishes diagnostics with textDocument/publishDiagnostics as you edit.
Configure your editor
Section titled “Configure your editor”Point your editor’s LSP client at the glyim-lsp binary. Most editors expose this as a “custom server command” setting. A generic configuration pattern:
{ "languageserver": { "glyim": { "command": "/absolute/path/to/glyim/target/release/glyim-lsp", "args": [], "filetypes": ["glyim"] } }}Available capabilities
Section titled “Available capabilities”glyim-lsp implements:
- Diagnostics — compiler errors and warnings pushed as you type (
publishDiagnostics), the same set pulled per file on demand (textDocument/diagnostic), and the whole session pulled per workspace on demand (workspace/diagnostic), all driven by the same pipeline the CLI uses. A per-file pull for a file others import carriesrelatedDocuments: one report per transitive dependent, the files the driver re-analyses when the pulled file changes. A clean analysed file answers an empty full report; a file the server never analysed answers null; the workspace pull is always answerable and reports every analysed file in ascending file id. - Navigation — goto definition, goto type definition, goto declaration, goto implementation (the
implblocks behind a trait or a type, across every analysed file), find references, workspace symbols, document symbols, and document folding ranges. - Document links — include-macro literals become clickable file links: the string argument of
include!,include_str!, andinclude_bytes!resolves against the containing document’s directory (absolute literals are used as-is). Non-file macros and composed arguments such asinclude!(concat!(…))produce no link — the target is not knowable from source, so nothing is guessed. - Type hierarchy — prepare the trait, struct, or enum under the cursor (
textDocument/prepareTypeHierarchy) and walk its supertypes (the traits implemented for a type) or its subtypes (the impl self types behind a trait) over the recorded impl facts. A trait’s own supertypes and a type’s subtypes answer null — the HIR records no supertrait store, so nothing is guessed. - Monikers —
textDocument/monikeranswers the recorded identity of the cursor’s symbol for external indexers (LSIF/SCIP-style consumers): the spelled path of theusebinding the cursor sits on, the qualified module path of the definition it sits on, or the name-only resolution of a bare usage. A local binding (recorded without a usable extent) and a name nothing records answer null — no identity is guessed, and every moniker carriesdocumentuniqueness because each session file carries its own module tree. - Inline values —
textDocument/inlineValueanswers the recordedletbindings of a requested range as variable lookups (the facts a debug adapter stopped on a frame needs to render inline variable names), served from the stored HIR’s byte-exact pattern spans. Annotated bindings answer too — the request carries no type payload — and a range over pure expression lines answers null; nothing is guessed. - Call hierarchy — prepare a function under the cursor (definition site or a call to it) and walk its incoming callers or outgoing callees, served from the same reference graph rename uses.
- Highlighting — document highlight of the symbol under the cursor, selection ranges that expand token → statement → item → file, and semantic tokens so editors color declarations and members from the real parse tree.
- Linked editing —
textDocument/linkedEditingRangegroups the same-scope occurrences of the symbol under the cursor for multi-cursor editing: two same-named locals in different function bodies never edit together (the reference graph’s scope-owner filter the highlight and rename requests enforce applies here too). - Hover and completion — type information on hover and completion suggestions from the def-map.
- Signature help — parameter hints while typing a call, with the active parameter computed from the cursor’s position.
- Inlay hints — inline type annotations on un-annotated
letbindings, rendered from the type checker’s inferred types (annotated bindings and types with no stable spelling are skipped). - Range formatting —
textDocument/rangeFormattingre-indents the whole lines a selection claims at the depth the unselected prefix leaves, through the same formatter core the full-document request reads (one formatter, two wire shapes). An empty selection and an already-formatted span answer null; nothing is guessed. - Formatting — document formatting for consistent layout, and on-type formatting when you type a closing bracket:
textDocument/onTypeFormattingpairs the}/)/]just typed with its matching opener over the stored parse tree and replaces the line’s whitespace run with the opener line’s indentation. Unbalanced shapes, family mismatches, and already-correct indents answer nothing — the engine never guesses. - Execute command — the code-lens resolve’s
glyim.showReferencescommand executes throughworkspace/executeCommand: the echoed[uri, range]payload re-joins against the same reference graph the resolve counted, and the request answers the referenced locations — the count the lens title rendered is exactly what the execution answers, empty for an uncalled item. Unknown command ids, malformed payloads, and echoes that re-join against no live item-level definition are rejected with a JSON-RPC error naming the failed step. - Code lenses —
textDocument/codeLensputs a lens on every top-level item of the open document (the reference graph’s item-level definitions), andcodeLens/resolveattaches the live reference count as the lens command — recomputed at resolve time, so the number reflects the session’s latest analysis. - Rename —
prepareRenamevalidation followed by symbol renaming across the workspace. - Code actions — quick fixes, including:
- add missing
matcharms, - generate an
implblock, - remove unused imports,
- auto-import for unresolved names.
- add missing
- Save-time format edits —
textDocument/willSaveWaitUntilanswers, before the editor writes the file, the edits that bring the stored text to the same saved form thetextDocument/formattingrequest would produce (one formatter, two wire shapes). An already-formatted document answers null — no edit churn. - Watched files —
workspace/didChangeWatchedFilesrefreshes what no editor ever opened: a non-open file whose content moved on disk re-analyses from the file’s content (the driver’s dependent refresh follows), and a non-open file that no longer exists is forgotten. - File operations —
workspace/didCreateFilesindexes a created file no editor owns from disk (its definitions may resolve bare usages in the open documents), andworkspace/didDeleteFilesforgets a deleted one — the watched-files ownership rules over the client’s declared operations. - File renames —
workspace/didRenameFilesmoves the session’s path-keyed state with the file: an editor-owned document re-keys in place (its recorded facts stay valid, and the dependency graph’s edges follow it), a watched load re-analyses from the new path, and the diagnostics report republishes under the new URI. - Workspace folders — the session records the folder set it serves: the client’s initialize folder list (the deprecated
rootUrias the fallback) seeds the store,workspace/didChangeWorkspaceFoldersre-derives it (known removals drop, unknown removals skip, re-adds keep their first recording), and the folder queries answer which recorded folders contain a path — the scoping primitive per-folder work slots into. A folder whose URI does not resolve to a file path is skipped, never invented. - Document color —
textDocument/documentColoranswers every string literal that spells a hex color payload (#RGB,#RGBA,#RRGGBB,#RRGGBBAA) as the swatch site your editor renders inline: the payload extent (quotes excluded) carries the parsed channels. A color embedded in prose ("bg: #ff00aa") produces no swatch — the site boundaries would be guessed.textDocument/colorPresentationanswers the picker’s recolor echo with exactly one presentation, the canonical lowercase hex spelling over the reported extent; a range no recorded site occupies is never rewritten.
Fall back to JSON diagnostics
Section titled “Fall back to JSON diagnostics”If you drive tooling without LSP, the compiler emits one JSON object per diagnostic:
glyim input.g --error-format jsonThis is the same feed the language server uses internally, which makes it suitable for custom integrations, CI checks, and log analysis.
