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 highlight support for tree-sitter-query language (tsq) #845

Merged
merged 4 commits into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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