Skip to content

hhamud/tree-sitter-noir

Repository files navigation

Tree-sitter Noir

test npm Latest version gpl-3.0

Noir grammar and parser for tree-sitter

Emacs

To use with Emacs; use the following package here.

NeoVim

To use this parser with current nvim-treesitter, register the custom parser in the User TSUpdate hook, make sure Neovim recognizes .nr files as noir, and start tree-sitter highlighting for that filetype:

vim.api.nvim_create_autocmd("User", {
  pattern = "TSUpdate",
  callback = function()
    require("nvim-treesitter.parsers").noir = {
      install_info = {
        url = "https://github.com/hhamud/tree-sitter-noir",
        files = { "src/parser.c", "src/scanner.c" },
        branch = "main",
        queries = "queries/neovim",
      },
    }
  end,
})

vim.filetype.add({
  extension = {
    nr = "noir",
  },
})

vim.api.nvim_create_autocmd("FileType", {
  pattern = "noir",
  callback = function(args)
    vim.treesitter.start(args.buf, "noir")
  },
})

Then run :TSInstall noir.

If you are on an older nvim-treesitter version that does not support the queries key in install_info, copy queries/neovim/highlights.scm into your Neovim queries/noir/ runtime directory manually.

Other

To install the grammar from NPM

npm i tree-sitter-noir

To install the grammar from cargo

cargo add tree-sitter-noir

References

Contributing

Contributions to tree-sitter-noir are welcome. If you find any issues or have suggestions for improvement, please create a new issue or submit a pull request on the GitHub repository.

About

Treesitter grammer and parser for the Noir Language

Resources

License

Stars

Watchers

Forks

Contributors

Languages