diff options
29 files changed, 108 insertions, 112 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 25c13edfb..9c2f4e033 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -98,10 +98,11 @@ As languages differ quite a lot, here is a set of captures available to you when #### Identifiers ```query -@variable ; various variable names -@variable.builtin ; built-in variable names (e.g. `this`) -@variable.parameter ; parameters of a function -@variable.member ; object and struct fields +@variable ; various variable names +@variable.builtin ; built-in variable names (e.g. `this`) +@variable.parameter ; parameters of a function +@variable.parameter.builtin ; special parameters (e.g. `_`, `it`) +@variable.member ; object and struct fields @constant ; constant identifiers @constant.builtin ; built-in constant values @@ -111,6 +112,7 @@ As languages differ quite a lot, here is a set of captures available to you when @module.builtin ; built-in modules or namespaces @label ; GOTO and other labels (e.g. `label:` in C), including heredoc labels ``` + #### Literals ```query @@ -139,8 +141,9 @@ As languages differ quite a lot, here is a set of captures available to you when @type.definition ; identifiers in type definitions (e.g. `typedef <type> <identifier>` in C) @type.qualifier ; type qualifiers (e.g. `const`) -@attribute ; attribute annotations (e.g. Python decorators) -@property ; the key in key/value pairs +@attribute ; attribute annotations (e.g. Python decorators) +@attribute.builtin ; builtin annotations (e.g. `@property` in Python) +@property ; the key in key/value pairs ``` #### Functions @@ -167,6 +170,7 @@ As languages differ quite a lot, here is a set of captures available to you when @keyword.operator ; operators that are English words (e.g. `and` / `or`) @keyword.import ; keywords for including modules (e.g. `import` / `from` in Python) @keyword.storage ; modifiers that affect storage in memory or life-time +@keyword.type ; keywords describing composite types (e.g. `struct`, `enum`) @keyword.repeat ; keywords related to loops (e.g. `for` / `while`) @keyword.return ; keywords like `return` and `yield` @keyword.debug ; keywords related to debugging @@ -210,10 +214,15 @@ Mainly for markup languages. @markup.underline ; underlined text (only for literal underline markup!) @markup.heading ; headings, titles (including markers) +@markup.heading.1 ; top-level heading +@markup.heading.2 ; section heading +@markup.heading.3 ; subsection heading +@markup.heading.4 ; and so on +@markup.heading.5 ; and so forth +@markup.heading.6 ; six levels ought to be enough for anybody @markup.quote ; block quotes @markup.math ; math environments (e.g. `$ ... $` in LaTeX) -@markup.environment ; environments (e.g. in LaTeX) @markup.link ; text references, footnotes, citations, etc. @markup.link.label ; link, reference descriptions @@ -236,6 +245,7 @@ Mainly for markup languages. ```query @tag ; XML-style tag names (and similar) +@tag.builtin ; builtin tag names (e.g. HTML5 tags) @tag.attribute ; XML-style tag attributes @tag.delimiter ; XML-style tag delimiters ``` diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm index 786391e32..b021e8b37 100644 --- a/queries/cpp/highlights.scm +++ b/queries/cpp/highlights.scm @@ -220,12 +220,11 @@ "constexpr" ] @keyword -"co_await" @keyword.coroutine - [ + "co_await" "co_yield" "co_return" -] @keyword.coroutine.return +] @keyword.coroutine [ "public" diff --git a/queries/cue/locals.scm b/queries/cue/locals.scm index 9c5a7378e..b2a8972f7 100644 --- a/queries/cue/locals.scm +++ b/queries/cue/locals.scm @@ -19,13 +19,13 @@ (package_identifier) @local.definition.namespace (for_clause - (identifier) @local.definition.variable + (identifier) @local.definition.var (expression)) (for_clause (identifier) - (identifier) @local.definition.variable + (identifier) @local.definition.var (expression)) (let_clause - (identifier) @local.definition.variable) + (identifier) @local.definition.var) diff --git a/queries/ebnf/highlights.scm b/queries/ebnf/highlights.scm index 8715091b1..4254d04dd 100644 --- a/queries/ebnf/highlights.scm +++ b/queries/ebnf/highlights.scm @@ -1,7 +1,7 @@ ; Simple tokens ;;;; -(terminal) @string.grammar +(terminal) @string -(special_sequence) @string.special.grammar +(special_sequence) @string.special (integer) @number diff --git a/queries/firrtl/highlights.scm b/queries/firrtl/highlights.scm index 8e078fad2..14f12b169 100644 --- a/queries/firrtl/highlights.scm +++ b/queries/firrtl/highlights.scm @@ -87,7 +87,7 @@ "reader" "writer" "readwriter" -] @variable.member.builtin +] @variable.member ((field_id) @variable.member (#set! "priority" 105)) diff --git a/queries/fsh/highlights.scm b/queries/fsh/highlights.scm index 3404fa7c6..2354a2037 100644 --- a/queries/fsh/highlights.scm +++ b/queries/fsh/highlights.scm @@ -86,7 +86,7 @@ ; Constants (strength_value) @constant -(bool) @constant.boolean +(bool) @boolean (flag) @constant diff --git a/queries/hare/locals.scm b/queries/hare/locals.scm index b81ee5135..12a214bf7 100644 --- a/queries/hare/locals.scm +++ b/queries/hare/locals.scm @@ -61,5 +61,5 @@ (let_declaration "let" . - (identifier) @local.definition.variable + (identifier) @local.definition.var ","?) diff --git a/queries/hoon/highlights.scm b/queries/hoon/highlights.scm index 767b0dd22..d98ee44e0 100644 --- a/queries/hoon/highlights.scm +++ b/queries/hoon/highlights.scm @@ -28,7 +28,7 @@ (mold) @string.special.symbol -(specialIndex) @number.builtin +(specialIndex) @number (lark) @operator diff --git a/queries/jsonnet/highlights.scm b/queries/jsonnet/highlights.scm index acd838cbe..85670a25c 100644 --- a/queries/jsonnet/highlights.scm +++ b/queries/jsonnet/highlights.scm @@ -118,7 +118,7 @@ identifier: (id) @variable.parameter) (bind - (id) @variable.local) + (id) @variable) (bind function: (id) @function) diff --git a/queries/latex/highlights.scm b/queries/latex/highlights.scm index 5b5f19768..819a2ff94 100644 --- a/queries/latex/highlights.scm +++ b/queries/latex/highlights.scm @@ -41,16 +41,16 @@ ; General environments (begin - command: _ @markup.environment + command: _ @module name: (curly_group_text - (text) @markup.environment.name)) + (text) @label)) (end - command: _ @markup.environment + command: _ @module name: (curly_group_text - (text) @markup.environment.name)) + (text) @label)) ; Definitions and references (new_command_definition @@ -77,7 +77,7 @@ command: _ @function.macro name: (curly_group_text - (_) @markup.environment.name)) + (_) @label)) (paired_delimiter_definition command: _ @function.macro @@ -260,8 +260,8 @@ (begin name: (curly_group_text - (text) @markup.environment.name) - (#any-of? @markup.environment.name "frame")) + (text) @label) + (#any-of? @label "frame")) . (curly_group (_) @markup.heading)) diff --git a/queries/linkerscript/highlights.scm b/queries/linkerscript/highlights.scm index 23a483745..12330169e 100644 --- a/queries/linkerscript/highlights.scm +++ b/queries/linkerscript/highlights.scm @@ -63,7 +63,7 @@ "LENGTH" "len" "l" -] @variable.member.builtin +] @variable.member ; Constants ((symbol) @constant diff --git a/queries/markdown/highlights.scm b/queries/markdown/highlights.scm index e4d375b54..5d77e7217 100644 --- a/queries/markdown/highlights.scm +++ b/queries/markdown/highlights.scm @@ -1,34 +1,34 @@ ;From MDeiml/tree-sitter-markdown & Helix (setext_heading (paragraph) @markup.heading.1 - (setext_h1_underline) @markup.heading.1.marker) + (setext_h1_underline) @markup.heading.1) (setext_heading (paragraph) @markup.heading.2 - (setext_h2_underline) @markup.heading.2.marker) + (setext_h2_underline) @markup.heading.2) (atx_heading - (atx_h1_marker) @markup.heading.1.marker + (atx_h1_marker) @markup.heading.1 (inline) @markup.heading.1) (atx_heading - (atx_h2_marker) @markup.heading.2.marker + (atx_h2_marker) @markup.heading.2 (inline) @markup.heading.2) (atx_heading - (atx_h3_marker) @markup.heading.3.marker + (atx_h3_marker) @markup.heading.3 (inline) @markup.heading.3) (atx_heading - (atx_h4_marker) @markup.heading.4.marker + (atx_h4_marker) @markup.heading.4 (inline) @markup.heading.4) (atx_heading - (atx_h5_marker) @markup.heading.5.marker + (atx_h5_marker) @markup.heading.5 (inline) @markup.heading.5) (atx_heading - (atx_h6_marker) @markup.heading.6.marker + (atx_h6_marker) @markup.heading.6 (inline) @markup.heading.6) (info_string) @label @@ -54,12 +54,12 @@ (#set! "priority" 90)) (fenced_code_block - (fenced_code_block_delimiter) @markup.raw.delimiter + (fenced_code_block_delimiter) @markup.raw.block (#set! conceal "")) (fenced_code_block (info_string - (language) @conceal + (language) @label (#set! conceal ""))) (link_destination) @markup.link.url diff --git a/queries/markdown_inline/highlights.scm b/queries/markdown_inline/highlights.scm index e9b41c31d..cae8acfb4 100644 --- a/queries/markdown_inline/highlights.scm +++ b/queries/markdown_inline/highlights.scm @@ -16,10 +16,10 @@ ] @string.escape ; Conceal codeblock and text style markers -((code_span_delimiter) @markup.raw.delimiter - (#set! conceal "")) - -((emphasis_delimiter) @conceal +([ + (code_span_delimiter) + (emphasis_delimiter) +] @conceal (#set! conceal "")) ; Conceal inline links diff --git a/queries/objc/highlights.scm b/queries/objc/highlights.scm index 7a83376c2..dd2c796bd 100644 --- a/queries/objc/highlights.scm +++ b/queries/objc/highlights.scm @@ -174,12 +174,12 @@ "__unsafe_unretained" "__unused" "__weak" - ]) @function.macro.builtin + ]) @function.macro [ "__real" "__imag" -] @function.macro.builtin +] @function.macro ((call_expression function: (identifier) @function.macro) diff --git a/queries/perl/highlights.scm b/queries/perl/highlights.scm index 1b0dc2dc1..fcd0f3071 100644 --- a/queries/perl/highlights.scm +++ b/queries/perl/highlights.scm @@ -65,7 +65,7 @@ (yadayada) @keyword.exception (phaser_statement - phase: _ @keyword.phaser) + phase: _ @keyword) [ "or" @@ -207,50 +207,50 @@ ; highlights punc vars and also numeric only like $11 (#lua-match? @variable.builtin "^%A+$")) -(scalar) @variable.scalar +(scalar) @variable (scalar_deref_expression [ "$" "*" - ] @variable.scalar) + ] @variable) [ (array) (arraylen) -] @variable.array +] @variable (array_deref_expression [ "@" "*" - ] @variable.array) + ] @variable) -(hash) @variable.hash +(hash) @variable (hash_deref_expression [ "%" "*" - ] @variable.hash) + ] @variable) (array_element_expression - array: (_) @variable.array) + array: (_) @variable) (slice_expression - array: (_) @variable.array) + array: (_) @variable) (keyval_expression - array: (_) @variable.array) + array: (_) @variable) (hash_element_expression - hash: (_) @variable.hash) + hash: (_) @variable) (slice_expression - hash: (_) @variable.hash) + hash: (_) @variable) (keyval_expression - hash: (_) @variable.hash) + hash: (_) @variable) (comment) @comment diff --git a/queries/rbs/highlights.scm b/queries/rbs/highlights.scm index 11dbf7c2c..340bc254e 100644 --- a/queries/rbs/highlights.scm +++ b/queries/rbs/highlights.scm @@ -80,7 +80,7 @@ (const_name (constant) @constant) -(global_name) @variable.global +(global_name) @variable ; Standard Arguments (parameter diff --git a/queries/rst/injections.scm b/queries/rst/injections.scm index 7ca479a65..da57daa65 100644 --- a/queries/rst/injections.scm +++ b/queries/rst/injections.scm @@ -41,15 +41,7 @@ (body (arguments) @injection.language (content) @injection.content)) - (#any-of? @_type "code" "code-block" "sourcecode")) - -((directive - name: (type) @_type - body: - (body - (arguments) @injection.language - (content) @injection.content)) - (#eq? @_type "raw")) + (#any-of? @_type "raw" "code" "code-block" "sourcecode")) ((directive name: (type) @_type @@ -59,7 +51,6 @@ (#set! injection.language "latex") (#eq? @_type "math")) -; TODO: re-add when a parser for csv is added. ((directive name: (type) @_type body: diff --git a/queries/ruby/highlights.scm b/queries/ruby/highlights.scm index 50e8c9093..5b5fcbf9f 100644 --- a/queries/ruby/highlights.scm +++ b/queries/ruby/highlights.scm @@ -1,7 +1,8 @@ ; Variables -(identifier) @variable - -(global_variable) @variable.global +[ + (identifier) + (global_variable) +] @variable ; Keywords [ diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index f5fff58d0..4639d8859 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -288,7 +288,7 @@ [ "'" (identifier) - ] @keyword.storage.lifetime) + ] @keyword.storage) "fn" @keyword.function diff --git a/queries/slint/locals.scm b/queries/slint/locals.scm index 2d256b7ac..7e895a6b5 100644 --- a/queries/slint/locals.scm +++ b/queries/slint/locals.scm @@ -16,7 +16,7 @@ (argument) @local.definition.var (callback - name: (_) @local.definition.member) + name: (_) @local.definition.field) (component_definition name: (_) @local.definition.type) diff --git a/queries/soql/highlights.scm b/queries/soql/highlights.scm index 5356b8a7f..721e84ed2 100644 --- a/queries/soql/highlights.scm +++ b/queries/soql/highlights.scm @@ -82,9 +82,10 @@ (string_literal) @string -(date) @variable.readonly - -(date_time) @variable.readonly +[ + (date) + (date_time) +] @string.special [ "TRUE" diff --git a/queries/squirrel/highlights.scm b/queries/squirrel/highlights.scm index da7bef337..28d072029 100644 --- a/queries/squirrel/highlights.scm +++ b/queries/squirrel/highlights.scm @@ -64,15 +64,16 @@ ] @type.qualifier ; Variables -(identifier) @variable +[ + (identifier) + (global_variable) +] @variable (local_declaration - (identifier) @variable.local + (identifier) @variable . "=") -(global_variable) @variable.global - ((identifier) @variable.builtin (#any-of? @variable.builtin "base" "this" "vargv")) diff --git a/queries/squirrel/locals.scm b/queries/squirrel/locals.scm index 3858eb6b0..e5fce7d57 100644 --- a/queries/squirrel/locals.scm +++ b/queries/squirrel/locals.scm @@ -67,9 +67,9 @@ (var_statement "var" . - (identifier) @local.definition.variable) + (identifier) @local.definition.var) (local_declaration - (identifier) @local.definition.variable + (identifier) @local.definition.var . "=") diff --git a/queries/strace/highlights.scm b/queries/strace/highlights.scm index 62fa724bd..70a14fd2d 100644 --- a/queries/strace/highlights.scm +++ b/queries/strace/highlights.scm @@ -16,9 +16,10 @@ (syscall) @function.builtin ; Literals -(integer) @number - -(pointer) @number.special +[ + (integer) + (pointer) +] @number (value) @label diff --git a/queries/ungrammar/locals.scm b/queries/ungrammar/locals.scm index 389d5c262..0f745bd14 100644 --- a/queries/ungrammar/locals.scm +++ b/queries/ungrammar/locals.scm @@ -1,7 +1,8 @@ (grammar) @local.scope -(definition) @local.definition - -(label_name) @local.definition.label +[ + (definition) + (label_name) +] @local.definition (identifier) @local.reference diff --git a/queries/vimdoc/highlights.scm b/queries/vimdoc/highlights.scm index 294fa94f1..21b2b98c6 100644 --- a/queries/vimdoc/highlights.scm +++ b/queries/vimdoc/highlights.scm @@ -7,11 +7,11 @@ (column_heading) @markup.heading.4 (column_heading - "~" @markup.heading.4.marker + "~" @markup.heading.4 (#set! conceal "")) (tag - "*" @markup.heading.5.marker + "*" @label (#set! conceal "") text: (_) @label) @@ -24,7 +24,7 @@ text: (_) @markup.link) (codespan - "`" @markup.raw.delimiter + "`" @markup.raw (#set! conceal "") text: (_) @markup.raw) @@ -32,14 +32,15 @@ (#set! "priority" 90)) (codeblock - [ - ">" - (language) - ] @markup.raw.delimiter + ">" @markup.raw + (#set! conceal "")) + +(codeblock + (language) @label (#set! conceal "")) (block - "<" @markup.raw.delimiter + "<" @markup.raw (#set! conceal "")) (argument) @variable.parameter diff --git a/queries/xml/highlights.scm b/queries/xml/highlights.scm index 4585d2ae3..464207990 100644 --- a/queries/xml/highlights.scm +++ b/queries/xml/highlights.scm @@ -51,9 +51,9 @@ (CharData) @none @spell ((CDSect - (CDStart) @markup.environment + (CDStart) @module (CData) @markup.raw - "]]>" @markup.environment) + "]]>" @module) (#set! "priority" 105)) ; Delimiters & punctuation diff --git a/scripts/check-queries.lua b/scripts/check-queries.lua index 5e83bdcad..f3b45ea1a 100755 --- a/scripts/check-queries.lua +++ b/scripts/check-queries.lua @@ -1,4 +1,5 @@ #!/usr/bin/env -S nvim -l +vim.opt.rtp:prepend "./" -- Equivalent to print(), but this will ensure consistent output regardless of -- operating system. @@ -35,15 +36,6 @@ local function extract_captures() return captures end -local function list_any(list, predicate) - for _, v in pairs(list) do - if predicate(v) then - return true - end - end - return false -end - local function do_check() local timings = {} local queries = require "nvim-treesitter.query" @@ -72,9 +64,7 @@ local function do_check() for _, capture in ipairs(query.captures) do local is_valid = ( vim.startswith(capture, "_") -- Helpers. - or list_any(captures[query_type], function(documented_capture) - return vim.startswith(capture, documented_capture) - end) + or vim.tbl_contains(captures[query_type], capture) ) if not is_valid then local error = string.format("(x) Invalid capture @%s in %s for %s.", capture, query_type, lang) diff --git a/tests/query/highlights/markdown/test.md b/tests/query/highlights/markdown/test.md index 87b28520e..01acfcc19 100644 --- a/tests/query/highlights/markdown/test.md +++ b/tests/query/highlights/markdown/test.md @@ -1,8 +1,8 @@ # H1 -<!-- <- @markup.heading.1.marker --> +<!-- <- @markup.heading.1 --> ## H2 -<!-- <- @markup.heading.2.marker --> +<!-- <- @markup.heading.2 --> - Item 1 - Item 2 |
