Skip to content

Commit

Permalink
Add tree-sitter-comment (#1300)
Browse files Browse the repository at this point in the history
* Add tree-sitter-comment

Fix #1164

* fix precedence in tree-sitter-comment highlights

connects #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 <[email protected]>
  • Loading branch information
the-mikedavis and pickfire authored Dec 19, 2021
1 parent 7c01d92 commit e72786d
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 10 deletions.
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"))

0 comments on commit e72786d

Please sign in to comment.