add tree-sitter-embedded-template (erb & ejs) (#2055)
After the incremental parsing rewrite for injections (which was released in 22.03 https://helix-editor.com/news/release-22-03-highlights/#incremental-injection-parsing-rewrite), we can now do combined injections which lets us pull in some templating grammars. The most notable of those is embedded-template - a pretty straightforward grammar that covers ERB and EJS. The grammar and highlights queries are shared between the two but they have different injections.
This commit is contained in:
parent
78b1600943
commit
494306ad7a
6 changed files with 51 additions and 0 deletions
|
@ -9,8 +9,10 @@
|
||||||
| css | ✓ | | | `vscode-css-language-server` |
|
| css | ✓ | | | `vscode-css-language-server` |
|
||||||
| dart | ✓ | | ✓ | `dart` |
|
| dart | ✓ | | ✓ | `dart` |
|
||||||
| dockerfile | ✓ | | | `docker-langserver` |
|
| dockerfile | ✓ | | | `docker-langserver` |
|
||||||
|
| ejs | ✓ | | | |
|
||||||
| elixir | ✓ | | | `elixir-ls` |
|
| elixir | ✓ | | | `elixir-ls` |
|
||||||
| elm | ✓ | | | `elm-language-server` |
|
| elm | ✓ | | | `elm-language-server` |
|
||||||
|
| erb | ✓ | | | |
|
||||||
| erlang | ✓ | | | `erlang_ls` |
|
| erlang | ✓ | | | `erlang_ls` |
|
||||||
| fish | ✓ | ✓ | ✓ | |
|
| fish | ✓ | ✓ | ✓ | |
|
||||||
| git-commit | ✓ | | | |
|
| git-commit | ✓ | | | |
|
||||||
|
|
|
@ -1088,3 +1088,25 @@ language-server = { command = "sourcekit-lsp" }
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "swift"
|
name = "swift"
|
||||||
source = { git = "https://github.com/Dispersia/tree-sitter-swift", rev = "e75240f89bb3bfd3396155859ae364e5c58d7377" }
|
source = { git = "https://github.com/Dispersia/tree-sitter-swift", rev = "e75240f89bb3bfd3396155859ae364e5c58d7377" }
|
||||||
|
|
||||||
|
[[language]]
|
||||||
|
name = "erb"
|
||||||
|
scope = "text.html.erb"
|
||||||
|
injection-regex = "erb"
|
||||||
|
file-types = ["erb"]
|
||||||
|
roots = []
|
||||||
|
indent = { tab-width = 2, unit = " " }
|
||||||
|
grammar = "embedded-template"
|
||||||
|
|
||||||
|
[[language]]
|
||||||
|
name = "ejs"
|
||||||
|
scope = "text.html.ejs"
|
||||||
|
injection-regex = "ejs"
|
||||||
|
file-types = ["ejs"]
|
||||||
|
roots = []
|
||||||
|
indent = { tab-width = 2, unit = " " }
|
||||||
|
grammar = "embedded-template"
|
||||||
|
|
||||||
|
[[grammar]]
|
||||||
|
name = "embedded-template"
|
||||||
|
source = { git = "https://github.com/tree-sitter/tree-sitter-embedded-template", rev = "d21df11b0ecc6fd211dbe11278e92ef67bd17e97" }
|
||||||
|
|
12
runtime/queries/ejs/highlights.scm
Normal file
12
runtime/queries/ejs/highlights.scm
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
(comment_directive) @comment
|
||||||
|
|
||||||
|
[
|
||||||
|
"<%#"
|
||||||
|
"<%"
|
||||||
|
"<%="
|
||||||
|
"<%_"
|
||||||
|
"<%-"
|
||||||
|
"%>"
|
||||||
|
"-%>"
|
||||||
|
"_%>"
|
||||||
|
] @keyword
|
7
runtime/queries/ejs/injections.scm
Normal file
7
runtime/queries/ejs/injections.scm
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
((content) @injection.content
|
||||||
|
(#set! injection.language "html")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((code) @injection.content
|
||||||
|
(#set! injection.language "javascript")
|
||||||
|
(#set! injection.combined))
|
1
runtime/queries/erb/highlights.scm
Normal file
1
runtime/queries/erb/highlights.scm
Normal file
|
@ -0,0 +1 @@
|
||||||
|
; inherits: ejs
|
7
runtime/queries/erb/injections.scm
Normal file
7
runtime/queries/erb/injections.scm
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
((content) @injection.content
|
||||||
|
(#set! injection.language "html")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((code) @injection.content
|
||||||
|
(#set! injection.language "ruby")
|
||||||
|
(#set! injection.combined))
|
Loading…
Add table
Reference in a new issue