Skip to content

Language Server

scaf-lsp is the language server for scaf, providing diagnostics, hover information, and other IDE features.

Terminal window
go install github.com/rlch/scaf/cmd/scaf-lsp@latest

Verify installation:

Terminal window
scaf-lsp --version

Real-time error detection:

  • Syntax errors — Invalid scaf syntax
  • Undefined queries — Test scopes referencing undefined queries
  • Duplicate definitions — Queries or tests with same name
  • Type mismatches — Invalid value types in statements

Hover over elements to see:

  • Query definitions and their bodies
  • Test descriptions and paths
  • Parameter documentation

Jump from:

  • Test scope → Query definition
  • Named setup → Imported setup
  • Import → File

Outline view showing:

  • Queries
  • Test scopes
  • Groups
  • Tests

scaf.nvim starts the LSP automatically:

require("scaf").setup({
lsp = {
enabled = true, -- default
cmd = { "scaf-lsp" },
},
})
CapabilityDescription
textDocument/publishDiagnosticsError/warning diagnostics
textDocument/hoverHover information
textDocument/definitionGo to definition
textDocument/documentSymbolDocument outline
CapabilityDescription
textDocument/completionAuto-completion
textDocument/renameRename symbol
textDocument/formattingFormat document
textDocument/referencesFind references
Terminal window
# Verbose logging
scaf-lsp --verbose
# Custom log file
scaf-lsp --log-file=/tmp/scaf-lsp.log
# TCP mode (for debugging)
scaf-lsp --tcp --port=9999
VariableDescription
SCAF_LSP_LOGLog level (debug, info, warn, error)
SCAF_LSP_LOG_FILELog file path

Syntax Error

users.scaf:5:1: error: unexpected token 'test', expected '}'

Undefined Query

users.scaf:10:1: error: undefined query 'GetUsr' (did you mean 'GetUser'?)

Duplicate Definition

users.scaf:15:1: warning: duplicate query definition 'GetUser'

Import Error

users.scaf:1:8: error: cannot find module './shared/fixtures'
SeverityDescription
ErrorParse errors, undefined references
WarningDuplicate definitions, unused queries
InformationStyle suggestions
HintBest practice recommendations
  1. Verify installation:

    Terminal window
    which scaf-lsp
    scaf-lsp --version
  2. Check PATH in your shell:

    Terminal window
    echo $PATH
  3. Try running manually:

    Terminal window
    echo '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"capabilities":{}}}' | scaf-lsp
  1. Check filetype: :set ft? should show scaf
  2. Check LSP is attached: :LspInfo
  3. Enable verbose logging and check output
  1. Large files may cause lag
  2. Try disabling real-time diagnostics
  3. File an issue with reproduction steps
Terminal window
git clone https://github.com/rlch/scaf
cd scaf
go build ./cmd/scaf-lsp
Terminal window
go test ./lsp/...

Run with TCP for easier debugging:

Terminal window
# Terminal 1
scaf-lsp --tcp --port=9999
# Terminal 2 (connect with netcat)
nc localhost 9999