Neovim
sprocket.nvim provides WDL support for Neovim, powered by the Sprocket language server (sprocket analyzer).
The plugin includes:
- LSP integration. Completions, diagnostics, hover documentation, go-to-definition, and references powered by Sprocket.
- Syntax highlighting. WDL 1.0 through 1.3, via Vim regex patterns.
- Document formatting. Format WDL files on save or on demand, through the language server or the
sprocket formatcommand. - Commands. Validate, lint, and format files without leaving Neovim.
- Statusline component. Show language server status in your statusline (lualine and similar).
- Plugin integrations. Works with
nvim-autopairsfor auto-closing<<</>>>and~{/}pairs, and withComment.nvimfor#comments.
Requirements
- Neovim 0.11 or greater.
- The
sprocketbinary. See Installation, or let the plugin install it for you.
Installation
Install the plugin with your package manager of choice:
{
"stjude-rust-labs/sprocket.nvim",
ft = "wdl",
opts = {},
}use {
"stjude-rust-labs/sprocket.nvim",
ft = "wdl",
config = function()
require("sprocket").setup({})
end,
}Plug 'stjude-rust-labs/sprocket.nvim'
" In your init.lua or after/plugin:
lua require("sprocket").setup({})Installing Sprocket
Download the latest release from GitHub Releases and make sure sprocket is on your PATH:
# Example for macOS/Linux
curl -LO https://github.com/stjude-rust-labs/sprocket/releases/latest/download/sprocket-<version>-<platform>.tar.gz
tar -xzf sprocket-*.tar.gz
mv sprocket ~/.local/bin/Alternatively, enable auto_install in the plugin configuration to download the binary automatically.
Configuration
All options, with their defaults:
require("sprocket").setup({
binary = {
path = nil, -- Custom path to sprocket binary
auto_install = false, -- Auto-download from GitHub if not found
check_updates = false, -- Check for updates on startup
},
server = {
lint = false, -- Enable additional linting via `--lint` flag
log_level = "quiet", -- "quiet" | "info" | "verbose"
},
format_on_save = false, -- Auto-format WDL files before saving
status = {
enabled = true, -- Enable statusline component
icons = {
ok = "",
warning = "",
error = "",
loading = "",
},
},
lsp = {
capabilities = nil, -- Custom LSP capabilities (auto-detects cmp-nvim-lsp)
on_attach = nil, -- Callback when LSP attaches to buffer
handlers = nil, -- Custom LSP handlers (merged with defaults)
},
})Setting server.lint = true turns on the lint rules in addition to analysis diagnostics.
Example with keymaps
{
"stjude-rust-labs/sprocket.nvim",
ft = "wdl",
opts = {
lsp = {
on_attach = function(client, bufnr)
local map = function(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = desc })
end
-- Navigation
map("n", "gd", vim.lsp.buf.definition, "Go to definition")
map("n", "gr", vim.lsp.buf.references, "Find references")
map("n", "gI", vim.lsp.buf.implementation, "Go to implementation")
map("n", "K", vim.lsp.buf.hover, "Hover documentation")
-- Actions
map("n", "<leader>rn", vim.lsp.buf.rename, "Rename symbol")
map("n", "<leader>ca", vim.lsp.buf.code_action, "Code action")
map("n", "<leader>f", function()
vim.lsp.buf.format({ async = true })
end, "Format buffer")
-- Diagnostics
map("n", "[d", vim.diagnostic.goto_prev, "Previous diagnostic")
map("n", "]d", vim.diagnostic.goto_next, "Next diagnostic")
map("n", "<leader>e", vim.diagnostic.open_float, "Show diagnostic")
end,
},
},
}Commands
All commands use the :Sprocket prefix:
| Command | Description |
|---|---|
:Sprocket info | Show version, binary path, and server status. |
:Sprocket restart | Restart the language server. |
:Sprocket stop | Stop the language server. |
:Sprocket version | Display the installed sprocket version. |
:Sprocket update | Download and install the latest sprocket version. |
:Sprocket check [path] | Validate a WDL file (defaults to the current buffer). |
:Sprocket lint [path] | Run the linter on a WDL file. |
:Sprocket format [path] | Format a WDL file. |
:Sprocket log | Open the language server log file for debugging. |
Statusline
Add the status component to your statusline to see language server status at a glance:
-- lualine.nvim
require("lualine").setup({
sections = {
lualine_x = { require("sprocket").status },
},
})Icons indicate server status:
- Running normally
- Warning
- Error
- Starting or loading
Health check
Run :checkhealth sprocket to verify your setup. The health check reports:
- Neovim version compatibility.
- Binary availability and version.
- Required tools (
curl, andtarorunzipfor auto-install). - Language server status.
- Optional dependencies (
nvim-cmp). - The current configuration.
Optional dependencies
| Plugin | Benefit |
|---|---|
| nvim-cmp + cmp-nvim-lsp | Enhanced completion with LSP integration. |
| nvim-autopairs | Auto-close <<</>>>, ~{/}, and ${/} pairs. |
| Comment.nvim | Toggle comments with gc mappings. |
Troubleshooting
The language server does not start.
- Verify that Sprocket is installed:
:Sprocket version. - Check the log:
:Sprocket log. - Make sure the file has a
.wdlextension. - Run
:checkhealth sprocket.
No completions.
- Confirm the server is running:
:Sprocket info. - If you use
nvim-cmp, verify thatcmp-nvim-lspis configured. - Check your WDL file for syntax errors.
Formatting does not work.
- Check for syntax errors; formatting requires valid WDL.
- Update Sprocket:
:Sprocket update. - Check the log:
:Sprocket log.
Contributing
Contributions are welcome. File issues, request features, or open a pull request in the stjude-rust-labs/sprocket.nvim repository. The plugin is licensed under either the Apache License 2.0 or the MIT license, at your option.