skir-language-server
v0.1.0
Published
Language Server Protocol implementation for the Skir schema language (Vim, Neovim, Emacs, ...)
Readme
Skir Language Server
A Language Server Protocol (LSP) implementation for the Skir schema language. Enables IDE features in Vim, Neovim, Emacs, and any other LSP-aware editor.
Features
| Feature | Description |
|---|---|
| Diagnostics | Syntax and type errors, config validation, and breaking-change warnings (when a snapshot is present) |
| Go to definition | Jump to the declaration of any type, field, constant, or method |
| Find references | List every usage of a symbol across the workspace |
| Hover | Show documentation comments for records, fields, methods and constants |
| Completion | Context-aware completions with auto-import of types from other modules |
| Rename | Rename a symbol and update all references across the workspace |
| Formatting | Format the current .skir file on save or on demand |
| File rename | Automatically update import paths in other files when a .skir file is renamed (via willRenameFiles) |
Requirements
- Node.js ≥ 22.12.0 (required for
require()of ES modules used by the Skir compiler) - A Skir workspace with a
skir.ymlfile
Installation
npm install -g skir-language-serverOr use it locally inside a project:
npm install --save-dev skir-language-serverUsage
The server communicates over stdio (the standard mode used by most editors):
skir-language-server --stdioOr directly via npx without a global installation:
npx skir-language-server --stdioEditor configuration
Neovim (nvim-lspconfig)
Add the following to your Neovim configuration (e.g. ~/.config/nvim/lua/plugins/skir.lua):
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.skir then
configs.skir = {
default_config = {
cmd = { "npx", "skir-language-server", "--stdio" },
filetypes = { "skir" },
root_dir = lspconfig.util.root_pattern("skir.yml"),
settings = {},
},
}
end
lspconfig.skir.setup({})You also need a filetype detection rule. Add to ~/.config/nvim/lua/filetypes.lua (or filetype.vim):
vim.filetype.add({ extension = { skir = "skir" } })Neovim (using mason-lspconfig or manual setup)
vim.api.nvim_create_autocmd("FileType", {
pattern = "skir",
callback = function()
vim.lsp.start({
name = "skir",
cmd = { "npx", "skir-language-server", "--stdio" },
root_dir = vim.fs.dirname(vim.fs.find("skir.yml", { upward = true })[1]),
})
end,
})coc.nvim
Add to your coc-settings.json:
{
"languageserver": {
"skir": {
"command": "npx",
"args": ["skir-language-server", "--stdio"],
"filetypes": ["skir"],
"rootPatterns": ["skir.yml"]
}
}
}Vim (vim-lsp)
if executable('npx')
au User lsp_setup call lsp#register_server({
\ 'name': 'skir',
\ 'cmd': {server_info -> ['npx', 'skir-language-server', '--stdio']},
\ 'whitelist': ['skir'],
\ })
endifAlso add filetype detection if .skir is not yet recognized:
autocmd BufRead,BufNewFile *.skir setfiletype skirEmacs (eglot)
(add-to-list 'auto-mode-alist '("\\.skir\\'" . skir-mode))
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(skir-mode . ("npx" "skir-language-server" "--stdio"))))Emacs (lsp-mode)
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("npx" "skir-language-server" "--stdio"))
:major-modes '(skir-mode)
:server-id 'skir-ls))Helix
Add to ~/.config/helix/languages.toml:
[[language]]
name = "skir"
scope = "source.skir"
file-types = ["skir"]
roots = ["skir.yml"]
language-servers = ["skir-language-server"]
[language-server.skir-language-server]
command = "npx"
args = ["skir-language-server", "--stdio"]Sublime Text (LSP package)
In Preferences → Package Settings → LSP → Settings, add:
{
"clients": {
"skir": {
"command": ["npx", "skir-language-server", "--stdio"],
"enabled": true,
"selector": "source.skir"
}
}
}How it works
The server scans the workspace for:
| File | Purpose |
|---|---|
| skir.yml | Workspace definition and dependency declarations |
| skir-src/**/*.skir | Source modules |
| skir-snapshot.json | Snapshot baseline for breaking-change detection |
| skir-external/dependencies.json | Pre-downloaded external dependency modules |
It uses the same compiler internals as the official Skir CLI (skir npm package) to parse, type-check, and resolve all modules. Diagnostics are published as LSP textDocument/publishDiagnostics notifications.
Building from source
npm install
npm run buildThe compiled server is at dist/server.js.
