on master help sign in
epocsquadron/add tree sitter twig (#1602)

* Add tree-sitter-twig grammer and highlights The gammar itself is quite basic, but is much better than nothing for working with real files consisting mostly of html. * Docgen for newly added grammar

commitd6b6ad879e297ff786ce520acd3ce9c4ff3c2e8e authorDaniel S Poulin <dan.poulin@digitalsurgeons.com> dateMon 31 Jan 2022, 22:35 (5 years ago) parent983a53b
6 files changed+34
.gitmodules+4 book/src/generated/lang-support.md+1 helix-syntax/languages/tree-sitter-twig+1 languages.toml+9 runtime/queries/twig/highlights.scm+16 runtime/queries/twig/injections.scm+3
.gitmodules+4
@@ -218,3 +218,7 @@
218218 path = helix-syntax/languages/tree-sitter-iex
219219 url = https://github.com/elixir-lang/tree-sitter-iex
220220 shallow = true
221+[submodule "helix-syntax/languages/tree-sitter-twig"]
222+ path = helix-syntax/languages/tree-sitter-twig
223+ url = https://github.com/eirabben/tree-sitter-twig.git
224+ shallow = true
book/src/generated/lang-support.md+1
@@ -54,6 +54,7 @@
5454| toml | ✓ | | | |
5555| tsq | ✓ | | | |
5656| tsx | ✓ | | | `typescript-language-server` |
57+| twig | ✓ | | | |
5758| typescript | ✓ | | ✓ | `typescript-language-server` |
5859| vue | ✓ | | | |
5960| wgsl | ✓ | | | |
helix-syntax/languages/tree-sitter-twignew file+1

Submodule changed.

languages.toml+9
@@ -231,6 +231,15 @@ roots = []
231231
232232indent = { tab-width = 4, unit = " " }
233233
234+[[language]]
235+name = "twig"
236+scope = "source.twig"
237+injection-regex = "twig"
238+file-types = ["twig"]
239+roots = []
240+
241+indent = { tab-width = 2, unit = " " }
242+
234243[[language]]
235244name = "latex"
236245scope = "source.tex"
runtime/queries/twig/highlights.scmnew file+16
@@ -0,0 +1,16 @@
1+(comment_directive) @comment
2+
3+[
4+ "{%"
5+ "{%-"
6+ "{%~"
7+ "%}"
8+ "-%}"
9+ "~%}"
10+ "{{"
11+ "{{-"
12+ "{{~"
13+ "}}"
14+ "-}}"
15+ "~}}"
16+] @keyword
runtime/queries/twig/injections.scmnew file+3
@@ -0,0 +1,3 @@
1+((content) @injection.content
2+ (#set! injection.language "html")
3+ (#set! injection.combined))