diff options
Diffstat (limited to 'queries')
| -rw-r--r-- | queries/awk/highlights.scm | 154 | ||||
| -rw-r--r-- | queries/awk/injections.scm | 2 | ||||
| -rw-r--r-- | queries/help/highlights.scm | 13 | ||||
| -rw-r--r-- | queries/julia/folds.scm | 2 | ||||
| -rw-r--r-- | queries/julia/highlights.scm | 232 | ||||
| -rw-r--r-- | queries/julia/indents.scm | 2 | ||||
| -rw-r--r-- | queries/julia/locals.scm | 84 | ||||
| -rw-r--r-- | queries/lua/highlights.scm | 5 | ||||
| -rw-r--r-- | queries/markdown/highlights.scm | 9 | ||||
| -rw-r--r-- | queries/ql/folds.scm | 7 | ||||
| -rw-r--r-- | queries/rego/highlights.scm | 70 | ||||
| -rw-r--r-- | queries/rust/folds.scm | 1 | ||||
| -rw-r--r-- | queries/rust/highlights.scm | 45 | ||||
| -rw-r--r-- | queries/rust/locals.scm | 3 | ||||
| -rw-r--r-- | queries/scheme/highlights.scm | 2 | ||||
| -rw-r--r-- | queries/vhs/highlights.scm | 38 |
16 files changed, 501 insertions, 168 deletions
diff --git a/queries/awk/highlights.scm b/queries/awk/highlights.scm new file mode 100644 index 00000000..918d0116 --- /dev/null +++ b/queries/awk/highlights.scm @@ -0,0 +1,154 @@ +; adapted from https://github.com/Beaglefoot/tree-sitter-awk + +[ + (identifier) + (field_ref) +] @variable +(field_ref (_) @variable) + +(number) @number + +(string) @string +(regex) @string.regex +(escape_sequence) @string.escape + +(comment) @comment @spell + +(ns_qualified_name (namespace) @namespace) +(ns_qualified_name "::" @punctuation.delimiter) + +(func_def name: (_ (identifier) @function) @function) +(func_call name: (_ (identifier) @function) @function) + +(func_def (param_list (identifier) @parameter)) + +[ + "print" + "printf" + "getline" +] @function.builtin + +[ + (delete_statement) + (break_statement) + (continue_statement) + (next_statement) + (nextfile_statement) +] @keyword + +[ + "func" + "function" +] @keyword.function + +[ + "return" + "exit" +] @keyword.return + +[ + "do" + "while" + "for" + "in" +] @repeat + +[ + "if" + "else" + "switch" + "case" + "default" +] @conditional + +[ + "@include" + "@load" +] @include + +"@namespace" @preproc + +[ + "BEGIN" + "END" + "BEGINFILE" + "ENDFILE" +] @label + +(binary_exp [ + "^" + "**" + "*" + "/" + "%" + "+" + "-" + "<" + ">" + "<=" + ">=" + "==" + "!=" + "~" + "!~" + "in" + "&&" + "||" +] @operator) + +(unary_exp [ + "!" + "+" + "-" +] @operator) + +(assignment_exp [ + "=" + "+=" + "-=" + "*=" + "/=" + "%=" + "^=" +] @operator) + +(ternary_exp [ + "?" + ":" +] @operator) + +(update_exp [ + "++" + "--" +] @operator) + +(redirected_io_statement [ + ">" + ">>" +] @operator) + +(piped_io_statement [ + "|" + "|&" +] @operator) + +(piped_io_exp [ + "|" + "|&" +] @operator) + +(field_ref "$" @punctuation.delimiter) + +(regex "/" @punctuation.delimiter) +(regex_constant "@" @punctuation.delimiter) + +[ ";" "," ] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/queries/awk/injections.scm b/queries/awk/injections.scm new file mode 100644 index 00000000..8cbffc62 --- /dev/null +++ b/queries/awk/injections.scm @@ -0,0 +1,2 @@ +(comment) @comment +(regex) @regex diff --git a/queries/help/highlights.scm b/queries/help/highlights.scm index 6be4e49c..b2ed3903 100644 --- a/queries/help/highlights.scm +++ b/queries/help/highlights.scm @@ -2,6 +2,8 @@ (h2) @text.title (h3) @text.title (column_heading) @text.title +(column_heading + "~" @conceal (#set! conceal "")) (tag "*" @conceal (#set! conceal "") text: (_) @label) @@ -9,8 +11,15 @@ "|" @conceal (#set! conceal "") text: (_) @text.reference) (optionlink - text: (_) @text.literal) + text: (_) @text.reference) (codespan "`" @conceal (#set! conceal "") - text: (_) @string) + text: (_) @text.literal) +(codeblock) @text.literal +(codeblock + ">" @conceal (#set! conceal "")) +(block + "<" @conceal (#set! conceal "")) (argument) @parameter +(keycode) @string.special +(url) @text.uri diff --git a/queries/julia/folds.scm b/queries/julia/folds.scm index a8cfc940..61718215 100644 --- a/queries/julia/folds.scm +++ b/queries/julia/folds.scm @@ -12,6 +12,6 @@ (quote_statement) (do_clause) - (compound_expression) + (compound_statement) ] @fold diff --git a/queries/julia/highlights.scm b/queries/julia/highlights.scm index 1b7e5b72..8d30ff55 100644 --- a/queries/julia/highlights.scm +++ b/queries/julia/highlights.scm @@ -1,106 +1,110 @@ -(identifier) @variable +;;; Identifiers -(operator) @operator -(range_expression ":" @operator) -(pair_expression "=>" @operator) +(identifier) @variable -;; In case you want type highlighting based on Julia naming conventions (this might collide with mathematical notation) -;((identifier) @type ; exception: mark `A_foo` sort of identifiers as variables - ;(match? @type "^[A-Z][^_]")) +; ;; If you want type highlighting based on Julia naming conventions (this might collide with mathematical notation) +; ((identifier) @type +; (match? @type "^[A-Z][^_]")) ; exception: Highlight `A_foo` sort of identifiers as variables (macro_identifier) @function.macro -(macro_identifier (identifier) @function.macro) ; for any one using the variable highlight +(macro_identifier + (identifier) @function.macro) ; for any one using the variable highlight + (macro_definition - name: (identifier) @function.macro - ["macro" "end" @keyword]) + name: (identifier) @function.macro) + +(quote_expression ":" (identifier)) @symbol + + +;;; Fields and indexes (field_expression - (identifier) (identifier) @field .) +(index_expression + (_) + (range_expression + (identifier) @constant.builtin .) + (#eq? @constant.builtin "end")) + + +;;; Function names + +;; definitions + (function_definition name: (identifier) @function) +(short_function_definition + name: (identifier) @function) + +(function_definition + name: (scoped_identifier (identifier) @function .)) +(short_function_definition + name: (scoped_identifier (identifier) @function .)) + +;; calls + (call_expression (identifier) @function.call) (call_expression - (field_expression (identifier) @method.call .)) + (field_expression (identifier) @function.call .)) + (broadcast_call_expression (identifier) @function.call) (broadcast_call_expression - (field_expression (identifier) @method.call .)) + (field_expression (identifier) @function.call .)) + + +;;; Parameters + (parameter_list (identifier) @parameter) -(parameter_list - (optional_parameter . - (identifier) @parameter)) +(optional_parameter . + (identifier) @parameter) +(slurp_parameter + (identifier) @parameter) + (typed_parameter - (identifier) @parameter - (identifier) @type) -(type_parameter_list - (identifier) @type) + parameter: (identifier) @parameter + type: (_) @type) (typed_parameter - (identifier) @parameter - (parameterized_identifier) @type) + type: (_) @type) + (function_expression - . (identifier) @parameter) -(spread_parameter) @parameter -(spread_parameter - (identifier) @parameter) -(named_argument - . (identifier) @parameter) -(argument_list - (typed_expression - (identifier) @parameter - (identifier) @type)) -(argument_list - (typed_expression - (identifier) @parameter - (parameterized_identifier) @type)) - -;; Symbol expressions (:my-wanna-be-lisp-keyword) -(quote_expression - (identifier)) @symbol - -;; Parsing error! foo (::Type) gets parsed as two quote expressions -(argument_list - (quote_expression - (quote_expression - (identifier) @type))) - -(type_argument_list - (identifier) @type) -(parameterized_identifier (_)) @type -(argument_list - (typed_expression . (identifier) @parameter)) + . (identifier) @parameter) ; Single parameter arrow functions -(typed_expression - (identifier) @type .) -(typed_expression - (parameterized_identifier) @type .) + +;;; Types + +;; Definitions (abstract_definition name: (identifier) @type) +(primitive_definition + name: (identifier) @type) (struct_definition name: (identifier) @type) -(subscript_expression - (_) - (range_expression - (identifier) @constant.builtin .) - (#eq? @constant.builtin "end")) +;; Annotations -"end" @keyword +(parametrized_type_expression (_) @type) -(if_statement - ["if" "end"] @conditional) -(elseif_clause - ["elseif"] @conditional) -(else_clause - ["else"] @conditional) -(ternary_expression - ["?" ":"] @conditional) +(type_parameter_list + (identifier) @type) + +(typed_expression + (identifier) @type .) + +(function_definition + return_type: (identifier) @type) +(short_function_definition + return_type: (identifier) @type) + +(where_clause + (identifier) @type) ; where clause without braces -(function_definition ["function" "end"] @keyword.function) + +;;; Keywords [ "abstract" @@ -110,51 +114,91 @@ "struct" "type" "mutable" + "where" ] @keyword -"return" @keyword.return +"end" @keyword -((identifier) @keyword (#any-of? @keyword "global" "local")) +((identifier) @keyword (#any-of? @keyword "global" "local")) ; Grammar error -(compound_expression +(compound_statement ["begin" "end"] @keyword) +(quote_statement + ["quote" "end"] @keyword) +(let_statement + ["let" "end"] @keyword) + +(if_statement + ["if" "end"] @conditional) +(elseif_clause + ["elseif"] @conditional) +(else_clause + ["else"] @conditional) +(ternary_expression + ["?" ":"] @conditional) + (try_statement - ["try" "end" ] @exception) + ["try" "end"] @exception) (finally_clause "finally" @exception) (catch_clause "catch" @exception) -(quote_statement - ["quote" "end"] @keyword) -(let_statement - ["let" "end"] @keyword) + (for_statement ["for" "end"] @repeat) (while_statement ["while" "end"] @repeat) -(break_statement) @repeat -(continue_statement) @repeat (for_clause "for" @repeat) +[ + (break_statement) + (continue_statement) +] @repeat + +(module_definition + ["module" "baremodule" "end"] @include) +(import_statement + ["import" "using"] @include) +(export_statement + "export" @include) + +(macro_definition + ["macro" "end" @keyword]) + +(function_definition + ["function" "end"] @keyword.function) (do_clause - ["do" "end"] @keyword) + ["do" "end"] @keyword.function) +(function_expression + "->" @keyword.function) +(return_statement + "return" @keyword.return) -"in" @keyword.operator -(export_statement - ["export"] @include) +;;; Operators & Punctuation -(import_statement - ["import" "using"] @include) +(operator) @operator +(for_binding ["in" "=" "∈"] @operator) +(pair_expression "=>" @operator) +(range_expression ":" @operator) -(module_definition - ["module" "end"] @include) +(slurp_parameter "..." @operator) +(spread_expression "..." @operator) + +"." @operator +["::" "<:"] @operator -((identifier) @include (#eq? @include "baremodule")) +["," ";"] @punctuation.delimiter +["(" ")" "[" "]" "{" "}"] @punctuation.bracket ;;; Literals +[ + (true) + (false) +] @boolean + (integer_literal) @number (float_literal) @float @@ -162,9 +206,6 @@ (#any-of? @float "NaN" "NaN16" "NaN32" "Inf" "Inf16" "Inf32")) -((identifier) @boolean - (#any-of? @boolean "true" "false")) - ((identifier) @constant.builtin (#any-of? @constant.builtin "nothing" "missing")) @@ -184,8 +225,3 @@ (block_comment) ] @comment -;;; Punctuation - -(quote_expression ":" @symbol) -["::" "." "," "..."] @punctuation.delimiter -["[" "]" "(" ")" "{" "}"] @punctuation.bracket diff --git a/queries/julia/indents.scm b/queries/julia/indents.scm index e6423d34..9cfdc407 100644 --- a/queries/julia/indents.scm +++ b/queries/julia/indents.scm @@ -11,7 +11,7 @@ (quote_statement) (do_clause) - (compound_expression) + (compound_statement) (assignment_expression) (binary_expression) diff --git a/queries/julia/locals.scm b/queries/julia/locals.scm index f8b34f71..655affe0 100644 --- a/queries/julia/locals.scm +++ b/queries/julia/locals.scm @@ -1,59 +1,79 @@ +;;; Variables +(assignment_expression + (identifier) @definition.var) +(assignment_expression + (tuple_expression + (identifier) @definition.var)) -(import_statement - (identifier) @definition.import) +;;; let/const bindings (variable_declaration (identifier) @definition.var) (variable_declaration (tuple_expression (identifier) @definition.var)) + + +;;; For bindings (for_binding - (identifier) @definition.var) + (identifier) @definition.var) (for_binding - (tuple_expression - (identifier) @definition.var)) + (tuple_expression + (identifier) @definition.var)) -(assignment_expression - (tuple_expression - (identifier) @definition.var)) -(assignment_expression - (bare_tuple_expression - (identifier) @definition.var)) -(assignment_expression - (identifier) @definition.var) -(type_parameter_list - (identifier) @definition.type) -(type_argument_list - (identifier) @definition.type) +;;; Types + (struct_definition name: (identifier) @definition.type) +(abstract_definition + name: (identifier) @definition.type) +(abstract_definition + name: (identifier) @definition.type) + +(type_parameter_list + (identifier) @definition.type) + +;;; Module imports + +(import_statement + (identifier) @definition.import) + + +;;; Parameters (parameter_list - (identifier) @definition.parameter) + (identifier) @definition.parameter) +(optional_parameter . + (identifier) @definition.parameter) +(slurp_parameter + (identifier) @definition.parameter) + (typed_parameter - (identifier) @definition.parameter - (identifier)) + parameter: (identifier) @definition.parameter + (_)) + (function_expression - . (identifier) @definition.parameter) -(argument_list - (typed_expression - (identifier) @definition.parameter - (identifier))) -(spread_parameter - (identifier) @definition.parameter) + . (identifier) @definition.parameter) ;; Single parameter arrow function + + +;;; Function/macro definitions (function_definition - name: (identifier) @definition.function) @scope + name: (identifier) @definition.function) @scope +(short_function_definition + name: (identifier) @definition.function) @scope (macro_definition - name: (identifier) @definition.macro) @scope + name: (identifier) @definition.macro) @scope (identifier) @reference [ + (for_statement) + (while_statement) (try_statement) + (catch_clause) (finally_clause) - (quote_statement) (let_statement) - (compound_expression) - (for_statement) + (quote_statement) + (do_clause) ] @scope diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm index 50069258..48aed052 100644 --- a/queries/lua/highlights.scm +++ b/queries/lua/highlights.scm @@ -131,6 +131,11 @@ ((identifier) @variable.builtin (#eq? @variable.builtin "self")) +(variable_list + attribute: (attribute + (["<" ">"] @punctuation.bracket + (identifier) @attribute))) + ;; Constants ((identifier) @constant diff --git a/queries/markdown/highlights.scm b/queries/markdown/highlights.scm index 70c35b39..81cb5a5b 100644 --- a/queries/markdown/highlights.scm +++ b/queries/markdown/highlights.scm @@ -20,11 +20,10 @@ ] @text.literal (pipe_table_header (pipe_table_cell) @text.title) -[ - (pipe_table_row) - (pipe_table_delimiter_row) - (pipe_table_header) -] "|" @punctuation.special + +(pipe_table_header "|" @punctuation.special) +(pipe_table_row "|" @punctuation.special) +(pipe_table_delimiter_row "|" @punctuation.special) (pipe_table_delimiter_cell) @punctuation.special [ diff --git a/queries/ql/folds.scm b/queries/ql/folds.scm new file mode 100644 index 00000000..1a31eeb2 --- /dev/null +++ b/queries/ql/folds.scm @@ -0,0 +1,7 @@ +[ + (module) + (classlessPredicate) + (dataclass) + (charpred) + (memberPredicate) +] @fold diff --git a/queries/rego/highlights.scm b/queries/rego/highlights.scm index 70bf849a..42d276cd 100644 --- a/queries/rego/highlights.scm +++ b/queries/rego/highlights.scm @@ -1,16 +1,64 @@ ; highlights.scm -"import" @include -"package" @include +[ + (import) + (package) +] @include +[ + (with) + (as) + (every) + (some) + (in) + (not) + (if) + (contains) + (else) + (default) + "null" +] @keyword + +[ + "true" + "false" +] @boolean + +[ + (assignment_operator) + (bool_operator) + (arith_operator) + (bin_operator) +] @operator + +[ + (string) + (raw_string) +] @string + +(term (ref (var))) @variable -(reserved_keywords) @keyword (comment) @comment -(rego_block rego_rule_name: (identifier) @function) -(builtin_function function_name: (function_name) @function.builtin) -(opening_parameter) @punctuation.bracket -(closing_parameter) @punctuation.bracket -(string_definition) @string + (number) @number -(operator) @operator -(true) @boolean -(false) @boolean + +(expr_call func_name: (fn_name (var) @function .)) + +(expr_call func_arguments: (fn_args (expr) @parameter)) + +(rule_args (term) @parameter) + +[ + (open_paren) + (close_paren) + (open_bracket) + (close_bracket) + (open_curly) + (close_curly) +] @punctuation.bracket + +(rule (rule_head (var) @method)) + +(rule + (rule_head (term (ref (var) @namespace))) + (rule_body (query (literal (expr (expr_infix (expr (term (ref (var)) @_output)))))) (#eq? @_output @namespace)) +) diff --git a/queries/rust/folds.scm b/queries/rust/folds.scm index d83351cb..97cf2eaf 100644 --- a/queries/rust/folds.scm +++ b/queries/rust/folds.scm @@ -14,7 +14,6 @@ (for_expression) (while_expression) (if_expression) - (if_let_expression) (match_expression) (call_expression) diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index c08912be..c7cd1174 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -25,7 +25,6 @@ (self) @variable.builtin -(lifetime ["'" (identifier)] @label) (loop_label ["'" (identifier)] @label) @@ -72,6 +71,9 @@ (scoped_type_identifier path: (identifier) @namespace) (scoped_type_identifier + path: (identifier) @type + (#lua-match? @type "^[A-Z]")) +(scoped_type_identifier (scoped_identifier name: (identifier) @namespace)) ((scoped_identifier @@ -121,14 +123,14 @@ (macro_definition "macro_rules!" @function.macro) ;; Attribute macros -(attribute_item (meta_item (identifier) @function.macro)) -(meta_item (scoped_identifier (identifier) @function.macro .)) +(attribute_item (attribute (identifier) @function.macro)) +(attribute (scoped_identifier (identifier) @function.macro .)) ;; Derive macros (assume all arguments are types) -(meta_item - (identifier) @_name - arguments: (meta_arguments (meta_item (identifier) @type)) - (#eq? @_name "derive")) +; (attribute +; (identifier) @_name +; arguments: (attribute (attribute (identifier) @type)) +; (#eq? @_name "derive")) ;; Function-like macros (macro_invocation @@ -169,7 +171,6 @@ [ "async" "await" - "const" "default" "dyn" "enum" @@ -179,17 +180,26 @@ "match" "move" "pub" - "ref" - "static" "struct" "trait" "type" "union" "unsafe" "where" - (mutable_specifier) ] @keyword +[ + "ref" + (mutable_specifier) +] @type.qualifier + +[ + "const" + "static" +] @storageclass + +(lifetime ["'" (identifier)] @storageclass.lifetime) + "fn" @keyword.function [ "return" @@ -201,7 +211,8 @@ (use_list (self) @keyword) (scoped_use_list (self) @keyword) -(scoped_identifier (self) @keyword) +(scoped_identifier [(crate) (super) (self)] @keyword) +(visibility_modifier [(crate) (super) (self)] @keyword) [ "else" @@ -216,8 +227,7 @@ "while" ] @repeat -(impl_item - "for" @keyword) +"for" @keyword (for_expression "for" @repeat) @@ -266,6 +276,8 @@ (closure_parameters "|" @punctuation.bracket) (type_arguments ["<" ">"] @punctuation.bracket) (type_parameters ["<" ">"] @punctuation.bracket) +(bracketed_type ["<" ">"] @punctuation.bracket) +(for_lifetimes ["<" ">"] @punctuation.bracket) ["," "." ":" "::" ";"] @punctuation.delimiter @@ -273,3 +285,8 @@ (inner_attribute_item ["!" "#"] @punctuation.special) (macro_invocation "!" @function.macro) (empty_type "!" @type.builtin) + +(macro_invocation macro: (identifier) @_ident @exception "!" @exception + (#eq? @_ident "panic")) +(macro_invocation macro: (identifier) @_ident @exception "!" @exception + (#contains? @_ident "assert")) diff --git a/queries/rust/locals.scm b/queries/rust/locals.scm index 010bf4af..1cefcabf 100644 --- a/queries/rust/locals.scm +++ b/queries/rust/locals.scm @@ -34,7 +34,7 @@ (tuple_pattern (identifier) @definition.var) -(if_let_expression +(let_condition pattern: (_ (identifier) @definition.var)) @@ -93,7 +93,6 @@ (for_expression) (loop_expression) (if_expression) - (if_let_expression) (match_expression) (match_arm) diff --git a/queries/scheme/highlights.scm b/queries/scheme/highlights.scm index 4a7393eb..497512b8 100644 --- a/queries/scheme/highlights.scm +++ b/queries/scheme/highlights.scm @@ -81,7 +81,7 @@ ;; quote -(abbreviation +(quote "'" (symbol)) @symbol diff --git a/queries/vhs/highlights.scm b/queries/vhs/highlights.scm new file mode 100644 index 00000000..67fa3cf8 --- /dev/null +++ b/queries/vhs/highlights.scm @@ -0,0 +1,38 @@ +[ + "Output" + "Backspace" + "Down" + "Enter" + "Escape" + "Left" + "Right" + "Space" + "Tab" + "Up" + "Set" + "Type" + "Sleep" + "Hide" + "Show" ] @keyword + +[ "Shell" + "FontFamily" + "FontSize" + "Framerate" + "PlaybackSpeed" + "Height" + "LetterSpacing" + "TypingSpeed" + "LineHeight" + "Padding" + "Theme" + "LoopOffset" + "Width" ] @type + +[ "@" ] @operator +(control) @function.macro +(float) @float +(integer) @number +(comment) @comment @spell +[(path) (string) (json)] @string +(time) @symbol |
