Editor Setup

Silt ships with an LSP server and Vim/Neovim syntax highlighting.

LSP Server

Start the language server with:

silt lsp

The server communicates over stdin/stdout using the standard LSP protocol. As the protocol has it, it ends with status 0 after the editor’s shutdown request and exit, and with 1 when the session ends without a shutdown: an exit that comes first, or an editor that goes away.

A buffer that was never saved (untitled:Untitled-1) is checked as a file of its own, outside any package. It reads no file on disk; it can import another unsaved buffer whose name ends in .silt (import helper for untitled:helper.silt).

The server fetches nothing: opening a folder runs no git and connects to no host. A git dependency of the project that is not in silt’s cache yet, or that silt.lock pins no commit for, is an error on its line of silt.toml, “not fetched or not pinned in silt.lock: run silt check”; silt check (or silt run, silt test) fetches it and pins its commit, or says why it cannot (a project it refuses gets no silt.lock).

Supported Features

FeatureDescription
DiagnosticsLex, parse, and type errors on every edit
HoverShow inferred type for any expression (K in nvim); on the name of a function that calls itself, or of one of a group that call each other, its stack verdict: constant stack, depth follows the data (and the parameter it descends on), or deep (not checked); on a method that calls a method of its own trait: not checked (trait call)
Go to definitionJump to where a function, let, type, variant, trait, method, record field or local is declared; from an import or a module’s alias to the module’s file, from an item of import m.{ f } to f (gd)
Go to type definitionJump from a value to the definition of its type
Go to implementationJump from a trait method to its implementations
CompletionKeywords, builtins, stdlib functions, user definitions
Signature helpParameter names and types while typing a call
Document symbolsOutline of all declarations in the file
Workspace symbol searchFind any definition across the entire workspace by name
FormattingFormat via the existing silt fmt formatter
Find referencesLocate every use of a definition, a trait method, a record field or a local across the workspace, and of a module’s alias in its file. A field is found by its record type: x of P is not x of Q
Document highlightHighlight every occurrence of the symbol under the cursor in the active file
RenameRename a definition, a trait method, a record field, a local or a module’s alias and update every reference (<leader>rn). A field written alone is written out: renaming the field x makes P { x } into P { new: x }. A field’s name is also its key in the text json writes and in what json and toml read, and it is shown when the record is printed, so a rename of a field changes those too. Not renamed: silt’s own names and the fields of its types, the fields of a type of another package, a name that a file of a fetched git dependency holds (rename it in its repository), and a module’s name, which is its file’s. A rename to a name that is taken where it is written is refused with the reason, and so is one that a local holds in a file that imports the name, where the local would hide the import
Code actionsQuick fixes and refactors offered for the symbol or diagnostic under the cursor
Inlay hintsInferred types for let-bindings and unannotated parameters rendered as inline hints
Folding rangesEditor-driven code folding for blocks, records, and match arms
Selection rangesSmart syntax-aware expand/shrink selection
Semantic tokensToken classification for richer editor highlighting

Neovim

Minimal setup (built-in LSP)

Add to your init.lua:

-- Register .silt filetype
vim.filetype.add({ extension = { silt = 'silt' } })

-- Load syntax highlighting from silt's editors directory
vim.opt.runtimepath:append('/path/to/silt/editors/vim')

-- Start LSP on silt files
vim.api.nvim_create_autocmd('FileType', {
  pattern = 'silt',
  callback = function()
    vim.lsp.start({
      name = 'silt',
      cmd = { 'silt', 'lsp' },
      -- The package's directory (where silt.toml is); a file outside a
      -- package gets the server too. vim.fs.root needs Neovim 0.10.
      root_dir = vim.fs.root(0, { 'silt.toml', '.git' }),
    })
  end,
})
vim.api.nvim_create_autocmd('LspAttach', {
  callback = function(ev)
    local opts = { buffer = ev.buf }
    vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
    vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
    vim.keymap.set('n', '<leader>fm', vim.lsp.buf.format, opts)
    vim.keymap.set('n', '<leader>fs', '<cmd>Telescope lsp_document_symbols<cr>', opts)
    vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
    vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
    vim.keymap.set('i', '<C-s>', vim.lsp.buf.signature_help, opts)
  end,
})

Format on save

vim.api.nvim_create_autocmd('BufWritePre', {
  pattern = '*.silt',
  callback = function()
    vim.lsp.buf.format({ async = false })
  end,
})

Without the language server, an editor can pipe the buffer through silt fmt -, which reads the program from stdin and writes the formatted program to stdout, and through silt check - (add --format json for diagnostics a plugin can read), which names the buffer <stdin> in what it reports. Each diagnostic of the JSON form has its file and its start and end as line, col, end_line and end_col, counted from 1 as the terminal shows them; a file that could not be read is at line 1, column 1.

Completion (nvim-cmp)

Install nvim-cmp with the cmp-nvim-lsp source for automatic completion from the LSP.

VS Code

A dedicated VS Code extension lives in editors/vscode/. It bundles a TextMate grammar for syntax highlighting and bootstraps silt lsp as a language server. Because the extension launches the same server, it inherits every advertised capability: diagnostics, hover, go-to-definition, go-to-type-definition, go-to-implementation, completion, signature help, document symbols, workspace symbol search, formatting, find references, document highlight, rename, code actions, inlay hints, folding ranges, selection ranges, and semantic tokens.

Build and install it locally:

cd editors/vscode
npm install
npm run compile

Then either package it as a VSIX:

npx vsce package
code --install-extension silt-vscode-0.1.0.vsix

…or symlink it into your extensions directory:

ln -s "$(pwd)" ~/.vscode/extensions/silt-lang.silt-vscode-0.1.0

Reload VS Code and open any .silt file — the extension activates on onLanguage:silt and spawns the language server over stdio.

Settings:

  • silt.serverPath (default silt) — path to the silt binary used as the language server. Set this if silt is not on your PATH.
  • silt.trace.server — controls LSP message tracing (off | messages | verbose).

If you’d rather use a generic LSP client extension without the bundled grammar, configure it to run silt lsp for the silt language id.

Syntax Highlighting

Vim/Neovim syntax files are shipped in editors/vim/:

  • editors/vim/syntax/silt.vim — full syntax highlighting
  • editors/vim/ftdetect/silt.vim — filetype detection

Add to your runtimepath:

vim.opt.runtimepath:append('/path/to/silt/editors/vim')

What’s highlighted

  • Keywords (fn, let, match, type, etc.)
  • Builtins (println, panic, Ok, Err, Some, None, etc.)
  • Module names before . (list, string, map, etc.)
  • Comments (-- line and {- -} block, nestable)
  • Strings with {interpolation} and escape sequences
  • Triple-quoted raw strings ("""...""")
  • Numbers (int and float)
  • Operators (|>, ->, .., ?, ^, etc.)
  • Function, type, and trait names after their keyword