Setup LSP
import { Steps, Aside, Tabs, TabItem } from ‘@astrojs/starlight/components’;
kag-lsp is a Language Server Protocol implementation for KAG scripts (.ks files). It provides:
- Syntax highlighting and error diagnostics
- Hover documentation for every built-in tag and attribute
- Go-to-definition for labels, macros, and files
- Auto-completion for tag names and attribute keys
- Find-all-references for labels and macros
Build from source
Section titled “Build from source”kag-lsp lives in the kag-lsp crate of this repository.
-
Clone the repository
Terminal window git clone https://github.com/haruki-nikaidou/kani-engine.gitcd kani-engine -
Build in release mode
Terminal window cargo build -p kag-lsp --releaseThe binary is placed at
target/release/kag-lsp. -
Put it on your
PATHTerminal window # Linux / macOScp target/release/kag-lsp ~/.local/bin/# Or add the release dir to PATH in your shell profileexport PATH="$PATH:/path/to/kani-engine/target/release"
Editor setup
Section titled “Editor setup”-
Install the KAG Script extension (or any generic LSP client such as vscode-glspc).
-
Add this to your
settings.json:{"languageServerExample.serverPath": "/path/to/kag-lsp"}Or, with a generic client:
{"genericLSP.servers": [{"name": "KAG","language": "kag","extensions": [".ks"],"command": ["kag-lsp"]}]}
Add to your Neovim config:
local lspconfig = require('lspconfig')local configs = require('lspconfig.configs')
if not configs.kag_lsp then configs.kag_lsp = { default_config = { cmd = { 'kag-lsp' }, filetypes = { 'kag' }, root_dir = lspconfig.util.root_pattern('Cargo.toml', '.git'), settings = {}, }, }end
lspconfig.kag_lsp.setup {}Then add a filetype detection rule:
autocmd BufRead,BufNewFile *.ks set filetype=kagAdd to ~/.config/helix/languages.toml:
[[language]]name = "kag"scope = "source.kag"file-types = ["ks"]language-servers = ["kag-lsp"]
[language-server.kag-lsp]command = "kag-lsp"Any editor that supports the LSP protocol can use kag-lsp. Configure your editor to:
- Launch
kag-lspas a server process (communicates over stdio) - Associate the
.ksfile extension with thekaglanguage ID
Features overview
Section titled “Features overview”Hover documentation
Section titled “Hover documentation”Hovering over a tag name displays its description, required and optional attributes, and a short example — sourced directly from the tag_defs module.
Go-to-definition
Section titled “Go-to-definition”Ctrl+click (or your editor’s equivalent) on a target=*label value jumps to the label’s definition, even across files.
Diagnostics
Section titled “Diagnostics”The LSP validates attribute completeness in real time:
| Severity | Condition |
|---|---|
| Error | A required attribute (e.g. storage= on [bg]) is missing |
| Warning | A recommended attribute is absent and the tag will have no effect |
Completion
Section titled “Completion”Pressing the completion key inside [ or after a space inside a tag gives you:
- All known tag names
- All valid attribute keys for the current tag
- Boolean value suggestions (
true/false)