Skip to content

Commit

Permalink
Add highlight support for tree-sitter-query language (tsq) (helix-edi…
Browse files Browse the repository at this point in the history
…tor#845)

* add submodule on tree-sitter/tree-sitter-tsq

mark tsq submodule as shallow

* add tree-sitter-tsq to languages

* add highlight queries for tsq

* Update .gitmodules

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
  • Loading branch information
the-mikedavis and archseer authored Oct 16, 2021
1 parent 4346592 commit e069fb9
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,7 @@
path = helix-syntax/languages/tree-sitter-vue
url = https://github.com/ikatyang/tree-sitter-vue
shallow = true
[submodule "helix-syntax/languages/tree-sitter-tsq"]
path = helix-syntax/languages/tree-sitter-tsq
url = https://github.com/tree-sitter/tree-sitter-tsq
shallow = true
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-tsq
Submodule tree-sitter-tsq added at b66565
8 changes: 8 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,11 @@ language-server = { command = "swipl", args = [
"-g", "use_module(library(lsp_server))",
"-g", "lsp_server:main",
"-t", "halt", "--", "stdio"] }

[[language]]
name = "tsq"
scope = "source.tsq"
file-types = ["scm"]
roots = []
comment-token = ";"
indent = { tab-width = 2, unit = " " }
46 changes: 46 additions & 0 deletions runtime/queries/tsq/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
; mark the string passed #match? as a regex
(((predicate_name) @function
(capture)
(string) @string.regexp)
(#eq? @function "#match?"))

; highlight inheritance comments
((query . (comment) @keyword.directive)
(#match? @keyword.directive "^;\ +inherits *:"))

[
"("
")"
"["
"]"
] @punctuation.bracket

":" @punctuation.delimiter

[
(one_or_more)
(zero_or_one)
(zero_or_more)
] @operator

[
(wildcard_node)
(anchor)
] @constant.builtin

[
(anonymous_leaf)
(string)
] @string

(comment) @comment

(field_name) @property

(capture) @label

(predicate_name) @function

(escape_sequence) @escape

(node_name) @variable

0 comments on commit e069fb9

Please sign in to comment.