Skip to content

Repository files navigation

Tree-Sitter Grammar for MimIR

Integrations

Helix

Helix integration is currently available in my fork. There is currently no plan to upstream the changes as MimIR is not (yet) relevant to the public and the grammar itself does not handle all of its grammar properly. This will be moved to a plugin once plugin support lands in helix master.

VSCode

A VSCode plugin is available here

Neovim

Neovim does not know about Mim yet, so nvim-treesitter (branch main) has to be told about this repository. Unlike Helix, Neovim uses the queries in queries/ - capture names differ between the two editors, so the Helix queries linked above will not work here.

vim-mim already does step 1 for you and adds what a grammar cannot provide - filetype detection, comment settings, and abbreviations for the Unicode terminals - plus a regex syntax file that Neovim falls back to whenever the parser is missing. With it installed, only step 2 is left.

  1. Add the following to your init.lua:
vim.filetype.add({
    extension = { mim = "mim" },
})

vim.api.nvim_create_autocmd("User", {
    pattern = "TSUpdate",
    callback = function()
        require("nvim-treesitter.parsers").mim = {
            install_info = {
                url = "https://github.com/mimir/tree-sitter-mim",
                queries = "queries",
            },
        }
    end,
})
  1. Run :TSInstall mim inside of Neovim. This downloads the repository, compiles src/parser.c and installs queries/. :TSUpdate mim pulls a newer version later on.

  2. nvim-treesitter main does not enable highlighting by itself. Distributions such as LazyVim do it for you; otherwise add

vim.api.nvim_create_autocmd("FileType", {
    pattern = "mim",
    callback = function()
        vim.treesitter.start()
    end,
})

Working on the grammar

Point install_info at a local clone instead - queries/ is then symlinked into Neovim's parser directory, so edits to the .scm files take effect right away and only :TSInstall! mim is needed after a change to grammar.js:

install_info = {
    path = vim.fn.expand("~/treesitter/tree-sitter-mim"),
    queries = "queries",
    generate = false,
    generate_from_json = false,
},

About

Tree-Sitter Parser for Mim

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages