coc.nvim Integration for Silk
This page describes the coc.nvim client for the silk-lsp language server.
The Silk compiler repository includes a coc.nvim extension under coc/. It is a thin wrapper around silk-lsp and
should stay aligned with the LSP capabilities documented in lsp silk.
Location and Layout#
coc/contains the full coc.nvim extension.coc/src/index.tswiressilk-lspinto coc.nvim.coc/src/snippets.jsonprovides a small set of Silk snippets.
Requirements#
- Neovim with
coc.nvim(engine version^0.0.80). silk-lspon yourPATHor a configured absolute path.filetype=silkfor*.slkand*.silkbuffers (includingbuild.slk; use the Vim plugin undervim/or your own filetype setup).
Install (local, from the Silk compiler repository)#
-
Build the language server:
cd /path/to/silk zig build -
Build the extension:
cd /path/to/silk/coc npm install npm run build -
Symlink into Coc’s extensions directory:
mkdir -p ~/.config/coc/extensions/node_modules ln -s /path/to/silk/coc ~/.config/coc/extensions/node_modules/coc-silk -
Restart Neovim.
Configuration#
Add settings to your coc-settings.json:
{
"silk.enabled": true,
"silk.startUpMessage": true,
"silk.path": "silk-lsp",
"silk.args": [],
"silk.env": {},
"silk.stdRoot": "",
"silk.noStd": false,
"silk.filetypes": ["silk"],
"silk.rootPatterns": [
"build.slk",
"silk.toml",
"build.zig",
"build.zig.zon",
".git"
],
"silk.outputChannel": "Silk Language Server"
}
silk.stdRoot maps to silk-lsp --std-root <path> and silk.noStd maps to silk-lsp --nostd. You can also use silk.args or silk.env.SILK_STD_ROOT for custom setups.
Commands#
Use :CocCommand for server lifecycle management:
silk.start— start the language server.silk.stop— stop the language server.silk.restart— restart the language server.
Features#
The extension exposes the capabilities currently implemented by silk-lsp:
- diagnostics from the Silk lexer, parser, and type checker,
- hover with approximate type hints for identifiers and struct fields,
- heuristic go-to-definition across the module set (functions, lets, structs, struct fields, and impl methods), including local
letbindings and parameters, - keyword/identifier completion with symbol-aware details and struct member suggestions,
- struct-literal field suggestions in
Type { ... }expressions, - signature help while typing function and method calls,
- top-level document symbols for
fn,let,struct,enum,error,interface,ext, andimpldeclarations.
Reference: LSP protocol and server.
Notes and Troubleshooting#
- If diagnostics are missing, check that
:set filetype?reportssilk. - If
silk-lspcannot be found, setsilk.pathto the full path of yoursilk-lspbinary. - Use
:CocList outputsand open theSilk Language Serverchannel for logs.
Source repository · Edit this page · View Markdown