Nickel grammar for tree-sitter.
Tree sitter is a parser framework for programming language tooling. Tree sitter enables semantically aware highlighting, indentation, folding, and much more. This project provides a tree sitter grammar definition for Nickel.
Every editor has to provide specific queries for its own use. Currently, we provide example highlighting queries in the style of Neovim.
The Nickel language has been added to
nvim-treesitter. Please refer to
nvim-treesitter
's installation guide there to get Nickel highlighting out of
the box. Note that while nvim-treesitter
uses the latest grammar definition
from this repository automatically, the highlighting queries are hosted directly
by nvim-treesitter
. They were copied at some point in time from this
repository, but they might not always be up to date.
You can use a local version of those queries with Neovim for developing, testing or customization purpose:
-
Clone this repository
-
Configure tree-sitter to use this grammar:
local parser_config = require("nvim-treesitter.parsers").get_parser_configs() parser_config.nickel = { install_info = { url = "PATH_TO_WHERE_YOU_CLONED_IT", files = {"src/parser.c", "src/scanner.c"}, branch = "main", generate_requires_npm = false, requires_generate_from_grammar = false, }, }
grammar.js
is the main grammar definition. Most other files are generated fromgrammar.js
and this is most probably the file you want to modify when updating the grammarsrc/scanner.c
contains a custom scanner required by the Nickel grammarsrc/*
most other files insrc
are auto-generated and shouldn't be modified directlycorpus/
contains a test suitebindings/
contains the bindings to this parser for various languages.
The project comes with a flake.nix
containing everything needed to work on the
grammar itself via Nix. With a
flake-enabled Nix, Just run nix develop
at
the root of this repository to be dropped in a shell with all the needed
commands available.
Without Nix, you have to install tree-sitter
and other dependencies manually.
You should be able to deduce a list of requirements easily by reading
flake.nix
.
tree-sitter generate
will build the grammar from the current definitiontree-sitter test
tests the built grammar against corpustree-sitter parse <FILE>
parses the given file.tree-sitter highlight <FILE>
tests highlighting of the given file
As with other tree-sitter grammars, this repository comes with bindings for the following languages:
- C
- Go
- Node
- Python
- Rust
- Swift