Neovim
spork-lang 0.6.0
Install and configure syntax, indentation, LSP diagnostics, navigation, completion, and commands.
The Neovim integration provides filetype detection, syntax highlighting, indentation, and LSP setup for Spork. Its source lives in the spork-lang repository under editors/nvim.
Features#
- Syntax highlighting for
.sporkfiles - LSP integration via
nvim-lspconfig - Lisp-style indentation
- Filetype detection
Requirements#
- Neovim 0.8.0 or later
- Spork CLI installed (
sporkcommand available) - nvim-lspconfig is optional; without it, the plugin uses Neovim's built-in LSP client directly
Installation#
Using a local checkout#
Clone spork-lang, then point your plugin manager at its Neovim subdirectory.
With lazy.nvim:
{
dir = "/path/to/spork-lang/editors/nvim",
name = "spork.nvim",
config = function()
require("spork").setup()
end,
}
With packer.nvim:
use {
"/path/to/spork-lang/editors/nvim",
config = function()
require("spork").setup()
end,
}
Manual Installation#
Add the plugin directory to your runtimepath in init.lua:
vim.opt.runtimepath:append("/path/to/spork-lang/editors/nvim")
require("spork").setup()
Or in init.vim:
set runtimepath+=/path/to/spork-lang/editors/nvim
lua require("spork").setup()
Configuration#
Basic Setup#
require("spork").setup()
Custom Configuration#
require("spork").setup({
-- Path to spork executable (default: "spork")
cmd = "spork",
-- Additional LSP server arguments
cmd_args = { "lsp" },
-- Enable LSP (default: true)
lsp = true,
-- Enable default keybindings (default: true)
default_keymaps = true,
-- LSP on_attach callback (called after default keymaps are set)
on_attach = function(client, bufnr)
-- Your custom on_attach logic
end,
-- LSP capabilities (merged with defaults)
capabilities = nil,
})
LSP Configuration with nvim-lspconfig#
If you prefer to configure the LSP manually with nvim-lspconfig:
-- First, set up the spork plugin for syntax/filetype
require("spork").setup({ lsp = false })
-- Then configure LSP manually
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
-- Register the spork LSP if not already registered
if not configs.spork then
configs.spork = {
default_config = {
cmd = { "spork", "lsp" },
filetypes = { "spork" },
root_dir = lspconfig.util.root_pattern("spork.it", ".git"),
settings = {},
},
}
end
lspconfig.spork.setup({
on_attach = your_on_attach,
capabilities = your_capabilities,
})
Key Mappings#
The plugin sets up default keybindings when LSP attaches to a buffer:
| Key | Mode | Action |
|---|---|---|
K | Normal | Hover documentation |
gd | Normal | Go to definition |
gD | Normal | Go to declaration |
gl | Normal | Show line diagnostics |
[d | Normal | Previous diagnostic |
]d | Normal | Next diagnostic |
<leader>q | Normal | Show all diagnostics in location list |
<leader>ds | Normal | Document symbols |
<C-Space> | Insert | Trigger completion |
<C-k> | Insert | Signature help |
Disabling Default Keymaps#
If you prefer to set up your own keymaps:
require("spork").setup({
default_keymaps = false,
on_attach = function(client, bufnr)
-- Your custom keybindings here
local opts = { buffer = bufnr, noremap = true, silent = true }
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
-- etc.
end,
})
Commands#
The plugin provides the following commands:
| Command | Description |
|---|---|
:SporkInfo | Show Spork LSP information |
:SporkRestart | Restart the Spork LSP server |
LSP Features#
When the LSP is enabled, you get:
- Completion: Symbols, special forms, and macros
- Hover: Documentation and type information
- Go to Definition: Jump to symbol definitions
- Diagnostics: Parse and compile errors
- Document Symbols: Outline of definitions in the file
Troubleshooting#
LSP not starting#
Ensure
sporkis in your PATH:which sporkTest the LSP server manually:
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | spork lspCheck the LSP log:
vim.lsp.set_log_level("debug") -- Then check :LspLog
Syntax highlighting not working#
Ensure the plugin is loaded before opening .spork files:
:set runtimepath?
-- Should include the nvim plugin path
Source#
The integration source is maintained in the spork-lang editor directory.