Tree-sitter grammar for the MIPS assembly language.
First, run npm install
to install the tree-sitter cli
. Next, build the grammar using npm run build
, which generates the necessary parser files, or use it to parse a file with npm run parse $file
.
Install tree-sitter (e.g. nix-shell -p tree-sitter
).
Build the grammar using tree-sitter generate
and parse a file with tree-sitter parse $file
.
To use tree-sitter-mips in neovim, the plugin nvim-treesitter is required.
Installing the lastest grammar from this repo involves the following three steps:
- Update your Neovim config for nvim-treesitter to refer to tree-sitter-mips. Add this to your tree-sitter config in neovim:
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.mips = {
install_info = {
url = 'https://github.com/omeyenburg/tree-sitter-mips', -- You can use a local path
branch = 'main',
files = { 'src/parser.c' },
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = 'asm',
}
- Tree-sitter should automatically install tree-sitter-mips for you when you open a
.asm
file. If not, run:TSInstall mips
inside Neovim. - Copy the files from
./queries/
to the neovim config directory at$XDG_CONFIG_HOME/nvim/queries/mips/
- see the Adding queries section of the nvim-treesitter README. They are required to enable highlighting.
mkdir -p $XDG_CONFIG_HOME/nvim/queries/mips/
cp ./queries/* $XDG_CONFIG_HOME/nvim/queries/mips/
If you are looking for a more general grammar for assembly, check out tree-sitter-asm which supports features of other instruction sets, yet it lacks some specific features of MIPS.