Crates.io | tree-sitter-nickel |
lib.rs | tree-sitter-nickel |
version | 0.3.0 |
source | src |
created_at | 2023-09-14 08:24:33.910375 |
updated_at | 2024-10-01 15:52:37.555017 |
description | Nickel grammar for the tree-sitter parsing library |
homepage | |
repository | https://github.com/nickel-lang/tree-sitter-nickel |
max_upload_size | |
id | 972399 |
size | 1,408,072 |
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
from grammar.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 in src
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 fileAs with other tree-sitter grammars, this repository comes with bindings for the following languages: