From eaf8d6d30da5014a3c475c4187b9dccfe621afd5 Mon Sep 17 00:00:00 2001 From: JJ Date: Tue, 31 Oct 2023 18:00:19 -0700 Subject: Add rainbow tree-sitter highlights ref: https://github.com/helix-editor/helix/issues/695 ref: https://github.com/helix-editor/helix/pull/2857 Co-authored-by: Michael Davis --- runtime/queries/bash/rainbows.scm | 21 +++++++++++ runtime/queries/c/rainbows.scm | 29 +++++++++++++++ runtime/queries/clojure/rainbows.scm | 13 +++++++ runtime/queries/common-lisp/rainbows.scm | 1 + runtime/queries/cpp/rainbows.scm | 49 ++++++++++++++++++++++++++ runtime/queries/css/rainbows.scm | 15 ++++++++ runtime/queries/ecma/rainbows.scm | 28 +++++++++++++++ runtime/queries/elixir/rainbows.scm | 24 +++++++++++++ runtime/queries/erlang/rainbows.scm | 24 +++++++++++++ runtime/queries/go/rainbows.scm | 33 ++++++++++++++++++ runtime/queries/html/rainbows.scm | 13 +++++++ runtime/queries/java/rainbows.scm | 35 +++++++++++++++++++ runtime/queries/javascript/rainbows.scm | 1 + runtime/queries/json/rainbows.scm | 9 +++++ runtime/queries/jsx/rainbows.scm | 10 ++++++ runtime/queries/nix/rainbows.scm | 17 +++++++++ runtime/queries/python/rainbows.scm | 30 ++++++++++++++++ runtime/queries/racket/rainbows.scm | 1 + runtime/queries/regex/rainbows.scm | 17 +++++++++ runtime/queries/ruby/rainbows.scm | 28 +++++++++++++++ runtime/queries/rust/rainbows.scm | 60 ++++++++++++++++++++++++++++++++ runtime/queries/scheme/rainbows.scm | 12 +++++++ runtime/queries/scss/rainbows.scm | 3 ++ runtime/queries/starlark/rainbows.scm | 1 + runtime/queries/toml/rainbows.scm | 12 +++++++ runtime/queries/tsq/rainbows.scm | 12 +++++++ runtime/queries/tsx/rainbows.scm | 2 ++ runtime/queries/typescript/rainbows.scm | 19 ++++++++++ runtime/queries/xml/rainbows.scm | 29 +++++++++++++++ runtime/queries/yaml/rainbows.scm | 9 +++++ runtime/queries/zig/rainbows.scm | 42 ++++++++++++++++++++++ 31 files changed, 599 insertions(+) create mode 100644 runtime/queries/bash/rainbows.scm create mode 100644 runtime/queries/c/rainbows.scm create mode 100644 runtime/queries/clojure/rainbows.scm create mode 100644 runtime/queries/common-lisp/rainbows.scm create mode 100644 runtime/queries/cpp/rainbows.scm create mode 100644 runtime/queries/css/rainbows.scm create mode 100644 runtime/queries/ecma/rainbows.scm create mode 100644 runtime/queries/elixir/rainbows.scm create mode 100644 runtime/queries/erlang/rainbows.scm create mode 100644 runtime/queries/go/rainbows.scm create mode 100644 runtime/queries/html/rainbows.scm create mode 100644 runtime/queries/java/rainbows.scm create mode 100644 runtime/queries/javascript/rainbows.scm create mode 100644 runtime/queries/json/rainbows.scm create mode 100644 runtime/queries/jsx/rainbows.scm create mode 100644 runtime/queries/nix/rainbows.scm create mode 100644 runtime/queries/python/rainbows.scm create mode 100644 runtime/queries/racket/rainbows.scm create mode 100644 runtime/queries/regex/rainbows.scm create mode 100644 runtime/queries/ruby/rainbows.scm create mode 100644 runtime/queries/rust/rainbows.scm create mode 100644 runtime/queries/scheme/rainbows.scm create mode 100644 runtime/queries/scss/rainbows.scm create mode 100644 runtime/queries/starlark/rainbows.scm create mode 100644 runtime/queries/toml/rainbows.scm create mode 100644 runtime/queries/tsq/rainbows.scm create mode 100644 runtime/queries/tsx/rainbows.scm create mode 100644 runtime/queries/typescript/rainbows.scm create mode 100644 runtime/queries/xml/rainbows.scm create mode 100644 runtime/queries/yaml/rainbows.scm create mode 100644 runtime/queries/zig/rainbows.scm (limited to 'runtime/queries') diff --git a/runtime/queries/bash/rainbows.scm b/runtime/queries/bash/rainbows.scm new file mode 100644 index 00000000..fd2a9d3a --- /dev/null +++ b/runtime/queries/bash/rainbows.scm @@ -0,0 +1,21 @@ +[ + (function_definition) + (compound_statement) + (subshell) + (test_command) + (subscript) + (parenthesized_expression) + (array) + (expansion_flags) + (expansion) + (command_substitution) +] @rainbow.scope + +[ + "(" ")" + "((" "))" + "${" "$(" + "{" "}" + "[" "]" + "[[" "]]" +] @rainbow.bracket diff --git a/runtime/queries/c/rainbows.scm b/runtime/queries/c/rainbows.scm new file mode 100644 index 00000000..1f80868a --- /dev/null +++ b/runtime/queries/c/rainbows.scm @@ -0,0 +1,29 @@ +[ + (preproc_params) + (preproc_defined) + (argument_list) + (attribute_specifier) + (ms_declspec_modifier) + (declaration_list) + (parenthesized_declarator) + (parenthesized_expression) + (abstract_parenthesized_declarator) + (array_declarator) + (compound_statement) + (initializer_list) + (compound_literal_expression) + (enumerator_list) + (field_declaration_list) + (parameter_list) + (for_statement) + (macro_type_specifier) + (subscript_expression) + (subscript_designator) + (cast_expression) +] @rainbow.scope + +[ + "(" ")" + "{" "}" + "[" "]" +] @rainbow.bracket diff --git a/runtime/queries/clojure/rainbows.scm b/runtime/queries/clojure/rainbows.scm new file mode 100644 index 00000000..99dc8bc3 --- /dev/null +++ b/runtime/queries/clojure/rainbows.scm @@ -0,0 +1,13 @@ +[ + (list_lit) + (map_lit) + (vec_lit) + (anon_fn_lit) +] @rainbow.scope + +[ + "(" ")" + "#" + "{" "}" + "[" "]" +] @rainbow.bracket diff --git a/runtime/queries/common-lisp/rainbows.scm b/runtime/queries/common-lisp/rainbows.scm new file mode 100644 index 00000000..e11eb788 --- /dev/null +++ b/runtime/queries/common-lisp/rainbows.scm @@ -0,0 +1 @@ +; inherits: scheme diff --git a/runtime/queries/cpp/rainbows.scm b/runtime/queries/cpp/rainbows.scm new file mode 100644 index 00000000..ff4882c2 --- /dev/null +++ b/runtime/queries/cpp/rainbows.scm @@ -0,0 +1,49 @@ +[ + ; c + (preproc_params) + (preproc_defined) + (argument_list) + (attribute_specifier) + (ms_declspec_modifier) + (declaration_list) + (parenthesized_declarator) + (parenthesized_expression) + (abstract_parenthesized_declarator) + (array_declarator) + (compound_statement) + (initializer_list) + (compound_literal_expression) + (enumerator_list) + (field_declaration_list) + (parameter_list) + (for_statement) + ; (macro_type_specifier) - not part of cpp + (subscript_expression) + (subscript_designator) + (cast_expression) + + ; cpp + (decltype) + (explicit_function_specifier) + (template_parameter_list) + (template_argument_list) + (parameter_list) + (argument_list) + (structured_binding_declarator) + (noexcept) + (throw_specifier) + (static_assert_declaration) + (condition_clause) + (for_range_loop) + (new_declarator) + (delete_expression "[" "]") + (lambda_capture_specifier) + (sizeof_expression) +] @rainbow.scope + +[ + "(" ")" + "{" "}" + "[" "]" + "<" ">" +] @rainbow.bracket diff --git a/runtime/queries/css/rainbows.scm b/runtime/queries/css/rainbows.scm new file mode 100644 index 00000000..66b60d51 --- /dev/null +++ b/runtime/queries/css/rainbows.scm @@ -0,0 +1,15 @@ +[ + (keyframe_block_list) + (block) + (attribute_selector) + (feature_query) + (parenthesized_query) + (selector_query) + (parenthesized_value) + (arguments) +] @rainbow.scope + +[ + "{" "}" + "(" ")" +] @rainbow.bracket diff --git a/runtime/queries/ecma/rainbows.scm b/runtime/queries/ecma/rainbows.scm new file mode 100644 index 00000000..50f9f813 --- /dev/null +++ b/runtime/queries/ecma/rainbows.scm @@ -0,0 +1,28 @@ +[ + (export_clause) + (named_imports) + (statement_block) + (for_statement) + (for_in_statement) + (switch_body) + (catch_clause "(" ")") + (parenthesized_expression) + (object) + (object_pattern) + (array) + (array_pattern) + (subscript_expression) + (template_substitution) + (arguments) + (class_body) + (formal_parameters) + (computed_property_name) +] @rainbow.scope + +[ + "(" ")" + "${" "{" "}" + "[" "]" +] @rainbow.bracket + +(regex "/" @rainbow.bracket) @rainbow.scope diff --git a/runtime/queries/elixir/rainbows.scm b/runtime/queries/elixir/rainbows.scm new file mode 100644 index 00000000..01d3da7a --- /dev/null +++ b/runtime/queries/elixir/rainbows.scm @@ -0,0 +1,24 @@ +[ + (block) + (interpolation) + (list) + (tuple) + (bitstring) + (map) + ; short-hand function captures like &(&1 + &2) + (unary_operator + operator: "&") + (arguments "(" ")") + (access_call) + (sigil) +] @rainbow.scope + +[ + "(" ")" + "%" + "{" "}" + "[" "]" + "<<" ">>" + "#{" + "|" +] @rainbow.bracket diff --git a/runtime/queries/erlang/rainbows.scm b/runtime/queries/erlang/rainbows.scm new file mode 100644 index 00000000..5092c998 --- /dev/null +++ b/runtime/queries/erlang/rainbows.scm @@ -0,0 +1,24 @@ +[ + ; () + (arguments "(" ")") + (parenthesized_expression) + (function_type) + ; #{} + (record) + (map) + ; {} + (map_update) + (tuple) + ; <<>> + (bitstring) + ; [] + (list) +] @rainbow.scope + +[ + "#" + "{" "}" + "(" ")" + "[" "]" + "<<" ">>" +] @rainbow.bracket diff --git a/runtime/queries/go/rainbows.scm b/runtime/queries/go/rainbows.scm new file mode 100644 index 00000000..81004bf8 --- /dev/null +++ b/runtime/queries/go/rainbows.scm @@ -0,0 +1,33 @@ +[ + (import_spec_list) + (const_declaration) + (var_declaration) + (type_parameter_list) + (parameter_list) + (type_declaration) + (parenthesized_type) + (type_arguments) + (array_type) + (implicit_length_array_type) + (slice_type) + (field_declaration_list) + (interface_type) + (map_type) + (block) + (expression_switch_statement) + (type_switch_statement) + (select_statement) + (parenthesized_expression) + (argument_list) + (index_expression) + (slice_expression) + (type_assertion_expression) + (type_conversion_expression) + (literal_value) +] @rainbow.scope + +[ + "(" ")" + "[" "]" + "{" "}" +] @rainbow.bracket diff --git a/runtime/queries/html/rainbows.scm b/runtime/queries/html/rainbows.scm new file mode 100644 index 00000000..66e62e95 --- /dev/null +++ b/runtime/queries/html/rainbows.scm @@ -0,0 +1,13 @@ +[ + (doctype) + (erroneous_end_tag) +] @rainbow.scope + +([ + (element) + (script_element) + (style_element) + ] @rainbow.scope + (#set! rainbow.include-children)) + +["<" ">" ""] @rainbow.bracket diff --git a/runtime/queries/java/rainbows.scm b/runtime/queries/java/rainbows.scm new file mode 100644 index 00000000..699b899c --- /dev/null +++ b/runtime/queries/java/rainbows.scm @@ -0,0 +1,35 @@ +[ + (cast_expression) + (inferred_parameters) + (dimensions_expr) + (parenthesized_expression) + (array_access) + (argument_list) + (type_arguments) + (dimensions) + (block) + (switch_block) + (catch_clause) + (resource_specification) + (for_statement) + (enhanced_for_statement) + (annotation_argument_list) + (element_value_array_initializer) + (module_body) + (enum_body) + (type_parameters) + (class_body) + (constructor_body) + (annotation_type_body) + (annotation_type_element_declaration) + (interface_body) + (array_initializer) + (formal_parameters) +] @rainbow.scope + +[ + "(" ")" + "{" "}" + "[" "]" + "<" ">" +] @rainbow.bracket diff --git a/runtime/queries/javascript/rainbows.scm b/runtime/queries/javascript/rainbows.scm new file mode 100644 index 00000000..04328f09 --- /dev/null +++ b/runtime/queries/javascript/rainbows.scm @@ -0,0 +1 @@ +; inherits: ecma diff --git a/runtime/queries/json/rainbows.scm b/runtime/queries/json/rainbows.scm new file mode 100644 index 00000000..5c21bdcc --- /dev/null +++ b/runtime/queries/json/rainbows.scm @@ -0,0 +1,9 @@ +[ + (object) + (array) +] @rainbow.scope + +[ + "[" "]" + "{" "}" +] @rainbow.bracket diff --git a/runtime/queries/jsx/rainbows.scm b/runtime/queries/jsx/rainbows.scm new file mode 100644 index 00000000..cf4a7e6a --- /dev/null +++ b/runtime/queries/jsx/rainbows.scm @@ -0,0 +1,10 @@ +; inherits: ecma + +[ + (jsx_expression) +] @rainbow.scope + +(jsx_fragment ["<" "/" ">"] @rainbow.bracket) @rainbow.scope +(jsx_opening_element ["<" ">"] @rainbow.bracket) @rainbow.scope +(jsx_closing_element ["<" "/" ">"] @rainbow.bracket) @rainbow.scope +(jsx_self_closing_element ["<" "/" ">"] @rainbow.bracket) @rainbow.scope diff --git a/runtime/queries/nix/rainbows.scm b/runtime/queries/nix/rainbows.scm new file mode 100644 index 00000000..2df51393 --- /dev/null +++ b/runtime/queries/nix/rainbows.scm @@ -0,0 +1,17 @@ +[ + (formals) + (parenthesized_expression) + (attrset_expression) + (let_attrset_expression) + (rec_attrset_expression) + (inherit_from) + (interpolation) + (list_expression) +] @rainbow.scope + +[ + "${" + "{" "}" + "(" ")" + "[" "]" +] @rainbow.bracket diff --git a/runtime/queries/python/rainbows.scm b/runtime/queries/python/rainbows.scm new file mode 100644 index 00000000..ce3efe2d --- /dev/null +++ b/runtime/queries/python/rainbows.scm @@ -0,0 +1,30 @@ +[ + (future_import_statement) + (import_from_statement) + (with_clause) + (parameters) + (parenthesized_list_splat) + (argument_list) + (tuple_pattern) + (list_pattern) + (subscript) + (list) + (set) + (tuple) + (dictionary) + (dictionary_comprehension) + (set_comprehension) + (list_comprehension) + (generator_expression) + (parenthesized_expression) + (interpolation) + (format_expression) +] @rainbow.scope + +[ + "(" ")" + "{" "}" + "[" "]" +] @rainbow.bracket + +(string ["{{" "}}"] @rainbow.bracket) @rainbow.scope diff --git a/runtime/queries/racket/rainbows.scm b/runtime/queries/racket/rainbows.scm new file mode 100644 index 00000000..e11eb788 --- /dev/null +++ b/runtime/queries/racket/rainbows.scm @@ -0,0 +1 @@ +; inherits: scheme diff --git a/runtime/queries/regex/rainbows.scm b/runtime/queries/regex/rainbows.scm new file mode 100644 index 00000000..a9eb1cff --- /dev/null +++ b/runtime/queries/regex/rainbows.scm @@ -0,0 +1,17 @@ +[ + (lookahead_assertion) + (character_class) + (anonymous_capturing_group) + (named_capturing_group) + (non_capturing_group) + (count_quantifier) + (character_class_escape) +] @rainbow.scope + +[ + "(?" "(?:" + "(?<" ">" + "(" ")" + "[" "]" + "{" "}" +] @rainbow.bracket diff --git a/runtime/queries/ruby/rainbows.scm b/runtime/queries/ruby/rainbows.scm new file mode 100644 index 00000000..e67edfb8 --- /dev/null +++ b/runtime/queries/ruby/rainbows.scm @@ -0,0 +1,28 @@ +[ + (begin_block) + (end_block) + (singleton_method) + (block_parameters) + (parenthesized_statements) + (element_reference) + (argument_list "(" ")") + (block) + (destructured_left_assignment) + (interpolation) + (string_array) + (symbol_array) + (regex) + (array) + (hash) + (method_parameters) +] @rainbow.scope + +[ + "#{" + "{" "}" + "(" ")" + "%w(" "%i(" + "[" "]" + "|" + "/" +] @rainbow.bracket diff --git a/runtime/queries/rust/rainbows.scm b/runtime/queries/rust/rainbows.scm new file mode 100644 index 00000000..0656047b --- /dev/null +++ b/runtime/queries/rust/rainbows.scm @@ -0,0 +1,60 @@ +[ + ; {/} + (declaration_list) + (field_declaration_list) + (field_initializer_list) + (enum_variant_list) + (block) + (match_block) + (use_list) + (struct_pattern) + + ; (/) + (ordered_field_declaration_list) + (arguments) + (parameters) + (tuple_type) + (tuple_expression) + (tuple_pattern) + (tuple_struct_pattern) + (unit_type) + (unit_expression) + (visibility_modifier) + (parenthesized_expression) + (token_repetition_pattern) + + ; + (type_parameters) + (type_arguments) + (bracketed_type) + (for_lifetimes) + + ; [/] + (array_type) + (array_expression) + (index_expression) + (slice_pattern) + + ; attributes #[] + (attribute_item) + (inner_attribute_item) + + ; macros + (token_tree_pattern) + (macro_definition) + + ; closures + (closure_parameters) +] @rainbow.scope + +; attributes like `#[serde(rename_all = "kebab-case")]` +(attribute arguments: (token_tree) @rainbow.scope) + +[ + "#" + "[" "]" + "(" ")" + "{" "}" + "<" ">" + "|" +] @rainbow.bracket diff --git a/runtime/queries/scheme/rainbows.scm b/runtime/queries/scheme/rainbows.scm new file mode 100644 index 00000000..f948772c --- /dev/null +++ b/runtime/queries/scheme/rainbows.scm @@ -0,0 +1,12 @@ +[ + (list) + (vector) + (byte_vector) +] @rainbow.scope + +[ + "#(" "#vu8(" + "(" ")" + "[" "]" + "{" "}" +] @rainbow.bracket diff --git a/runtime/queries/scss/rainbows.scm b/runtime/queries/scss/rainbows.scm new file mode 100644 index 00000000..f0c648f3 --- /dev/null +++ b/runtime/queries/scss/rainbows.scm @@ -0,0 +1,3 @@ +; inherits: css + +(parameters) @rainbow.scope diff --git a/runtime/queries/starlark/rainbows.scm b/runtime/queries/starlark/rainbows.scm new file mode 100644 index 00000000..0b920cbf --- /dev/null +++ b/runtime/queries/starlark/rainbows.scm @@ -0,0 +1 @@ +; inherits: python diff --git a/runtime/queries/toml/rainbows.scm b/runtime/queries/toml/rainbows.scm new file mode 100644 index 00000000..1f61c8ac --- /dev/null +++ b/runtime/queries/toml/rainbows.scm @@ -0,0 +1,12 @@ +[ + (table_array_element) + (table) + (array) + (inline_table) +] @rainbow.scope + +[ + "[[" "]]" + "[" "]" + "{" "}" +] @rainbow.bracket diff --git a/runtime/queries/tsq/rainbows.scm b/runtime/queries/tsq/rainbows.scm new file mode 100644 index 00000000..b1785fa8 --- /dev/null +++ b/runtime/queries/tsq/rainbows.scm @@ -0,0 +1,12 @@ +[ + (group) + (named_node) + (wildcard_node) + (predicate) + (alternation) +] @rainbow.scope + +[ + "(" ")" + "[" "]" +] @rainbow.bracket diff --git a/runtime/queries/tsx/rainbows.scm b/runtime/queries/tsx/rainbows.scm new file mode 100644 index 00000000..64c2fe36 --- /dev/null +++ b/runtime/queries/tsx/rainbows.scm @@ -0,0 +1,2 @@ +; inherits: typescript +; inherits: jsx diff --git a/runtime/queries/typescript/rainbows.scm b/runtime/queries/typescript/rainbows.scm new file mode 100644 index 00000000..919061aa --- /dev/null +++ b/runtime/queries/typescript/rainbows.scm @@ -0,0 +1,19 @@ +; inherits: ecma + +[ + (import_require_clause) + (enum_body) + (lookup_type) + (parenthesized_type) + (object_type) + (type_parameters) + (index_signature) + (array_type) + (tuple_type) +] @rainbow.scope + +(type_arguments ["<" ">"] @rainbow.bracket) @rainbow.scope + +[ + "{|" "|}" +] @rainbow.bracket diff --git a/runtime/queries/xml/rainbows.scm b/runtime/queries/xml/rainbows.scm new file mode 100644 index 00000000..0ff9c7fa --- /dev/null +++ b/runtime/queries/xml/rainbows.scm @@ -0,0 +1,29 @@ +[ + (processing_instructions) + (cdata_sect) + (xml_decl) + (doctype_decl) + (element_decl) + (element_choice) + (element_seq) + (mixed) + (attlist_decl) + (notation_type) + (enumeration) + (ge_decl) + (pe_decl) + (notation_decl) +] @rainbow.scope + +((element) @rainbow.scope + (#set! rainbow.include-children)) + +[ + "" + "<" ">" + "" + "