on master help sign in
docs: Add note about tree-sitter query precedence (#1314)
commit176fbe760a56945089de9f77e06f05f1639ba9be authorGokul Soumya <gokulps15@gmail.com> dateTue 21 Dec 2021, 07:33 (5 years ago) parent205dc87
1 file changed+11−1
book/src/guides/adding_languages.md+11−1
book/src/guides/adding_languages.md+11−1
@@ -42,7 +42,16 @@ These are the available keys and descriptions for the file.
4242
4343## Queries
4444
45−For a language to have syntax-highlighting and indentation among other things, you have to add queries. Add a directory for your language with the path `runtime/queries/<name>/`. The tree-sitter [website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries) gives more info on how to write queries.
45+For a language to have syntax-highlighting and indentation among
46+other things, you have to add queries. Add a directory for your
47+language with the path `runtime/queries/<name>/`. The tree-sitter
48+[website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries)
49+gives more info on how to write queries.
50+
51+> NOTE: When evaluating queries, the first matching query takes
52+precedence, which is different from other editors like neovim where
53+the last matching query supercedes the ones before it. See
54+[this issue][neovim-query-precedence] for an example.
4655
4756## Common Issues
4857
@@ -58,3 +67,4 @@ For a language to have syntax-highlighting and indentation among other things, y
5867
5968[treesitter-language-injection]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection
6069[languages.toml]: https://github.com/helix-editor/helix/blob/master/languages.toml
70+[neovim-query-precedence]: https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090