scrii_ls — language server

scrii_ls is a Language Server Protocol
implementation for Scrii. It brings real IDE features — not just regex
syntax coloring — to any editor that speaks LSP over stdio.

Feature matrix

Capability Notes
textDocument/completion Scope-aware symbol + std-module completion (trigger chars . and :)
textDocument/definition Jump to declaration (works across import)
textDocument/hover Declared type, const/fn classification, -> descriptions
textDocument/documentSymbol Document outline
textDocument/diagnostic Parse errors, undefined variables, member-access checks; #DECLARE name comments suppress undefined-variable errors
textDocument/semanticTokens/full Legend: namespace, function, variable, parameter, property, constant

Semantic tokens come from real analysis, not text matching: call positions
are function, parameters are parameter, const declarations and
SCREAMING_CASE identifiers are constant — consistent with the tree-sitter
highlighting (see tree-sitter-scrii).

Declaration suppression

Undefined-variable diagnostics are suppressed on a per-name basis with a
#DECLARE name comment:

#DECLARE external_fn    # defined by a native plugin, not this file
external_fn("hi")

This is useful for globals injected by a host embedder or plugin that the
analyzer can’t see.

Build

From the repository root:

cmake -S . -B build && cmake --build build --target scrii_ls

Or standalone (FetchContent pulls the LSP protocol framework):

cmake -S . -B build
cmake --build build

Editor setup

The server speaks generic stdio LSP. Neovim (nvim-lspconfig style):

require'lspconfig'.scrii_ls = {
  cmd = { '/path/to/scrii_ls' },
  filetypes = { 'scrii' },
}

Other editors that support LSP over stdio configure the same command + filetype pair. Point cmd at the scrii_ls binary produced by the build.

Internals

  • analyzer.cpp/.hpp — symbol table, type inference, diagnostics
  • semantic.cpp — semantic-token extraction
  • document.cpp/.hpp — open-document tracking
  • features/ — one translation unit per LSP feature
  • server.cpp/.hpp — JSON-RPC dispatch and capabilities

Tests live in test/ (Catch2); they are skipped automatically when Catch2
is unavailable.