Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tree-sitter-comment #1300

Merged
merged 11 commits into from
Dec 19, 2021
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
path = helix-syntax/languages/tree-sitter-perl
url = https://github.com/ganezdragon/tree-sitter-perl
shallow = true
[submodule "helix-syntax/languages/tree-sitter-comment"]
path = helix-syntax/languages/tree-sitter-comment
url = https://github.com/stsewd/tree-sitter-comment
shallow = true
[submodule "helix-syntax/languages/tree-sitter-wgsl"]
path = helix-syntax/languages/tree-sitter-wgsl
url = https://github.com/szebniok/tree-sitter-wgsl
Expand Down
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
| c | ✓ | | | `clangd` |
| c-sharp | ✓ | | | |
| cmake | ✓ | | | `cmake-language-server` |
| comment | ✓ | | | |
| cpp | ✓ | | | `clangd` |
| css | ✓ | | | |
| dart | ✓ | | ✓ | `dart` |
Expand Down
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-comment
Submodule tree-sitter-comment added at 5dd3c6
9 changes: 8 additions & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ shebangs = ["racket"]
comment-token = ";"
language-server = { command = "racket", args = ["-l", "racket-langserver"] }

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

[[language]]
name = "wgsl"
scope = "source.wgsl"
Expand Down Expand Up @@ -448,4 +455,4 @@ roots = ["build.sbt"]
file-types = ["scala", "sbt"]
comment-token = "//"
indent = { tab-width = 2, unit = " " }
language-server = { command = "metals" }
language-server = { command = "metals" }
30 changes: 30 additions & 0 deletions runtime/queries/comment/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
"("
")"
] @punctuation.bracket

":" @punctuation.delimiter

((tag (name) @warning)
(#match? @warning "^(TODO|HACK|WARNING)$"))

("text" @warning
(#match? @warning "^(TODO|HACK|WARNING)$"))

((tag (name) @error)
(match? @error "^(FIXME|XXX|BUG)$"))

("text" @error
(match? @error "^(FIXME|XXX|BUG)$"))

(tag
(name) @ui.text
(user)? @constant)

; Issue number (#123)
("text" @constant.numeric
(#match? @constant.numeric "^#[0-9]+$"))

; User mention (@user)
("text" @tag
(#match? @tag "^[@][a-zA-Z0-9_-]+$"))
2 changes: 2 additions & 0 deletions runtime/queries/elixir/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))
6 changes: 4 additions & 2 deletions runtime/queries/glsl/injections.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(preproc_arg) @glsl
((preproc_arg) @injection.content
(#set! injection.language "glsl"))

(comment) @comment
((comment) @injection.content
(#set! injection.language "comment"))
8 changes: 5 additions & 3 deletions runtime/queries/julia/injections.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
; TODO: re-add when markdown is added.
; ((triple_string) @markdown
; (#offset! @markdown 0 3 0 -3))
; ((triple_string) @injection.content
; (#offset! @injection.content 0 3 0 -3)
; (#set! injection.language "markdown"))

(comment) @comment
((comment) @injection.content
(#set! injection.language "comment"))
4 changes: 2 additions & 2 deletions runtime/queries/ledger/injections.scm
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(comment) @comment
(note) @comment
([(comment) (note)] @injection.content
(#set! injection.language "comment"))
2 changes: 2 additions & 0 deletions runtime/queries/python/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))
3 changes: 3 additions & 0 deletions runtime/queries/rust/injections.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
([(line_comment) (block_comment)] @injection.content
(#set! injection.language "comment"))

((macro_invocation
(token_tree) @injection.content)
(#set! injection.language "rust")
Expand Down
4 changes: 2 additions & 2 deletions runtime/queries/svelte/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
(#set! injection.language "typescript")
)

(comment) @comment

((comment) @injection.content
(#set! injection.language "comment"))
2 changes: 2 additions & 0 deletions runtime/queries/tsq/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))