Syntax highlighting (Crystal) #4945
|
I'm currently trying to add support for Crystal to helix. In the Helix repo I cloned: [[language]]
name = "crystal"
scope = "source.cr"
file-types = ["cr"]
roots = ["shard.yml", "shard.lock"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "crystal"
source = { git = "https://github.com/will/tree-sitter-crystal", rev = "15597b307b18028b04d288561f9c29794621562b" }And added a file [
"def"
"end"
"if"
"else"
"while"
] @keywordI then ran I then opened a file ending in |
Replies: 1 comment 1 reply
|
It looks like the queries are invalid: you can see in the log file ( |
It looks like the queries are invalid: you can see in the log file (
:log-openwithin helix) that the query file fails the analysis phase because the"if","else", and"while"nodes aren't in the grammar. You can check the grammar file here: https://github.com/will/tree-sitter-crystal/blob/main/grammar.js. Literal strings in the javascript grammar file can be queried with string literals (e.g."struct","enum") but the rest must be named nodes, e.g.(struct_definition),(enum_definition). See the tree-sitter docs on queries: https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries, https://tree-sitter.github.io/tree-sitter/syntax-highlighting#highlights