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#

Requirements#

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:

KeyModeAction
KNormalHover documentation
gdNormalGo to definition
gDNormalGo to declaration
glNormalShow line diagnostics
[dNormalPrevious diagnostic
]dNormalNext diagnostic
<leader>qNormalShow all diagnostics in location list
<leader>dsNormalDocument symbols
<C-Space>InsertTrigger completion
<C-k>InsertSignature 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:

CommandDescription
:SporkInfoShow Spork LSP information
:SporkRestartRestart the Spork LSP server

LSP Features#

When the LSP is enabled, you get:

Troubleshooting#

LSP not starting#

  1. Ensure spork is in your PATH:

    which spork
    
  2. Test the LSP server manually:

    echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | spork lsp
    
  3. Check 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.