Neovim
This guide will walk through setting up syntax highlighting using Treesitter.
It is assumed that the nvim-treesitter plugin is installed.
The guide will use ~/Git/Spawn/ as a reference parent directory for cloned
spawnlang repositories and uses Unix-like commands. Please adapt them to custom needs.
Syntax highlighting
To achieve syntax highlighting, we will use Treesitter. The parsed syntax tree enables queries that allow fine-grained highlighting and integrate with Neovim's extensive plugin system.
Clone the tree-sitter-spawn repository
Below performs a filtered clone, which is lighter while preserving accessibility.
# ~/Git/Spawn
git clone --filter=blob:none https://github.com/spawnlang/tree-sitter-spawn.git
Add spawn to your nvim-treesitter config
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.spawn = {
install_info = {
url = "~/Git/Spawn/tree-sitter-spawn", -- local path or git repo
files = { "src/parser.c", "src/scanner.c" },
},
filetype = "sp",
}
Link the queries to your Neovim config directory
mkdir -p ~/.config/nvim/queries/spawn \
&& ln -s ~/Git/Spawn/tree-sitter-spawn/queries/*.scm ~/.config/nvim/queries/spawn/
Create an autocommand to handle the .sp filetype
vim.api.nvim_create_autocmd({ "BufRead" }, {
pattern = { "*.sp" },
command = "set ft=spawn",
})