// Generated by scripts/update-highlight-queries.sh from the grammars' own highlight // queries, at the versions Package.swift pins. Do not edit. enum HighlightQueries { static let source: [String: String] = [ "bash": ####""" [ (string) (raw_string) (heredoc_body) (heredoc_start) ] @string (command_name) @function (variable_name) @property [ "case" "do" "done" "elif" "else" "esac" "export" "fi" "for" "function" "if" "in" "select" "then" "unset" "until" "while" ] @keyword (comment) @comment (function_definition name: (word) @function) (file_descriptor) @number [ (command_substitution) (process_substitution) (expansion) ]@embedded [ "$" "&&" ">" ">>" "<" "|" ] @operator ( (command (_) @constant) (#match? @constant "^-") ) """####, "c": ####""" (identifier) @variable ((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]*$")) "break" @keyword "case" @keyword "const" @keyword "continue" @keyword "default" @keyword "do" @keyword "else" @keyword "enum" @keyword "extern" @keyword "for" @keyword "if" @keyword "inline" @keyword "return" @keyword "sizeof" @keyword "static" @keyword "struct" @keyword "switch" @keyword "typedef" @keyword "union" @keyword "volatile" @keyword "while" @keyword "#define" @keyword "#elif" @keyword "#else" @keyword "#endif" @keyword "#if" @keyword "#ifdef" @keyword "#ifndef" @keyword "#include" @keyword (preproc_directive) @keyword "--" @operator "-" @operator "-=" @operator "->" @operator "=" @operator "!=" @operator "*" @operator "&" @operator "&&" @operator "+" @operator "++" @operator "+=" @operator "<" @operator "==" @operator ">" @operator "||" @operator "." @delimiter ";" @delimiter (string_literal) @string (system_lib_string) @string (null) @constant (number_literal) @number (char_literal) @number (field_identifier) @property (statement_identifier) @label (type_identifier) @type (primitive_type) @type (sized_type_specifier) @type (call_expression function: (identifier) @function) (call_expression function: (field_expression field: (field_identifier) @function)) (function_declarator declarator: (identifier) @function) (preproc_function_def name: (identifier) @function.special) (comment) @comment """####, "clojure": ####""" ;; Literals (num_lit) @number [ (char_lit) (str_lit) ] @string [ (bool_lit) (nil_lit) ] @constant.builtin (kwd_lit) @constant ;; Comments (comment) @comment ;; Treat quasiquotation as operators for the purpose of highlighting. [ "'" "`" "~" "@" "~@" ] @operator """####, "cpp": ####""" (identifier) @variable ((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]*$")) "break" @keyword "case" @keyword "const" @keyword "continue" @keyword "default" @keyword "do" @keyword "else" @keyword "enum" @keyword "extern" @keyword "for" @keyword "if" @keyword "inline" @keyword "return" @keyword "sizeof" @keyword "static" @keyword "struct" @keyword "switch" @keyword "typedef" @keyword "union" @keyword "volatile" @keyword "while" @keyword "#define" @keyword "#elif" @keyword "#else" @keyword "#endif" @keyword "#if" @keyword "#ifdef" @keyword "#ifndef" @keyword "#include" @keyword (preproc_directive) @keyword "--" @operator "-" @operator "-=" @operator "->" @operator "=" @operator "!=" @operator "*" @operator "&" @operator "&&" @operator "+" @operator "++" @operator "+=" @operator "<" @operator "==" @operator ">" @operator "||" @operator "." @delimiter ";" @delimiter (string_literal) @string (system_lib_string) @string (null) @constant (number_literal) @number (char_literal) @number (field_identifier) @property (statement_identifier) @label (type_identifier) @type (primitive_type) @type (sized_type_specifier) @type (call_expression function: (identifier) @function) (call_expression function: (field_expression field: (field_identifier) @function)) (function_declarator declarator: (identifier) @function) (preproc_function_def name: (identifier) @function.special) (comment) @comment ; Functions (call_expression function: (qualified_identifier name: (identifier) @function)) (template_function name: (identifier) @function) (template_method name: (field_identifier) @function) (template_function name: (identifier) @function) (function_declarator declarator: (qualified_identifier name: (identifier) @function)) (function_declarator declarator: (field_identifier) @function) ; Types ((namespace_identifier) @type (#match? @type "^[A-Z]")) (auto) @type ; Constants (this) @variable.builtin (null "nullptr" @constant) ; Keywords [ "catch" "class" "co_await" "co_return" "co_yield" "constexpr" "constinit" "consteval" "delete" "explicit" "final" "friend" "mutable" "namespace" "noexcept" "new" "override" "private" "protected" "public" "template" "throw" "try" "typename" "using" "concept" "requires" "virtual" ] @keyword ; Strings (raw_string_literal) @string """####, "elisp": ####""" ;; When several patterns capture the same node, the last one wins, so ;; a pattern that refines another must come after it. ;; Special forms [ "and" "catch" "cond" "condition-case" "defconst" "defvar" "function" "if" "interactive" "lambda" "let" "let*" "or" "prog1" "prog2" "progn" "quote" "save-current-buffer" "save-excursion" "save-restriction" "setq" "setq-default" "unwind-protect" "while" ] @keyword ;; Function definitions [ "defun" "defsubst" ] @keyword (function_definition name: (symbol) @function) (function_definition parameters: (list (symbol) @variable.parameter)) ;; Highlight macro definitions the same way as function definitions. "defmacro" @keyword (macro_definition name: (symbol) @function) (macro_definition parameters: (list (symbol) @variable.parameter)) ;; &optional and &rest are argument list markers, not parameters. ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Argument-List.html (function_definition parameters: (list (symbol) @keyword (#match? @keyword "^&"))) (macro_definition parameters: (list (symbol) @keyword (#match? @keyword "^&"))) ;; A sharp quoted symbol is a function reference, e.g. #'foo. (function_quote (symbol) @function) ;; The variable defined by defvar or defconst. The anchor restricts ;; this to the first symbol, leaving the initial value alone. (special_form [ "defconst" "defvar" ] . (symbol) @variable) ;; Variables bound by let and let*, written either as (let ((x 1))) ;; or as (let (x)). (special_form [ "let" "let*" ] . (list [ (symbol) @variable (list . (symbol) @variable) ])) (comment) @comment (integer) @number (float) @number ;; Characters are integers in Emacs Lisp, e.g. ?a is 97. (char) @number (string) @string ;; Docstrings are strings too, so these come after (string) @string. (function_definition docstring: (string) @string.documentation) (macro_definition docstring: (string) @string.documentation) ;; defvar and defconst take the docstring after the initial value, so ;; (defvar foo nil "Doc.") has one but (defvar foo "Value") does not. (special_form [ "defconst" "defvar" ] . (symbol) . (_) . (string) @string.documentation) ;; #$ is the name of the file being loaded. ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Read-Syntax.html (byte_compiled_file_name) @constant.builtin [ "(" ")" "#(" "#[" "[" "]" ] @punctuation.bracket [ "`" "#'" "'" "," ",@" ] @operator ;; Highlight nil and t as constants, unlike other symbols [ "nil" "t" ] @constant.builtin ;; Keywords evaluate to themselves, so highlight them as constants too. ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Constant-Variables.html ((symbol) @constant (#match? @constant "^:")) """####, "go": ####""" ; Function calls (call_expression function: (identifier) @function) (call_expression function: (identifier) @function.builtin (#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$")) (call_expression function: (selector_expression field: (field_identifier) @function.method)) ; Function definitions (function_declaration name: (identifier) @function) (method_declaration name: (field_identifier) @function.method) ; Identifiers (type_identifier) @type (field_identifier) @property (identifier) @variable ; Operators [ "--" "-" "-=" ":=" "!" "!=" "..." "*" "*" "*=" "/" "/=" "&" "&&" "&=" "%" "%=" "^" "^=" "+" "++" "+=" "<-" "<" "<<" "<<=" "<=" "=" "==" ">" ">=" ">>" ">>=" "|" "|=" "||" "~" ] @operator ; Keywords [ "break" "case" "chan" "const" "continue" "default" "defer" "else" "fallthrough" "for" "func" "go" "goto" "if" "import" "interface" "map" "package" "range" "return" "select" "struct" "switch" "type" "var" ] @keyword ; Literals [ (interpreted_string_literal) (raw_string_literal) (rune_literal) ] @string (escape_sequence) @escape [ (int_literal) (float_literal) (imaginary_literal) ] @number [ (true) (false) (nil) (iota) ] @constant.builtin (comment) @comment """####, "haskell": ####""" ; ---------------------------------------------------------------------------- ; Parameters and variables ; NOTE: These are at the top, so that they have low priority, ; and don't override destructured parameters (variable) @variable (pattern/wildcard) @variable (decl/function patterns: (patterns (_) @variable.parameter)) (expression/lambda (_)+ @variable.parameter "->") (decl/function (infix (pattern) @variable.parameter)) ; ---------------------------------------------------------------------------- ; Literals and comments (integer) @number (negation) @number (expression/literal (float)) @number.float (char) @character (string) @string (unit) @string.special.symbol ; unit, as in () (comment) @comment ((haddock) @comment.documentation) ; ---------------------------------------------------------------------------- ; Punctuation [ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket [ "," ";" ] @punctuation.delimiter ; ---------------------------------------------------------------------------- ; Keywords, operators, includes [ "forall" ; "∀" ; utf-8 is not cross-platform safe ] @keyword.repeat (pragma) @keyword.directive [ "if" "then" "else" "case" "cases" "of" ] @keyword.conditional [ "import" "qualified" "module" ] @keyword.import [ (operator) (constructor_operator) (all_names) (wildcard) "." ".." "=" "|" "::" "=>" "->" "<-" "\\" "`" "@" ] @operator ; TODO broken, also huh? ; ((qualified_module ; (module) @constructor) ; . ; (module)) (module (module_id) @module) [ "where" "let" "in" "class" "instance" "pattern" "data" "newtype" "family" "type" "as" "hiding" "deriving" "via" "stock" "anyclass" "do" "mdo" "rec" "infix" "infixl" "infixr" ] @keyword ; ---------------------------------------------------------------------------- ; Functions and variables [ (decl/function name: (variable) @function) (decl/bind name: (variable) @function) (decl/signature name: (variable) @function) (decl/signature names: (binding_list (variable) @function)) ] (decl/bind name: (variable) @variable) ; Consider signatures (and accompanying functions) ; with only one value on the rhs as variables (decl/signature name: (variable) @variable type: (type)) ((decl/signature name: (variable) @_name type: (type)) . [ (decl/function name: (variable) @variable) (decl/bind name: (variable) @variable) ] match: (_) (#eq? @_name @variable)) ; but consider a type that involves 'IO' a decl/function (decl/signature name: (variable) @function type: (type/apply constructor: (name) @_type) (#eq? @_type "IO")) ((decl/signature name: (variable) @_name type: (type/apply constructor: (name) @_type) (#eq? @_type "IO")) . [ (decl/function name: (variable) @function) (decl/bind name: (variable) @function) ] match: (_) (#eq? @_name @function)) ((decl/signature) @function . (decl/function name: (variable) @function)) (decl/bind name: (variable) @function (match expression: (expression/lambda))) ; view patterns (view_pattern [ (expression/variable) @function.call (expression/qualified (variable) @function.call) ]) ; consider infix functions as operators (infix_id [ (variable) @operator (qualified (variable) @operator) ]) ; decl/function calls with an infix operator ; e.g. func <$> a <*> b (infix [ (variable) @function.call (qualified ((module) @module (variable) @function.call)) ] . (operator)) ; infix operators applied to variables ((expression/variable) @variable . (operator)) ((operator) . [ (expression/variable) @variable (expression/qualified (variable) @variable) ]) ; decl/function calls with infix operators ([ (expression/variable) @function.call (expression/qualified (variable) @function.call) ] . (operator) @_op (#any-of? @_op "$" "<$>" ">>=" "=<<")) ; right hand side of infix operator ((infix [ (operator) (infix_id (variable)) ] ; infix or `func` . [ (variable) @function.call (qualified (variable) @function.call) ]) . (operator) @_op (#any-of? @_op "$" "<$>" "=<<")) ; decl/function composition, arrows, monadic composition (lhs) ( [ (expression/variable) @function (expression/qualified (variable) @function) ] . (operator) @_op (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) ; right hand side of infix operator ((infix [ (operator) (infix_id (variable)) ] ; infix or `func` . [ (variable) @function (qualified (variable) @function) ]) . (operator) @_op (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) ; function composition, arrows, monadic composition (rhs) ((operator) @_op . [ (expression/variable) @function (expression/qualified (variable) @function) ] (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) ; function defined in terms of a function composition (decl/function name: (variable) @function (match expression: (infix operator: (operator) @_op (#any-of? @_op "." ">>>" "***" ">=>" "<=<")))) (apply [ (expression/variable) @function.call (expression/qualified (variable) @function.call) ]) ; function compositions, in parentheses, applied ; lhs (apply . (expression/parens (infix [ (variable) @function.call (qualified (variable) @function.call) ] . (operator)))) ; rhs (apply . (expression/parens (infix (operator) . [ (variable) @function.call (qualified (variable) @function.call) ]))) ; variables being passed to a function call (apply (_) . [ (expression/variable) @variable (expression/qualified (variable) @variable) ]) ; main is always a function ; (this prevents `main = undefined` from being highlighted as a variable) (decl/bind name: (variable) @function (#eq? @function "main")) ; scoped function types (func :: a -> b) (signature pattern: (pattern/variable) @function type: (quantified_type)) ; signatures that have a function type ; + binds that follow them (decl/signature name: (variable) @function type: (quantified_type)) ((decl/signature name: (variable) @_name type: (quantified_type)) . (decl/bind (variable) @function) (#eq? @function @_name)) ; ---------------------------------------------------------------------------- ; Types (name) @type (type/star) @type (variable) @type (constructor) @constructor ; True or False ((constructor) @boolean (#any-of? @boolean "True" "False")) ; otherwise (= True) ((variable) @boolean (#eq? @boolean "otherwise")) ; ---------------------------------------------------------------------------- ; Quasi-quotes (quoter) @function.call (quasiquote [ (quoter) @_name (_ (variable) @_name) ] (#eq? @_name "qq") (quasiquote_body) @string) (quasiquote (_ (variable) @_name) (#eq? @_name "qq") (quasiquote_body) @string) ; namespaced quasi-quoter (quasiquote (_ (module) @module . (variable) @function.call)) ; Highlighting of quasiquote_body for other languages is handled by injections.scm ; ---------------------------------------------------------------------------- ; Exceptions/error handling ((variable) @keyword.exception (#any-of? @keyword.exception "error" "undefined" "try" "tryJust" "tryAny" "catch" "catches" "catchJust" "handle" "handleJust" "throw" "throwIO" "throwTo" "throwError" "ioError" "mask" "mask_" "uninterruptibleMask" "uninterruptibleMask_" "bracket" "bracket_" "bracketOnErrorSource" "finally" "fail" "onException" "expectationFailure")) ; ---------------------------------------------------------------------------- ; Debugging ((variable) @keyword.debug (#any-of? @keyword.debug "trace" "traceId" "traceShow" "traceShowId" "traceWith" "traceShowWith" "traceStack" "traceIO" "traceM" "traceShowM" "traceEvent" "traceEventWith" "traceEventIO" "flushEventLog" "traceMarker" "traceMarkerIO")) ; ---------------------------------------------------------------------------- ; Fields (field_name (variable) @variable.member) (import_name (name) . (children (variable) @variable.member)) ; ---------------------------------------------------------------------------- ; Spell checking (comment) @spell """####, "java": ####""" ; Variables (identifier) @variable ; Methods (method_declaration name: (identifier) @function.method) (method_invocation name: (identifier) @function.method) (super) @function.builtin ; Annotations (annotation name: (identifier) @attribute) (marker_annotation name: (identifier) @attribute) "@" @operator ; Types (type_identifier) @type (interface_declaration name: (identifier) @type) (class_declaration name: (identifier) @type) (enum_declaration name: (identifier) @type) ((field_access object: (identifier) @type) (#match? @type "^[A-Z]")) ((scoped_identifier scope: (identifier) @type) (#match? @type "^[A-Z]")) ((method_invocation object: (identifier) @type) (#match? @type "^[A-Z]")) ((method_reference . (identifier) @type) (#match? @type "^[A-Z]")) (constructor_declaration name: (identifier) @type) [ (boolean_type) (integral_type) (floating_point_type) (floating_point_type) (void_type) ] @type.builtin ; Constants ((identifier) @constant (#match? @constant "^_*[A-Z][A-Z\\d_]+$")) ; Builtins (this) @variable.builtin ; Literals [ (hex_integer_literal) (decimal_integer_literal) (octal_integer_literal) (decimal_floating_point_literal) (hex_floating_point_literal) ] @number [ (character_literal) (string_literal) ] @string (escape_sequence) @string.escape [ (true) (false) (null_literal) ] @constant.builtin [ (line_comment) (block_comment) ] @comment ; Keywords [ "abstract" "assert" "break" "case" "catch" "class" "continue" "default" "do" "else" "enum" "exports" "extends" "final" "finally" "for" "if" "implements" "import" "instanceof" "interface" "module" "native" "new" "non-sealed" "open" "opens" "package" "permits" "private" "protected" "provides" "public" "requires" "record" "return" "sealed" "static" "strictfp" "switch" "synchronized" "throw" "throws" "to" "transient" "transitive" "try" "uses" "volatile" "when" "while" "with" "yield" ] @keyword """####, "javascript": ####""" ; Variables ;---------- (identifier) @variable ; Properties ;----------- (property_identifier) @property ; Function and method definitions ;-------------------------------- (function_expression name: (identifier) @function) (function_declaration name: (identifier) @function) (method_definition name: (property_identifier) @function.method) (pair key: (property_identifier) @function.method value: [(function_expression) (arrow_function)]) (assignment_expression left: (member_expression property: (property_identifier) @function.method) right: [(function_expression) (arrow_function)]) (variable_declarator name: (identifier) @function value: [(function_expression) (arrow_function)]) (assignment_expression left: (identifier) @function right: [(function_expression) (arrow_function)]) ; Function and method calls ;-------------------------- (call_expression function: (identifier) @function) (call_expression function: (member_expression property: (property_identifier) @function.method)) ; Special identifiers ;-------------------- ((identifier) @constructor (#match? @constructor "^[A-Z]")) ([ (identifier) (shorthand_property_identifier) (shorthand_property_identifier_pattern) ] @constant (#match? @constant "^[A-Z_][A-Z\\d_]+$")) ((identifier) @variable.builtin (#match? @variable.builtin "^(arguments|module|console|window|document)$") (#is-not? local)) ((identifier) @function.builtin (#eq? @function.builtin "require") (#is-not? local)) ; Literals ;--------- (this) @variable.builtin (super) @variable.builtin [ (true) (false) (null) (undefined) ] @constant.builtin (comment) @comment [ (string) (template_string) ] @string (regex) @string.special (number) @number ; Tokens ;------- [ ";" (optional_chain) "." "," ] @punctuation.delimiter [ "-" "--" "-=" "+" "++" "+=" "*" "*=" "**" "**=" "/" "/=" "%" "%=" "<" "<=" "<<" "<<=" "=" "==" "===" "!" "!=" "!==" "=>" ">" ">=" ">>" ">>=" ">>>" ">>>=" "~" "^" "&" "|" "^=" "&=" "|=" "&&" "||" "??" "&&=" "||=" "??=" ] @operator [ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket (template_substitution "${" @punctuation.special "}" @punctuation.special) @embedded [ "as" "async" "await" "break" "case" "catch" "class" "const" "continue" "debugger" "default" "delete" "do" "else" "export" "extends" "finally" "for" "from" "function" "get" "if" "import" "in" "instanceof" "let" "new" "of" "return" "set" "static" "switch" "target" "throw" "try" "typeof" "var" "void" "while" "with" "yield" ] @keyword """####, "json": ####""" (pair key: (_) @string.special.key) (string) @string (number) @number [ (null) (true) (false) ] @constant.builtin (escape_sequence) @escape (comment) @comment """####, "lua": ####""" ; Keywords "return" @keyword.return [ "goto" "in" "local" "global" ] @keyword (label_statement) @label (break_statement) @keyword (do_statement [ "do" "end" ] @keyword) (while_statement [ "while" "do" "end" ] @repeat) (repeat_statement [ "repeat" "until" ] @repeat) (if_statement [ "if" "elseif" "else" "then" "end" ] @conditional) (elseif_statement [ "elseif" "then" "end" ] @conditional) (else_statement [ "else" "end" ] @conditional) (for_statement [ "for" "do" "end" ] @repeat) (function_declaration [ "function" "end" ] @keyword.function) (function_definition [ "function" "end" ] @keyword.function) ; Operators (binary_expression operator: _ @operator) (unary_expression operator: _ @operator) "=" @operator [ "and" "not" "or" ] @keyword.operator ; Punctuations [ ";" ":" "," "." ] @punctuation.delimiter ; Brackets [ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket ; Variables (identifier) @variable ((identifier) @variable.builtin (#eq? @variable.builtin "self")) (variable_list (attribute "<" @punctuation.bracket (identifier) @attribute ">" @punctuation.bracket)) ; Constants ((identifier) @constant (#match? @constant "^[A-Z][A-Z_0-9]*$")) (vararg_expression) @constant (nil) @constant.builtin [ (false) (true) ] @boolean ; Tables (field name: (identifier) @field) (dot_index_expression field: (identifier) @field) (table_constructor [ "{" "}" ] @constructor) ; Functions (parameters (identifier) @parameter) (function_declaration name: [ (identifier) @function (dot_index_expression field: (identifier) @function) ]) (function_declaration name: (method_index_expression method: (identifier) @method)) (assignment_statement (variable_list . name: [ (identifier) @function (dot_index_expression field: (identifier) @function) ]) (expression_list . value: (function_definition))) (table_constructor (field name: (identifier) @function value: (function_definition))) (function_call name: [ (identifier) @function.call (dot_index_expression field: (identifier) @function.call) (method_index_expression method: (identifier) @method.call) ]) (function_call (identifier) @function.builtin (#any-of? @function.builtin ; built-in functions in Lua 5.1 "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall")) ; Others (comment) @comment (hash_bang_line) @preproc (number) @number (string) @string (escape_sequence) @string.escape """####, "python": ####""" ; Identifier naming conventions (identifier) @variable ((identifier) @constructor (#match? @constructor "^[A-Z]")) ((identifier) @constant (#match? @constant "^[A-Z][A-Z_]*$")) ; Function calls (decorator) @function (decorator (identifier) @function) (call function: (attribute attribute: (identifier) @function.method)) (call function: (identifier) @function) ; Builtin functions ((call function: (identifier) @function.builtin) (#match? @function.builtin "^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$")) ; Function definitions (function_definition name: (identifier) @function) (attribute attribute: (identifier) @property) (type (identifier) @type) ; Literals [ (none) (true) (false) ] @constant.builtin [ (integer) (float) ] @number (comment) @comment (string) @string (escape_sequence) @escape (interpolation "{" @punctuation.special "}" @punctuation.special) @embedded [ "-" "-=" "!=" "*" "**" "**=" "*=" "/" "//" "//=" "/=" "&" "&=" "%" "%=" "^" "^=" "+" "->" "+=" "<" "<<" "<<=" "<=" "<>" "=" ":=" "==" ">" ">=" ">>" ">>=" "|" "|=" "~" "@=" "and" "in" "is" "not" "or" "is not" "not in" ] @operator [ "as" "assert" "async" "await" "break" "class" "continue" "def" "del" "elif" "else" "except" "exec" "finally" "for" "from" "global" "if" "import" "lambda" "nonlocal" "pass" "print" "raise" "return" "try" "while" "with" "yield" "match" "case" ] @keyword """####, "r": ####""" ; highlights.scm ; Literals (integer) @number (float) @number (complex) @number (string) @string (string (string_content (escape_sequence) @string.escape)) ; Comments (comment) @comment ; Operators [ "?" ":=" "=" "<-" "<<-" "->" "->>" "~" "|>" "||" "|" "&&" "&" "<" "<=" ">" ">=" "==" "!=" "+" "-" "*" "/" "::" ":::" "**" "^" "$" "@" ":" "!" "special" ] @operator ; Punctuation [ "(" ")" "{" "}" "[" "]" "[[" "]]" ] @punctuation.bracket (comma) @punctuation.delimiter ; Variables (identifier) @variable ; Functions (binary_operator lhs: (identifier) @function operator: "<-" rhs: (function_definition) ) (binary_operator lhs: (identifier) @function operator: "=" rhs: (function_definition) ) ; Calls (call function: (identifier) @function) ; - `return` is just a regular identifier in our grammar (#189), but people ; expect `return()` to be highlighted ; - We feel confident that we can use `#eq?` here, as other grammars use ; `#eq?` and `#match?` predicates already, even though support for predicates ; is dependent on the library that binds to tree-sitter's C library, not the ; C library itself. ; https://github.com/tree-sitter/tree-sitter-javascript/blob/58404d8cf191d69f2674a8fd507bd5776f46cb11/queries/highlights.scm#L65-L67 ; https://github.com/tree-sitter/tree-sitter-rust/blob/77a3747266f4d621d0757825e6b11edcbf991ca5/queries/highlights.scm#L9-L11 ; - Placed after `(call function: (identifier) @function)` for correct precedence ( (call function: (identifier) @keyword) (#eq? @keyword "return") ) ; Parameters (parameters (parameter name: (identifier) @variable.parameter)) (arguments (argument name: (identifier) @variable.parameter)) ; Namespace (namespace_operator lhs: (identifier) @namespace) (call function: (namespace_operator rhs: (identifier) @function) ) ; Keywords (function_definition name: "function" @keyword.function) (function_definition name: "\\" @operator) [ "in" (next) (break) ] @keyword [ "if" "else" ] @conditional [ "while" "repeat" "for" ] @repeat [ (true) (false) ] @boolean [ (null) (inf) (nan) (na) (dots) (dot_dot_i) ] @constant.builtin ; Error (ERROR) @error """####, "ruby": ####""" (identifier) @variable ((identifier) @function.method (#is-not? local)) [ "alias" "and" "begin" "break" "case" "class" "def" "do" "else" "elsif" "end" "ensure" "for" "if" "in" "module" "next" "or" "rescue" "retry" "return" "then" "unless" "until" "when" "while" "yield" ] @keyword ((identifier) @keyword (#match? @keyword "^(private|protected|public)$")) (constant) @constructor ; Function calls "defined?" @function.method.builtin (call method: [(identifier) (constant)] @function.method) ((identifier) @function.method.builtin (#eq? @function.method.builtin "require")) ; Function definitions (alias (identifier) @function.method) (setter (identifier) @function.method) (method name: [(identifier) (constant)] @function.method) (singleton_method name: [(identifier) (constant)] @function.method) ; Identifiers [ (class_variable) (instance_variable) ] @property ((identifier) @constant.builtin (#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$")) (file) @constant.builtin (line) @constant.builtin (encoding) @constant.builtin (hash_splat_nil "**" @operator) @constant.builtin ((constant) @constant (#match? @constant "^[A-Z\\d_]+$")) [ (self) (super) ] @variable.builtin (block_parameter (identifier) @variable.parameter) (block_parameters (identifier) @variable.parameter) (destructured_parameter (identifier) @variable.parameter) (hash_splat_parameter (identifier) @variable.parameter) (lambda_parameters (identifier) @variable.parameter) (method_parameters (identifier) @variable.parameter) (splat_parameter (identifier) @variable.parameter) (keyword_parameter name: (identifier) @variable.parameter) (optional_parameter name: (identifier) @variable.parameter) ; Literals [ (string) (bare_string) (subshell) (heredoc_body) (heredoc_beginning) ] @string [ (simple_symbol) (delimited_symbol) (hash_key_symbol) (bare_symbol) ] @string.special.symbol (regex) @string.special.regex (escape_sequence) @escape [ (integer) (float) ] @number [ (nil) (true) (false) ] @constant.builtin (interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded (comment) @comment ; Operators [ "=" "=>" "->" ] @operator [ "," ";" "." ] @punctuation.delimiter [ "(" ")" "[" "]" "{" "}" "%w(" "%i(" ] @punctuation.bracket """####, "rust": ####""" ; Identifiers (type_identifier) @type (primitive_type) @type.builtin (field_identifier) @property ; Identifier conventions ; Assume all-caps names are constants ((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]+$'")) ; Assume uppercase names are enum constructors ((identifier) @constructor (#match? @constructor "^[A-Z]")) ; Assume that uppercase names in paths are types ((scoped_identifier path: (identifier) @type) (#match? @type "^[A-Z]")) ((scoped_identifier path: (scoped_identifier name: (identifier) @type)) (#match? @type "^[A-Z]")) ((scoped_type_identifier path: (identifier) @type) (#match? @type "^[A-Z]")) ((scoped_type_identifier path: (scoped_identifier name: (identifier) @type)) (#match? @type "^[A-Z]")) ; Assume all qualified names in struct patterns are enum constructors. (They're ; either that, or struct names; highlighting both as constructors seems to be ; the less glaring choice of error, visually.) (struct_pattern type: (scoped_type_identifier name: (type_identifier) @constructor)) ; Function calls (call_expression function: (identifier) @function) (call_expression function: (field_expression field: (field_identifier) @function.method)) (call_expression function: (scoped_identifier "::" name: (identifier) @function)) (generic_function function: (identifier) @function) (generic_function function: (scoped_identifier name: (identifier) @function)) (generic_function function: (field_expression field: (field_identifier) @function.method)) (macro_invocation macro: (identifier) @function.macro "!" @function.macro) ; Function definitions (function_item (identifier) @function) (function_signature_item (identifier) @function) (line_comment) @comment (block_comment) @comment (line_comment (doc_comment)) @comment.documentation (block_comment (doc_comment)) @comment.documentation "(" @punctuation.bracket ")" @punctuation.bracket "[" @punctuation.bracket "]" @punctuation.bracket "{" @punctuation.bracket "}" @punctuation.bracket (type_arguments "<" @punctuation.bracket ">" @punctuation.bracket) (type_parameters "<" @punctuation.bracket ">" @punctuation.bracket) "::" @punctuation.delimiter ":" @punctuation.delimiter "." @punctuation.delimiter "," @punctuation.delimiter ";" @punctuation.delimiter (parameter (identifier) @variable.parameter) (lifetime (identifier) @label) "as" @keyword "async" @keyword "await" @keyword "break" @keyword "const" @keyword "continue" @keyword "default" @keyword "dyn" @keyword "else" @keyword "enum" @keyword "extern" @keyword "fn" @keyword "for" @keyword "gen" @keyword "if" @keyword "impl" @keyword "in" @keyword "let" @keyword "loop" @keyword "macro_rules!" @keyword "match" @keyword "mod" @keyword "move" @keyword "pub" @keyword "raw" @keyword "ref" @keyword "return" @keyword "static" @keyword "struct" @keyword "trait" @keyword "type" @keyword "union" @keyword "unsafe" @keyword "use" @keyword "where" @keyword "while" @keyword "yield" @keyword (crate) @keyword (mutable_specifier) @keyword (use_list (self) @keyword) (scoped_use_list (self) @keyword) (scoped_identifier (self) @keyword) (super) @keyword (self) @variable.builtin (char_literal) @string (string_literal) @string (raw_string_literal) @string (boolean_literal) @constant.builtin (integer_literal) @constant.builtin (float_literal) @constant.builtin (escape_sequence) @escape (attribute_item) @attribute (inner_attribute_item) @attribute "*" @operator "&" @operator "'" @operator """####, "scheme": ####""" ["(" ")" "[" "]" "{" "}"] @punctuation.bracket (number) @number (character) @constant.builtin (boolean) @constant.builtin (symbol) @variable (string) @string (escape_sequence) @escape (list . (symbol) @function) (list . "[" . (symbol)+ @variable . "]") ((symbol) @operator (#match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$")) (list . (symbol) @keyword (#match? @keyword "^(define-syntax|let\\*|lambda|λ|case|=>|quote-splicing|unquote-splicing|set!|let|letrec|letrec-syntax|let-values|let\\*-values|do|else|define|cond|syntax-rules|unquote|begin|quote|let-syntax|and|if|quasiquote|letrec|delay|or|when|unless|identifier-syntax|assert|library|export|import|rename|only|except|prefix)$" )) (list . (symbol) @function.builtin (#match? @function.builtin "^(caar|cadr|call-with-input-file|call-with-output-file|cdar|cddr|list|open-input-file|open-output-file|with-input-from-file|with-output-to-file|\\*|\\+|-|/|<|<=|=|>|>=|abs|acos|angle|append|apply|asin|assoc|assq|assv|atan|boolean\\?|caaaar|caaadr|caaar|caadar|caaddr|caadr|cadaar|cadadr|cadar|caddar|cadddr|caddr|call-with-current-continuation|call-with-values|car|cdaaar|cdaadr|cdaar|cdadar|cdaddr|cdadr|cddaar|cddadr|cddar|cdddar|cddddr|cdddr|cdr|ceiling|char->integer|char-alphabetic\\?|char-ci<=\\?|char-ci<\\?|char-ci=\\?|char-ci>=\\?|char-ci>\\?|char-downcase|char-lower-case\\?|char-numeric\\?|char-ready\\?|char-upcase|char-upper-case\\?|char-whitespace\\?|char<=\\?|char<\\?|char=\\?|char>=\\?|char>\\?|char\\?|close-input-port|close-output-port|complex\\?|cons|cos|current-error-port|current-input-port|current-output-port|denominator|display|dynamic-wind|eof-object\\?|eq\\?|equal\\?|eqv\\?|eval|even\\?|exact->inexact|exact\\?|exp|expt|floor|flush-output|for-each|force|gcd|imag-part|inexact->exact|inexact\\?|input-port\\?|integer->char|integer\\?|interaction-environment|lcm|length|list->string|list->vector|list-ref|list-tail|list\\?|load|log|magnitude|make-polar|make-rectangular|make-string|make-vector|map|max|member|memq|memv|min|modulo|negative\\?|newline|not|null-environment|null\\?|number->string|number\\?|numerator|odd\\?|output-port\\?|pair\\?|peek-char|positive\\?|procedure\\?|quotient|rational\\?|rationalize|read|read-char|real-part|real\\?|remainder|reverse|round|scheme-report-environment|set-car!|set-cdr!|sin|sqrt|string|string->list|string->number|string->symbol|string-append|string-ci<=\\?|string-ci<\\?|string-ci=\\?|string-ci>=\\?|string-ci>\\?|string-copy|string-fill!|string-length|string-ref|string-set!|string<=\\?|string<\\?|string=\\?|string>=\\?|string>\\?|string\\?|substring|symbol->string|symbol\\?|tan|transcript-off|transcript-on|truncate|values|vector|vector->list|vector-fill!|vector-length|vector-ref|vector-set!|vector\\?|write|write-char|zero\\?)$" )) ;; quote ;; ;; hardcoded highlight four levels of nested structure ; 'atom (quote _ @constant) ; '() (quote (_ _* @constant)) ; '(()) (quote (_ (_ _* @constant))) ; '((())) (quote (_ (_ (_ _* @constant)))) ;; sexp comment ;; ;; hardcoded highlight four levels of nested structure ; #;atom (comment _ @comment) ; #;(list) (comment (_ _* @comment)) ; #;(list (list)) (comment (_ (_ _* @comment))) ; #;(list (list (list))) (comment (_ (_ (_ _ @comment)))) [(comment) (block_comment) (directive)] @comment """####, "toml": ####""" ; TOML highlights for Orgstar: table names as types, keys as properties. The grammar's own ; query captures whole pairs as properties, which colors values too. (comment) @comment (string) @string (quoted_key) @string [(integer) (float)] @number (boolean) @constant [(offset_date_time) (local_date_time) (local_date) (local_time)] @string.special (table (bare_key) @type) (table (dotted_key (bare_key) @type)) (table_array_element (bare_key) @type) (table_array_element (dotted_key (bare_key) @type)) (pair (bare_key) @property) (pair (dotted_key (bare_key) @property)) "=" @operator """####, "yaml": ####""" (boolean_scalar) @boolean (null_scalar) @constant.builtin [ (double_quote_scalar) (single_quote_scalar) (block_scalar) (string_scalar) ] @string [ (integer_scalar) (float_scalar) ] @number (comment) @comment [ (anchor_name) (alias_name) ] @label (tag) @type [ (yaml_directive) (tag_directive) (reserved_directive) ] @attribute (block_mapping_pair key: (flow_node [ (double_quote_scalar) (single_quote_scalar) ] @property)) (block_mapping_pair key: (flow_node (plain_scalar (string_scalar) @property))) (flow_mapping (_ key: (flow_node [ (double_quote_scalar) (single_quote_scalar) ] @property))) (flow_mapping (_ key: (flow_node (plain_scalar (string_scalar) @property)))) [ "," "-" ":" ">" "?" "|" ] @punctuation.delimiter [ "[" "]" "{" "}" ] @punctuation.bracket [ "*" "&" "---" "..." ] @punctuation.special """####, ] }