on master help sign in
Add tree-sitter-comment (#1300)

* Add tree-sitter-comment Fix #1164 * fix precedence in tree-sitter-comment highlights connects https://github.com/helix-editor/helix/pull/1170 * set injection-regex for comment language * remove comment filetype * fix comment injections for neovim-style injections tags * add comment injections for elixir * remove f.comment * fix spacing in .gitmodules * run 'cargo xtask docgen' Co-authored-by: Ivan Tham <pickfire@riseup.net>

commite72786df8eae5684c0330be18f190a33f516da76 authorMichael Davis <mcarsondavis@gmail.com> dateSun 19 Dec 2021, 08:56 (5 years ago) parent7c01d92
13 files changed+66−10
.gitmodules+4 book/src/generated/lang-support.md+1 helix-syntax/languages/tree-sitter-comment+1 languages.toml+8−1 runtime/queries/comment/highlights.scm+30 runtime/queries/elixir/injections.scm+2 runtime/queries/glsl/injections.scm+4−2 runtime/queries/julia/injections.scm+5−3 runtime/queries/ledger/injections.scm+2−2 runtime/queries/python/injections.scm+2 runtime/queries/rust/injections.scm+3 runtime/queries/svelte/injections.scm+2−2 runtime/queries/tsq/injections.scm+2
.gitmodules+4
@@ -142,6 +142,10 @@
142142 path = helix-syntax/languages/tree-sitter-perl
143143 url = https://github.com/ganezdragon/tree-sitter-perl
144144 shallow = true
145+[submodule "helix-syntax/languages/tree-sitter-comment"]
146+ path = helix-syntax/languages/tree-sitter-comment
147+ url = https://github.com/stsewd/tree-sitter-comment
148+ shallow = true
145149[submodule "helix-syntax/languages/tree-sitter-wgsl"]
146150 path = helix-syntax/languages/tree-sitter-wgsl
147151 url = https://github.com/szebniok/tree-sitter-wgsl
book/src/generated/lang-support.md+1
@@ -4,6 +4,7 @@
44| c | ✓ | | | `clangd` |
55| c-sharp | ✓ | | | |
66| cmake | ✓ | | | `cmake-language-server` |
7+| comment | ✓ | | | |
78| cpp | ✓ | | | `clangd` |
89| css | ✓ | | | |
910| dart | ✓ | | ✓ | `dart` |
helix-syntax/languages/tree-sitter-commentnew file+1

Submodule changed.

languages.toml+8−1
@@ -406,6 +406,13 @@ shebangs = ["racket"]
406406comment-token = ";"
407407language-server = { command = "racket", args = ["-l", "racket-langserver"] }
408408
409+[[language]]
410+name = "comment"
411+scope = "scope.comment"
412+roots = []
413+file-types = []
414+injection-regex = "comment"
415+
409416[[language]]
410417name = "wgsl"
411418scope = "source.wgsl"
@@ -448,4 +455,4 @@ roots = ["build.sbt"]
448455file-types = ["scala", "sbt"]
449456comment-token = "//"
450457indent = { tab-width = 2, unit = " " }
451−language-server = { command = "metals" }
458+language-server = { command = "metals" }
runtime/queries/comment/highlights.scmnew file+30
@@ -0,0 +1,30 @@
1+[
2+ "("
3+ ")"
4+] @punctuation.bracket
5+
6+":" @punctuation.delimiter
7+
8+((tag (name) @warning)
9+ (#match? @warning "^(TODO|HACK|WARNING)$"))
10+
11+("text" @warning
12+ (#match? @warning "^(TODO|HACK|WARNING)$"))
13+
14+((tag (name) @error)
15+ (match? @error "^(FIXME|XXX|BUG)$"))
16+
17+("text" @error
18+ (match? @error "^(FIXME|XXX|BUG)$"))
19+
20+(tag
21+ (name) @ui.text
22+ (user)? @constant)
23+
24+; Issue number (#123)
25+("text" @constant.numeric
26+ (#match? @constant.numeric "^#[0-9]+$"))
27+
28+; User mention (@user)
29+("text" @tag
30+ (#match? @tag "^[@][a-zA-Z0-9_-]+$"))
runtime/queries/elixir/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/glsl/injections.scm+4−2
@@ -1,3 +1,5 @@
1−(preproc_arg) @glsl
1+((preproc_arg) @injection.content
2+ (#set! injection.language "glsl"))
23
3−(comment) @comment
4+((comment) @injection.content
5+ (#set! injection.language "comment"))
runtime/queries/julia/injections.scm+5−3
@@ -1,5 +1,7 @@
11; TODO: re-add when markdown is added.
2−; ((triple_string) @markdown
3−; (#offset! @markdown 0 3 0 -3))
2+; ((triple_string) @injection.content
3+; (#offset! @injection.content 0 3 0 -3)
4+; (#set! injection.language "markdown"))
45
5−(comment) @comment
6+((comment) @injection.content
7+ (#set! injection.language "comment"))
runtime/queries/ledger/injections.scm+2−2
@@ -1,2 +1,2 @@
1−(comment) @comment
2−(note) @comment
1+([(comment) (note)] @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/python/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/rust/injections.scm+3
@@ -1,3 +1,6 @@
1+([(line_comment) (block_comment)] @injection.content
2+ (#set! injection.language "comment"))
3+
14((macro_invocation
25 (token_tree) @injection.content)
36 (#set! injection.language "rust")
runtime/queries/svelte/injections.scm+2−2
@@ -26,5 +26,5 @@
2626 (#set! injection.language "typescript")
2727)
2828
29−(comment) @comment
30−
29+((comment) @injection.content
30+ (#set! injection.language "comment"))
runtime/queries/tsq/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))