diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1faa8af..5604999 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 @@ -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/ diff --git a/.tsqueryrc.json b/.tsqueryrc.json new file mode 100644 index 0000000..3619c9b --- /dev/null +++ b/.tsqueryrc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/ribru17/ts_query_ls/refs/heads/master/schemas/config.json", + "parser_install_directories": ["."] +} diff --git a/queries/query/highlights.scm b/queries/query/highlights.scm index d909df1..cbd192a 100644 --- a/queries/query/highlights.scm +++ b/queries/query/highlights.scm @@ -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 @@ -36,14 +36,22 @@ ")" ] @punctuation.bracket -":" @punctuation.delimiter +[ + ":" + "/" +] @punctuation.delimiter [ "@" "#" ] @punctuation.special -"_" @constant +(predicate + "." @punctuation.special) + +"_" @character.special + +"MISSING" @keyword ((parameters (identifier) @number) @@ -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")) diff --git a/queries/query/injections.scm b/queries/query/injections.scm index dd1a855..759f9b2 100644 --- a/queries/query/injections.scm +++ b/queries/query/injections.scm @@ -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")) diff --git a/src/parser.c b/src/parser.c index 151fe55..45bce09 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,4 +1,4 @@ -/* Automatically @generated by tree-sitter v0.25.8 */ +/* Automatically @generated by tree-sitter v0.25.9 */ #include "tree_sitter/parser.h" diff --git a/test/highlight/statements.scm b/test/highlight/statements.scm index fd3239a..a6851b3 100644 --- a/test/highlight/statements.scm +++ b/test/highlight/statements.scm @@ -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