Set up your editor
Every editor gets the same two things from Sprig:
- The language server,
sprig lsp, which comes with thesprigcommand. It shows problems as you type, including the ones a change in one file causes in another. It also completes@people,^anchors,[[file]]links and field keys, goes to the definition of an anchor or link, finds every line that names it, shows progress and blockers on hover, and ticks items and formats files. - A grammar for highlighting: the TextMate grammar in
editors/sprig.tmLanguage.json, or the tree-sitter grammar ineditors/tree-sitter-sprig.
Install sprig first; the editors below find it on your PATH:
cargo install --locked --git https://github.com/oddurs/sprig sprig-clisprig --versionThe language server treats the folder your editor opened as the workspace, so open the folder that holds your plans rather than a single file.
VS Code
Section titled “VS Code”The extension in editors/vscode registers .sprig files, highlights them
and runs the language server it bundles, so it needs nothing else installed.
It isn’t on the Marketplace yet. Until it is, install a package built by CI:
- Download
sprig-<platform>.vsixfrom the latest run of the vscode workflow. - Run Extensions: Install from VSIX… from the command palette and pick it.
To use a different sprig, set sprig.server.path.
CI holds this to a test that opens examples/bakery/ in VS Code with only the
extension installed and checks the problems it reports.
Neovim
Section titled “Neovim”Neovim 0.9 or later needs no plugins. Copy
editors/neovim/sprig.lua
into your config, for example as ~/.config/nvim/plugin/sprig.lua. It sets the
filetype, starts sprig lsp for every .sprig buffer, and turns on tree-sitter
highlighting when the parser is installed.
For highlighting, build the parser and copy the queries:
git clone https://github.com/oddurs/sprigcd sprig/editors/tree-sitter-sprigtree-sitter build -o ~/.config/nvim/parser/sprig.somkdir -p ~/.config/nvim/queries/sprigcp queries/highlights.scm ~/.config/nvim/queries/sprig/If you use nvim-lspconfig, the same server can be added as a custom
configuration with cmd = { 'sprig', 'lsp' } and filetypes = { 'sprig' }.
CI follows this section on a clean config: it loads sprig.lua and the
parser, opens examples/bakery/lease.sprig and deletes ^signed. It then
waits for bakery.sprig and kitchen.sprig, which name it, to report a
problem.
Add to ~/.config/helix/languages.toml, with rev set to a commit of this
repository:
[language-server.sprig]command = "sprig"args = ["lsp"]
[[language]]name = "sprig"scope = "source.sprig"file-types = ["sprig"]roots = [".git"]comment-token = "//"indent = { tab-width = 2, unit = " " }language-servers = ["sprig"]
[[grammar]]name = "sprig"source = { git = "https://github.com/oddurs/sprig", rev = "COMMIT", subpath = "editors/tree-sitter-sprig" }Then fetch and build the grammar, and copy the highlight queries into your runtime directory:
hx --grammar fetch && hx --grammar buildmkdir -p ~/.config/helix/runtime/queries/sprigcp editors/tree-sitter-sprig/queries/highlights.scm ~/.config/helix/runtime/queries/sprig/hx --health sprig should then list the language server and highlighting.
Zed reaches a language server and a grammar only through an extension, and there isn’t one for Sprig yet (cairn 0147). Until there is, Zed has no Sprig support.
Other editors
Section titled “Other editors”Any editor with an LSP client can run sprig lsp over standard input and
output for files ending in .sprig:
- Emacs: with eglot, add
(add-to-list 'eglot-server-programs '(sprig-mode . ("sprig" "lsp"))). - Sublime Text: with the LSP package, add a client whose command is
["sprig", "lsp"]and whose selector matches.sprigfiles. - Anything else: the server speaks UTF-8 positions when the client offers
them and UTF-16 otherwise, and asks the client to watch
**/*.sprigwhen it can.
GitHub, which highlights with the same TextMate grammar as VS Code, will show Sprig once Linguist knows the language. That is a later step.