Skip to content

Commit

Permalink
epocsquadron/add tree sitter twig (#1602)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
EpocSquadron authored Feb 1, 2022
1 parent 983a53b commit d6b6ad8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,7 @@
path = helix-syntax/languages/tree-sitter-iex
url = https://github.com/elixir-lang/tree-sitter-iex
shallow = true
[submodule "helix-syntax/languages/tree-sitter-twig"]
path = helix-syntax/languages/tree-sitter-twig
url = https://github.com/eirabben/tree-sitter-twig.git
shallow = true
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
| toml || | | |
| tsq || | | |
| tsx || | | `typescript-language-server` |
| twig || | | |
| typescript || || `typescript-language-server` |
| vue || | | |
| wgsl || | | |
Expand Down
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-twig
Submodule tree-sitter-twig added at b74441
9 changes: 9 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ roots = []

indent = { tab-width = 4, unit = " " }

[[language]]
name = "twig"
scope = "source.twig"
injection-regex = "twig"
file-types = ["twig"]
roots = []

indent = { tab-width = 2, unit = " " }

[[language]]
name = "latex"
scope = "source.tex"
Expand Down
16 changes: 16 additions & 0 deletions runtime/queries/twig/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(comment_directive) @comment

[
"{%"
"{%-"
"{%~"
"%}"
"-%}"
"~%}"
"{{"
"{{-"
"{{~"
"}}"
"-}}"
"~}}"
] @keyword
3 changes: 3 additions & 0 deletions runtime/queries/twig/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
((content) @injection.content
(#set! injection.language "html")
(#set! injection.combined))

0 comments on commit d6b6ad8

Please sign in to comment.