Language Server
Language Server (scaf-lsp)
Section titled “Language Server (scaf-lsp)”scaf-lsp is the language server for scaf, providing diagnostics, hover information, and other IDE features.
Installation
Section titled “Installation”go install github.com/rlch/scaf/cmd/scaf-lsp@latestVerify installation:
scaf-lsp --versionFeatures
Section titled “Features”Diagnostics
Section titled “Diagnostics”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 Information
Section titled “Hover Information”Hover over elements to see:
- Query definitions and their bodies
- Test descriptions and paths
- Parameter documentation
Go to Definition
Section titled “Go to Definition”Jump from:
- Test scope → Query definition
- Named setup → Imported setup
- Import → File
Document Symbols
Section titled “Document Symbols”Outline view showing:
- Queries
- Test scopes
- Groups
- Tests
Editor Setup
Section titled “Editor Setup”scaf.nvim starts the LSP automatically:
require("scaf").setup({ lsp = { enabled = true, -- default cmd = { "scaf-lsp" }, },})vim.api.nvim_create_autocmd("FileType", { pattern = "scaf", callback = function() vim.lsp.start({ name = "scaf-lsp", cmd = { "scaf-lsp" }, root_dir = vim.fs.dirname( vim.fs.find({ ".scaf.yaml", ".git" }, { upward = true })[1] ), }) end,})local lspconfig = require("lspconfig")local configs = require("lspconfig.configs")
if not configs.scaf then configs.scaf = { default_config = { cmd = { "scaf-lsp" }, filetypes = { "scaf" }, root_dir = lspconfig.util.root_pattern(".scaf.yaml", ".git"), single_file_support = true, }, }end
lspconfig.scaf.setup({})LSP Capabilities
Section titled “LSP Capabilities”Supported
Section titled “Supported”| Capability | Description |
|---|---|
textDocument/publishDiagnostics | Error/warning diagnostics |
textDocument/hover | Hover information |
textDocument/definition | Go to definition |
textDocument/documentSymbol | Document outline |
Planned
Section titled “Planned”| Capability | Description |
|---|---|
textDocument/completion | Auto-completion |
textDocument/rename | Rename symbol |
textDocument/formatting | Format document |
textDocument/references | Find references |
Configuration
Section titled “Configuration”Command Line Options
Section titled “Command Line Options”# Verbose loggingscaf-lsp --verbose
# Custom log filescaf-lsp --log-file=/tmp/scaf-lsp.log
# TCP mode (for debugging)scaf-lsp --tcp --port=9999Environment Variables
Section titled “Environment Variables”| Variable | Description |
|---|---|
SCAF_LSP_LOG | Log level (debug, info, warn, error) |
SCAF_LSP_LOG_FILE | Log file path |
Diagnostics
Section titled “Diagnostics”Error Types
Section titled “Error Types”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'Diagnostic Severity
Section titled “Diagnostic Severity”| Severity | Description |
|---|---|
| Error | Parse errors, undefined references |
| Warning | Duplicate definitions, unused queries |
| Information | Style suggestions |
| Hint | Best practice recommendations |
Troubleshooting
Section titled “Troubleshooting”LSP Not Starting
Section titled “LSP Not Starting”-
Verify installation:
Terminal window which scaf-lspscaf-lsp --version -
Check PATH in your shell:
Terminal window echo $PATH -
Try running manually:
Terminal window echo '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"capabilities":{}}}' | scaf-lsp
No Diagnostics
Section titled “No Diagnostics”- Check filetype:
:set ft?should showscaf - Check LSP is attached:
:LspInfo - Enable verbose logging and check output
Performance Issues
Section titled “Performance Issues”- Large files may cause lag
- Try disabling real-time diagnostics
- File an issue with reproduction steps
Development
Section titled “Development”Building from Source
Section titled “Building from Source”git clone https://github.com/rlch/scafcd scafgo build ./cmd/scaf-lspRunning Tests
Section titled “Running Tests”go test ./lsp/...Debug Mode
Section titled “Debug Mode”Run with TCP for easier debugging:
# Terminal 1scaf-lsp --tcp --port=9999
# Terminal 2 (connect with netcat)nc localhost 9999