Skip to content
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
23 changes: 22 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Set up repository
uses: actions/checkout@v4
Expand All @@ -43,3 +43,24 @@ jobs:
uses: tree-sitter/parse-action@v4
with:
files: .tests/nvim-treesitter/runtime/queries/*/*.scm

query:
name: Validate queries
runs-on: ubuntu-latest
steps:
- name: Set up repository
uses: actions/checkout@v4

- name: Set up tree-sitter
uses: tree-sitter/setup-action@v2
with:
install-lib: false

- name: Build parser
run: tree-sitter build

- name: Set up ts_query_ls
run: curl -fL https://github.com/ribru17/ts_query_ls/releases/latest/download/ts_query_ls-x86_64-unknown-linux-gnu.tar.gz | tar -xz

- name: Check queries
run: ./ts_query_ls check -f queries/
4 changes: 4 additions & 0 deletions .tsqueryrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/ribru17/ts_query_ls/refs/heads/master/schemas/config.json",
"parser_install_directories": ["."]
}
57 changes: 36 additions & 21 deletions queries/query/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
(capture
(identifier) @type)

(anonymous_node
(string) @string)

(predicate
name: (identifier) @function.call)

(named_node
name: (identifier) @variable)

(missing_node
name: (identifier) @variable)

(field_definition
name: (identifier) @property)
name: (identifier) @variable.member)

(negated_field
"!" @operator
Expand All @@ -36,14 +36,22 @@
")"
] @punctuation.bracket

":" @punctuation.delimiter
[
":"
"/"
] @punctuation.delimiter

[
"@"
"#"
] @punctuation.special

"_" @constant
(predicate
"." @punctuation.special)

"_" @character.special

"MISSING" @keyword

((parameters
(identifier) @number)
Expand All @@ -53,35 +61,42 @@
.
(comment)*
.
(comment) @keyword.import)
(comment) @keyword.import @nospell)
(#lua-match? @keyword.import "^;+ *inherits *:"))

((program
.
(comment)*
.
(comment) @keyword.directive)
(comment) @keyword.directive @nospell)
(#lua-match? @keyword.directive "^;+ *extends *$"))

((comment) @keyword.directive
((comment) @keyword.directive @nospell
(#lua-match? @keyword.directive "^;+%s*format%-ignore%s*$"))

((predicate
name: (identifier) @_name
parameters:
(parameters
(string
"\"" @string
"\"" @string) @string.regexp))
parameters: (parameters
.
(capture)?
.
(identifier) @property))
(#eq? @_name "set"))

((predicate
name: (identifier) @_name
parameters: (parameters
(string
"\"" @string
"\"" @string) @string.regexp))
(#any-of? @_name "match" "not-match" "vim-match" "not-vim-match" "lua-match" "not-lua-match"))

((predicate
name: (identifier) @_name
parameters:
(parameters
(string
"\"" @string
"\"" @string) @string.regexp
.
(string) .))
parameters: (parameters
(string
"\"" @string
"\"" @string) @string.regexp
.
(string) .))
(#any-of? @_name "gsub" "not-gsub"))
35 changes: 16 additions & 19 deletions queries/query/injections.scm
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
((predicate
name: (identifier) @_name
parameters:
(parameters
(string) @injection.content))
(#any-of? @_name "match" "not-match" "vim-match" "not-vim-match")
(#set! injection.language "regex")
(#offset! @injection.content 0 1 0 -1))
parameters: (parameters
(string
(string_content) @injection.content)))
(#any-of? @_name "match" "not-match" "any-match" "vim-match" "not-vim-match" "any-vim-match")
(#set! injection.language "regex"))

((predicate
name: (identifier) @_name
parameters:
(parameters
(string) @injection.content))
(#any-of? @_name "lua-match" "not-lua-match")
(#set! injection.language "luap")
(#offset! @injection.content 0 1 0 -1))
parameters: (parameters
(string
(string_content) @injection.content)))
(#any-of? @_name "lua-match" "not-lua-match" "any-lua-match")
(#set! injection.language "luap"))

((predicate
name: (identifier) @_name
parameters:
(parameters
(string) @injection.content
.
(string) .))
parameters: (parameters
(string
(string_content) @injection.content)
.
(string) .))
(#any-of? @_name "gsub" "not-gsub")
(#set! injection.language "luap")
(#offset! @injection.content 0 1 0 -1))
(#set! injection.language "luap"))

((comment) @injection.content
(#set! injection.language "comment"))
2 changes: 1 addition & 1 deletion src/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions test/highlight/statements.scm
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
; ^ @type

name: (identifier)
; <- @property
; <- @variable.member
; ^ @punctuation.delimiter

(program
name: (_))
; ^ @constant
; ^ @character.special

(program
name: _)
; ^ @constant
; ^ @character.special

(program
field: (identifier) @capture
Expand Down
Loading