Tree-sitter grammar for the Sigil programming language
npm install tree-sitter-sigilA tree-sitter grammar for the Sigil programming language.
- Full syntax support for Sigil's unique features:
- Evidentiality markers: ! (known), ? (uncertain), ~ (reported), ‽ (paradox)
- Morpheme operators: τ (transform), φ (filter), σ (sort/sum), ρ (reduce), and more
- Pipeline syntax: data |τ{_ * 2} |φ{_ > 10}
- Rust-like constructs: structs, enums, traits, impl blocks
- Query files for syntax highlighting, indentation, and locals
Add to your nvim-treesitter config:
``lua
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.sigil = {
install_info = {
url = "https://github.com/Daemoniorum-LLC/sigil-lang",
files = { "tree-sitter-sigil/src/parser.c" },
branch = "main",
location = "tree-sitter-sigil",
},
filetype = "sigil",
}
`
Then run :TSInstall sigil
The grammar will be available in Helix once it's added to the helix-editor/helix grammars.
For now, you can build manually:
`bash`
cd tree-sitter-sigil
npm install
npm run generate
Then configure in ~/.config/helix/languages.toml:
`toml
[[language]]
name = "sigil"
scope = "source.sigil"
file-types = ["sigil", "sg"]
roots = ["Sigil.toml"]
[[grammar]]
name = "sigil"
source = { path = "/path/to/sigil-lang/tree-sitter-sigil" }
`
- Node.js >= 18
- tree-sitter CLI: npm install -g tree-sitter-cli
`bash`
npm install
npm run generate
`bash`
npm test
`bash`
tree-sitter parse /path/to/file.sigil
- queries/highlights.scm - Syntax highlightingqueries/indents.scm
- - Automatic indentationqueries/locals.scm
- - Local variable scoping
The grammar provides special highlighting for Sigil's unique features:
`sigil`
let known! = compute(); // ! = known (verified)
let uncertain? = maybe(); // ? = uncertain (validated)
let reported~ = external(); // ~ = reported (external)
`sigil``
// Greek letters get @function.builtin highlighting
let doubled = nums |τ{_ * 2}; // τ = transform
let filtered = nums |φ{_ > 0}; // φ = filter
let total = nums |Σ; // Σ = sum
MIT License - Daemoniorum, LLC