krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Sources/OrgHighlight/Queries.swift

191ddb506f3a91b93c755ba6e8123a4e8ac4f90d
orgstar/Sources/OrgHighlight/Queries.swift history · blame · raw

2397 lines · 57011 bytes

   1// Generated by scripts/update-highlight-queries.sh from the grammars' own highlight
   2// queries, at the versions Package.swift pins. Do not edit.
   3
   4enum HighlightQueries {
   5    static let source: [String: String] = [
   6        "bash": ####"""
   7        [
   8          (string)
   9          (raw_string)
  10          (heredoc_body)
  11          (heredoc_start)
  12        ] @string
  13
  14        (command_name) @function
  15
  16        (variable_name) @property
  17
  18        [
  19          "case"
  20          "do"
  21          "done"
  22          "elif"
  23          "else"
  24          "esac"
  25          "export"
  26          "fi"
  27          "for"
  28          "function"
  29          "if"
  30          "in"
  31          "select"
  32          "then"
  33          "unset"
  34          "until"
  35          "while"
  36        ] @keyword
  37
  38        (comment) @comment
  39
  40        (function_definition name: (word) @function)
  41
  42        (file_descriptor) @number
  43
  44        [
  45          (command_substitution)
  46          (process_substitution)
  47          (expansion)
  48        ]@embedded
  49
  50        [
  51          "$"
  52          "&&"
  53          ">"
  54          ">>"
  55          "<"
  56          "|"
  57        ] @operator
  58
  59        (
  60          (command (_) @constant)
  61          (#match? @constant "^-")
  62        )
  63        """####,
  64        "c": ####"""
  65        (identifier) @variable
  66
  67        ((identifier) @constant
  68         (#match? @constant "^[A-Z][A-Z\\d_]*$"))
  69
  70        "break" @keyword
  71        "case" @keyword
  72        "const" @keyword
  73        "continue" @keyword
  74        "default" @keyword
  75        "do" @keyword
  76        "else" @keyword
  77        "enum" @keyword
  78        "extern" @keyword
  79        "for" @keyword
  80        "if" @keyword
  81        "inline" @keyword
  82        "return" @keyword
  83        "sizeof" @keyword
  84        "static" @keyword
  85        "struct" @keyword
  86        "switch" @keyword
  87        "typedef" @keyword
  88        "union" @keyword
  89        "volatile" @keyword
  90        "while" @keyword
  91
  92        "#define" @keyword
  93        "#elif" @keyword
  94        "#else" @keyword
  95        "#endif" @keyword
  96        "#if" @keyword
  97        "#ifdef" @keyword
  98        "#ifndef" @keyword
  99        "#include" @keyword
 100        (preproc_directive) @keyword
 101
 102        "--" @operator
 103        "-" @operator
 104        "-=" @operator
 105        "->" @operator
 106        "=" @operator
 107        "!=" @operator
 108        "*" @operator
 109        "&" @operator
 110        "&&" @operator
 111        "+" @operator
 112        "++" @operator
 113        "+=" @operator
 114        "<" @operator
 115        "==" @operator
 116        ">" @operator
 117        "||" @operator
 118
 119        "." @delimiter
 120        ";" @delimiter
 121
 122        (string_literal) @string
 123        (system_lib_string) @string
 124
 125        (null) @constant
 126        (number_literal) @number
 127        (char_literal) @number
 128
 129        (field_identifier) @property
 130        (statement_identifier) @label
 131        (type_identifier) @type
 132        (primitive_type) @type
 133        (sized_type_specifier) @type
 134
 135        (call_expression
 136          function: (identifier) @function)
 137        (call_expression
 138          function: (field_expression
 139            field: (field_identifier) @function))
 140        (function_declarator
 141          declarator: (identifier) @function)
 142        (preproc_function_def
 143          name: (identifier) @function.special)
 144
 145        (comment) @comment
 146        """####,
 147        "clojure": ####"""
 148        ;; Literals
 149
 150        (num_lit) @number
 151
 152        [
 153          (char_lit)
 154          (str_lit)
 155        ] @string
 156
 157        [
 158         (bool_lit)
 159         (nil_lit)
 160        ] @constant.builtin
 161
 162        (kwd_lit) @constant
 163
 164        ;; Comments
 165
 166        (comment) @comment
 167
 168        ;; Treat quasiquotation as operators for the purpose of highlighting.
 169
 170        [
 171         "'"
 172         "`"
 173         "~"
 174         "@"
 175         "~@"
 176        ] @operator
 177        """####,
 178        "cpp": ####"""
 179        (identifier) @variable
 180
 181        ((identifier) @constant
 182         (#match? @constant "^[A-Z][A-Z\\d_]*$"))
 183
 184        "break" @keyword
 185        "case" @keyword
 186        "const" @keyword
 187        "continue" @keyword
 188        "default" @keyword
 189        "do" @keyword
 190        "else" @keyword
 191        "enum" @keyword
 192        "extern" @keyword
 193        "for" @keyword
 194        "if" @keyword
 195        "inline" @keyword
 196        "return" @keyword
 197        "sizeof" @keyword
 198        "static" @keyword
 199        "struct" @keyword
 200        "switch" @keyword
 201        "typedef" @keyword
 202        "union" @keyword
 203        "volatile" @keyword
 204        "while" @keyword
 205
 206        "#define" @keyword
 207        "#elif" @keyword
 208        "#else" @keyword
 209        "#endif" @keyword
 210        "#if" @keyword
 211        "#ifdef" @keyword
 212        "#ifndef" @keyword
 213        "#include" @keyword
 214        (preproc_directive) @keyword
 215
 216        "--" @operator
 217        "-" @operator
 218        "-=" @operator
 219        "->" @operator
 220        "=" @operator
 221        "!=" @operator
 222        "*" @operator
 223        "&" @operator
 224        "&&" @operator
 225        "+" @operator
 226        "++" @operator
 227        "+=" @operator
 228        "<" @operator
 229        "==" @operator
 230        ">" @operator
 231        "||" @operator
 232
 233        "." @delimiter
 234        ";" @delimiter
 235
 236        (string_literal) @string
 237        (system_lib_string) @string
 238
 239        (null) @constant
 240        (number_literal) @number
 241        (char_literal) @number
 242
 243        (field_identifier) @property
 244        (statement_identifier) @label
 245        (type_identifier) @type
 246        (primitive_type) @type
 247        (sized_type_specifier) @type
 248
 249        (call_expression
 250          function: (identifier) @function)
 251        (call_expression
 252          function: (field_expression
 253            field: (field_identifier) @function))
 254        (function_declarator
 255          declarator: (identifier) @function)
 256        (preproc_function_def
 257          name: (identifier) @function.special)
 258
 259        (comment) @comment
 260
 261        ; Functions
 262
 263        (call_expression
 264          function: (qualified_identifier
 265            name: (identifier) @function))
 266
 267        (template_function
 268          name: (identifier) @function)
 269
 270        (template_method
 271          name: (field_identifier) @function)
 272
 273        (template_function
 274          name: (identifier) @function)
 275
 276        (function_declarator
 277          declarator: (qualified_identifier
 278            name: (identifier) @function))
 279
 280        (function_declarator
 281          declarator: (field_identifier) @function)
 282
 283        ; Types
 284
 285        ((namespace_identifier) @type
 286         (#match? @type "^[A-Z]"))
 287
 288        (auto) @type
 289
 290        ; Constants
 291
 292        (this) @variable.builtin
 293        (null "nullptr" @constant)
 294
 295        ; Keywords
 296
 297        [
 298         "catch"
 299         "class"
 300         "co_await"
 301         "co_return"
 302         "co_yield"
 303         "constexpr"
 304         "constinit"
 305         "consteval"
 306         "delete"
 307         "explicit"
 308         "final"
 309         "friend"
 310         "mutable"
 311         "namespace"
 312         "noexcept"
 313         "new"
 314         "override"
 315         "private"
 316         "protected"
 317         "public"
 318         "template"
 319         "throw"
 320         "try"
 321         "typename"
 322         "using"
 323         "concept"
 324         "requires"
 325         "virtual"
 326        ] @keyword
 327
 328        ; Strings
 329
 330        (raw_string_literal) @string
 331        """####,
 332        "elisp": ####"""
 333        ;; When several patterns capture the same node, the last one wins, so
 334        ;; a pattern that refines another must come after it.
 335
 336        ;; Special forms
 337        [
 338          "and"
 339          "catch"
 340          "cond"
 341          "condition-case"
 342          "defconst"
 343          "defvar"
 344          "function"
 345          "if"
 346          "interactive"
 347          "lambda"
 348          "let"
 349          "let*"
 350          "or"
 351          "prog1"
 352          "prog2"
 353          "progn"
 354          "quote"
 355          "save-current-buffer"
 356          "save-excursion"
 357          "save-restriction"
 358          "setq"
 359          "setq-default"
 360          "unwind-protect"
 361          "while"
 362        ] @keyword
 363
 364        ;; Function definitions
 365        [
 366         "defun"
 367         "defsubst"
 368         ] @keyword
 369        (function_definition name: (symbol) @function)
 370        (function_definition parameters: (list (symbol) @variable.parameter))
 371
 372        ;; Highlight macro definitions the same way as function definitions.
 373        "defmacro" @keyword
 374        (macro_definition name: (symbol) @function)
 375        (macro_definition parameters: (list (symbol) @variable.parameter))
 376
 377        ;; &optional and &rest are argument list markers, not parameters.
 378        ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Argument-List.html
 379        (function_definition
 380          parameters: (list (symbol) @keyword
 381            (#match? @keyword "^&")))
 382        (macro_definition
 383          parameters: (list (symbol) @keyword
 384            (#match? @keyword "^&")))
 385
 386        ;; A sharp quoted symbol is a function reference, e.g. #'foo.
 387        (function_quote (symbol) @function)
 388
 389        ;; The variable defined by defvar or defconst. The anchor restricts
 390        ;; this to the first symbol, leaving the initial value alone.
 391        (special_form
 392          [
 393            "defconst"
 394            "defvar"
 395          ]
 396          .
 397          (symbol) @variable)
 398
 399        ;; Variables bound by let and let*, written either as (let ((x 1)))
 400        ;; or as (let (x)).
 401        (special_form
 402          [
 403            "let"
 404            "let*"
 405          ]
 406          .
 407          (list
 408            [
 409              (symbol) @variable
 410              (list . (symbol) @variable)
 411            ]))
 412
 413        (comment) @comment
 414
 415        (integer) @number
 416        (float) @number
 417        ;; Characters are integers in Emacs Lisp, e.g. ?a is 97.
 418        (char) @number
 419
 420        (string) @string
 421
 422        ;; Docstrings are strings too, so these come after (string) @string.
 423        (function_definition docstring: (string) @string.documentation)
 424        (macro_definition docstring: (string) @string.documentation)
 425        ;; defvar and defconst take the docstring after the initial value, so
 426        ;; (defvar foo nil "Doc.") has one but (defvar foo "Value") does not.
 427        (special_form
 428          [
 429            "defconst"
 430            "defvar"
 431          ]
 432          .
 433          (symbol)
 434          .
 435          (_)
 436          .
 437          (string) @string.documentation)
 438
 439        ;; #$ is the name of the file being loaded.
 440        ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Read-Syntax.html
 441        (byte_compiled_file_name) @constant.builtin
 442
 443        [
 444          "("
 445          ")"
 446          "#("
 447          "#["
 448          "["
 449          "]"
 450        ] @punctuation.bracket
 451
 452        [
 453          "`"
 454          "#'"
 455          "'"
 456          ","
 457          ",@"
 458        ] @operator
 459
 460        ;; Highlight nil and t as constants, unlike other symbols
 461        [
 462          "nil"
 463          "t"
 464        ] @constant.builtin
 465
 466        ;; Keywords evaluate to themselves, so highlight them as constants too.
 467        ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Constant-Variables.html
 468        ((symbol) @constant
 469          (#match? @constant "^:"))
 470        """####,
 471        "go": ####"""
 472        ; Function calls
 473
 474        (call_expression
 475          function: (identifier) @function)
 476
 477        (call_expression
 478          function: (identifier) @function.builtin
 479          (#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$"))
 480
 481        (call_expression
 482          function: (selector_expression
 483            field: (field_identifier) @function.method))
 484
 485        ; Function definitions
 486
 487        (function_declaration
 488          name: (identifier) @function)
 489
 490        (method_declaration
 491          name: (field_identifier) @function.method)
 492
 493        ; Identifiers
 494
 495        (type_identifier) @type
 496        (field_identifier) @property
 497        (identifier) @variable
 498
 499        ; Operators
 500
 501        [
 502          "--"
 503          "-"
 504          "-="
 505          ":="
 506          "!"
 507          "!="
 508          "..."
 509          "*"
 510          "*"
 511          "*="
 512          "/"
 513          "/="
 514          "&"
 515          "&&"
 516          "&="
 517          "%"
 518          "%="
 519          "^"
 520          "^="
 521          "+"
 522          "++"
 523          "+="
 524          "<-"
 525          "<"
 526          "<<"
 527          "<<="
 528          "<="
 529          "="
 530          "=="
 531          ">"
 532          ">="
 533          ">>"
 534          ">>="
 535          "|"
 536          "|="
 537          "||"
 538          "~"
 539        ] @operator
 540
 541        ; Keywords
 542
 543        [
 544          "break"
 545          "case"
 546          "chan"
 547          "const"
 548          "continue"
 549          "default"
 550          "defer"
 551          "else"
 552          "fallthrough"
 553          "for"
 554          "func"
 555          "go"
 556          "goto"
 557          "if"
 558          "import"
 559          "interface"
 560          "map"
 561          "package"
 562          "range"
 563          "return"
 564          "select"
 565          "struct"
 566          "switch"
 567          "type"
 568          "var"
 569        ] @keyword
 570
 571        ; Literals
 572
 573        [
 574          (interpreted_string_literal)
 575          (raw_string_literal)
 576          (rune_literal)
 577        ] @string
 578
 579        (escape_sequence) @escape
 580
 581        [
 582          (int_literal)
 583          (float_literal)
 584          (imaginary_literal)
 585        ] @number
 586
 587        [
 588          (true)
 589          (false)
 590          (nil)
 591          (iota)
 592        ] @constant.builtin
 593
 594        (comment) @comment
 595        """####,
 596        "haskell": ####"""
 597        ; ----------------------------------------------------------------------------
 598        ; Parameters and variables
 599        ; NOTE: These are at the top, so that they have low priority,
 600        ; and don't override destructured parameters
 601        (variable) @variable
 602
 603        (pattern/wildcard) @variable
 604
 605        (decl/function
 606          patterns: (patterns
 607            (_) @variable.parameter))
 608
 609        (expression/lambda
 610          (_)+ @variable.parameter
 611          "->")
 612
 613        (decl/function
 614          (infix
 615            (pattern) @variable.parameter))
 616
 617        ; ----------------------------------------------------------------------------
 618        ; Literals and comments
 619        (integer) @number
 620
 621        (negation) @number
 622
 623        (expression/literal
 624          (float)) @number.float
 625
 626        (char) @character
 627
 628        (string) @string
 629
 630        (unit) @string.special.symbol ; unit, as in ()
 631
 632        (comment) @comment
 633
 634        ((haddock) @comment.documentation)
 635
 636        ; ----------------------------------------------------------------------------
 637        ; Punctuation
 638        [
 639          "("
 640          ")"
 641          "{"
 642          "}"
 643          "["
 644          "]"
 645        ] @punctuation.bracket
 646
 647        [
 648          ","
 649          ";"
 650        ] @punctuation.delimiter
 651
 652        ; ----------------------------------------------------------------------------
 653        ; Keywords, operators, includes
 654        [
 655          "forall"
 656          ; "∀" ; utf-8 is not cross-platform safe
 657        ] @keyword.repeat
 658
 659        (pragma) @keyword.directive
 660
 661        [
 662          "if"
 663          "then"
 664          "else"
 665          "case"
 666          "cases"
 667          "of"
 668        ] @keyword.conditional
 669
 670        [
 671          "import"
 672          "qualified"
 673          "module"
 674        ] @keyword.import
 675
 676        [
 677          (operator)
 678          (constructor_operator)
 679          (all_names)
 680          (wildcard)
 681          "."
 682          ".."
 683          "="
 684          "|"
 685          "::"
 686          "=>"
 687          "->"
 688          "<-"
 689          "\\"
 690          "`"
 691          "@"
 692        ] @operator
 693
 694        ; TODO broken, also huh?
 695        ; ((qualified_module
 696        ;   (module) @constructor)
 697        ;   .
 698        ;   (module))
 699
 700        (module
 701          (module_id) @module)
 702
 703        [
 704          "where"
 705          "let"
 706          "in"
 707          "class"
 708          "instance"
 709          "pattern"
 710          "data"
 711          "newtype"
 712          "family"
 713          "type"
 714          "as"
 715          "hiding"
 716          "deriving"
 717          "via"
 718          "stock"
 719          "anyclass"
 720          "do"
 721          "mdo"
 722          "rec"
 723          "infix"
 724          "infixl"
 725          "infixr"
 726        ] @keyword
 727
 728        ; ----------------------------------------------------------------------------
 729        ; Functions and variables
 730        [
 731          (decl/function name: (variable) @function)
 732          (decl/bind name: (variable) @function)
 733          (decl/signature name: (variable) @function)
 734          (decl/signature names: (binding_list (variable) @function))
 735        ]
 736
 737        (decl/bind
 738          name: (variable) @variable)
 739
 740        ; Consider signatures (and accompanying functions)
 741        ; with only one value on the rhs as variables
 742        (decl/signature
 743          name: (variable) @variable
 744          type: (type))
 745
 746        ((decl/signature
 747          name: (variable) @_name
 748          type: (type))
 749          .
 750          [
 751            (decl/function name: (variable) @variable)
 752            (decl/bind name: (variable) @variable)
 753          ]
 754            match: (_)
 755          (#eq? @_name @variable))
 756
 757        ; but consider a type that involves 'IO' a decl/function
 758        (decl/signature
 759          name: (variable) @function
 760          type: (type/apply
 761            constructor: (name) @_type)
 762          (#eq? @_type "IO"))
 763
 764        ((decl/signature
 765          name: (variable) @_name
 766          type: (type/apply
 767            constructor: (name) @_type)
 768          (#eq? @_type "IO"))
 769          .
 770          [
 771            (decl/function name: (variable) @function)
 772            (decl/bind name: (variable) @function)
 773          ]
 774            match: (_)
 775          (#eq? @_name @function))
 776
 777        ((decl/signature) @function
 778          .
 779          (decl/function
 780            name: (variable) @function))
 781
 782        (decl/bind
 783          name: (variable) @function
 784          (match
 785            expression: (expression/lambda)))
 786
 787        ; view patterns
 788        (view_pattern
 789          [
 790            (expression/variable) @function.call
 791            (expression/qualified
 792              (variable) @function.call)
 793          ])
 794
 795        ; consider infix functions as operators
 796        (infix_id
 797          [
 798            (variable) @operator
 799            (qualified
 800              (variable) @operator)
 801          ])
 802
 803        ; decl/function calls with an infix operator
 804        ; e.g. func <$> a <*> b
 805        (infix
 806          [
 807            (variable) @function.call
 808            (qualified
 809              ((module) @module
 810                (variable) @function.call))
 811          ]
 812          .
 813          (operator))
 814
 815        ; infix operators applied to variables
 816        ((expression/variable) @variable
 817          .
 818          (operator))
 819
 820        ((operator)
 821          .
 822          [
 823            (expression/variable) @variable
 824            (expression/qualified
 825              (variable) @variable)
 826          ])
 827
 828        ; decl/function calls with infix operators
 829        ([
 830            (expression/variable) @function.call
 831            (expression/qualified
 832              (variable) @function.call)
 833          ]
 834          .
 835          (operator) @_op
 836          (#any-of? @_op "$" "<$>" ">>=" "=<<"))
 837
 838        ; right hand side of infix operator
 839        ((infix
 840          [
 841            (operator)
 842            (infix_id (variable))
 843          ] ; infix or `func`
 844          .
 845          [
 846            (variable) @function.call
 847            (qualified
 848              (variable) @function.call)
 849          ])
 850          .
 851          (operator) @_op
 852          (#any-of? @_op "$" "<$>" "=<<"))
 853
 854        ; decl/function composition, arrows, monadic composition (lhs)
 855        (
 856          [
 857            (expression/variable) @function
 858            (expression/qualified
 859              (variable) @function)
 860          ]
 861          .
 862          (operator) @_op
 863          (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
 864
 865        ; right hand side of infix operator
 866        ((infix
 867          [
 868            (operator)
 869            (infix_id (variable))
 870          ] ; infix or `func`
 871          .
 872          [
 873            (variable) @function
 874            (qualified
 875              (variable) @function)
 876          ])
 877          .
 878          (operator) @_op
 879          (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
 880
 881        ; function composition, arrows, monadic composition (rhs)
 882        ((operator) @_op
 883          .
 884          [
 885            (expression/variable) @function
 886            (expression/qualified
 887              (variable) @function)
 888          ]
 889          (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
 890
 891        ; function defined in terms of a function composition
 892        (decl/function
 893          name: (variable) @function
 894          (match
 895            expression: (infix
 896              operator: (operator) @_op
 897              (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))))
 898
 899        (apply
 900          [
 901            (expression/variable) @function.call
 902            (expression/qualified
 903              (variable) @function.call)
 904          ])
 905
 906        ; function compositions, in parentheses, applied
 907        ; lhs
 908        (apply
 909          .
 910          (expression/parens
 911            (infix
 912              [
 913                (variable) @function.call
 914                (qualified
 915                  (variable) @function.call)
 916              ]
 917              .
 918              (operator))))
 919
 920        ; rhs
 921        (apply
 922          .
 923          (expression/parens
 924            (infix
 925              (operator)
 926              .
 927              [
 928                (variable) @function.call
 929                (qualified
 930                  (variable) @function.call)
 931              ])))
 932
 933        ; variables being passed to a function call
 934        (apply
 935          (_)
 936          .
 937          [
 938            (expression/variable) @variable
 939            (expression/qualified
 940              (variable) @variable)
 941          ])
 942
 943        ; main is always a function
 944        ; (this prevents `main = undefined` from being highlighted as a variable)
 945        (decl/bind
 946          name: (variable) @function
 947          (#eq? @function "main"))
 948
 949        ; scoped function types (func :: a -> b)
 950        (signature
 951          pattern: (pattern/variable) @function
 952          type: (quantified_type))
 953
 954        ; signatures that have a function type
 955        ; + binds that follow them
 956        (decl/signature
 957          name: (variable) @function
 958          type: (quantified_type))
 959
 960        ((decl/signature
 961          name: (variable) @_name
 962          type: (quantified_type))
 963          .
 964          (decl/bind
 965            (variable) @function)
 966          (#eq? @function @_name))
 967
 968        ; ----------------------------------------------------------------------------
 969        ; Types
 970        (name) @type
 971
 972        (type/star) @type
 973
 974        (variable) @type
 975
 976        (constructor) @constructor
 977
 978        ; True or False
 979        ((constructor) @boolean
 980          (#any-of? @boolean "True" "False"))
 981
 982        ; otherwise (= True)
 983        ((variable) @boolean
 984          (#eq? @boolean "otherwise"))
 985
 986        ; ----------------------------------------------------------------------------
 987        ; Quasi-quotes
 988        (quoter) @function.call
 989
 990        (quasiquote
 991          [
 992            (quoter) @_name
 993            (_
 994              (variable) @_name)
 995          ]
 996          (#eq? @_name "qq")
 997          (quasiquote_body) @string)
 998
 999        (quasiquote
1000          (_
1001            (variable) @_name)
1002          (#eq? @_name "qq")
1003          (quasiquote_body) @string)
1004
1005        ; namespaced quasi-quoter
1006        (quasiquote
1007          (_
1008            (module) @module
1009            .
1010            (variable) @function.call))
1011
1012        ; Highlighting of quasiquote_body for other languages is handled by injections.scm
1013        ; ----------------------------------------------------------------------------
1014        ; Exceptions/error handling
1015        ((variable) @keyword.exception
1016          (#any-of? @keyword.exception
1017            "error" "undefined" "try" "tryJust" "tryAny" "catch" "catches" "catchJust" "handle" "handleJust"
1018            "throw" "throwIO" "throwTo" "throwError" "ioError" "mask" "mask_" "uninterruptibleMask"
1019            "uninterruptibleMask_" "bracket" "bracket_" "bracketOnErrorSource" "finally" "fail"
1020            "onException" "expectationFailure"))
1021
1022        ; ----------------------------------------------------------------------------
1023        ; Debugging
1024        ((variable) @keyword.debug
1025          (#any-of? @keyword.debug
1026            "trace" "traceId" "traceShow" "traceShowId" "traceWith" "traceShowWith" "traceStack" "traceIO"
1027            "traceM" "traceShowM" "traceEvent" "traceEventWith" "traceEventIO" "flushEventLog" "traceMarker"
1028            "traceMarkerIO"))
1029
1030        ; ----------------------------------------------------------------------------
1031        ; Fields
1032
1033        (field_name
1034          (variable) @variable.member)
1035
1036        (import_name
1037          (name)
1038          .
1039          (children
1040            (variable) @variable.member))
1041
1042
1043        ; ----------------------------------------------------------------------------
1044        ; Spell checking
1045        (comment) @spell
1046        """####,
1047        "java": ####"""
1048        ; Variables
1049
1050        (identifier) @variable
1051
1052        ; Methods
1053
1054        (method_declaration
1055          name: (identifier) @function.method)
1056        (method_invocation
1057          name: (identifier) @function.method)
1058        (super) @function.builtin
1059
1060        ; Annotations
1061
1062        (annotation
1063          name: (identifier) @attribute)
1064        (marker_annotation
1065          name: (identifier) @attribute)
1066
1067        "@" @operator
1068
1069        ; Types
1070
1071        (type_identifier) @type
1072
1073        (interface_declaration
1074          name: (identifier) @type)
1075        (class_declaration
1076          name: (identifier) @type)
1077        (enum_declaration
1078          name: (identifier) @type)
1079
1080        ((field_access
1081          object: (identifier) @type)
1082         (#match? @type "^[A-Z]"))
1083        ((scoped_identifier
1084          scope: (identifier) @type)
1085         (#match? @type "^[A-Z]"))
1086        ((method_invocation
1087          object: (identifier) @type)
1088         (#match? @type "^[A-Z]"))
1089        ((method_reference
1090          . (identifier) @type)
1091         (#match? @type "^[A-Z]"))
1092
1093        (constructor_declaration
1094          name: (identifier) @type)
1095
1096        [
1097          (boolean_type)
1098          (integral_type)
1099          (floating_point_type)
1100          (floating_point_type)
1101          (void_type)
1102        ] @type.builtin
1103
1104        ; Constants
1105
1106        ((identifier) @constant
1107         (#match? @constant "^_*[A-Z][A-Z\\d_]+$"))
1108
1109        ; Builtins
1110
1111        (this) @variable.builtin
1112
1113        ; Literals
1114
1115        [
1116          (hex_integer_literal)
1117          (decimal_integer_literal)
1118          (octal_integer_literal)
1119          (decimal_floating_point_literal)
1120          (hex_floating_point_literal)
1121        ] @number
1122
1123        [
1124          (character_literal)
1125          (string_literal)
1126        ] @string
1127        (escape_sequence) @string.escape
1128
1129        [
1130          (true)
1131          (false)
1132          (null_literal)
1133        ] @constant.builtin
1134
1135        [
1136          (line_comment)
1137          (block_comment)
1138        ] @comment
1139
1140        ; Keywords
1141
1142        [
1143          "abstract"
1144          "assert"
1145          "break"
1146          "case"
1147          "catch"
1148          "class"
1149          "continue"
1150          "default"
1151          "do"
1152          "else"
1153          "enum"
1154          "exports"
1155          "extends"
1156          "final"
1157          "finally"
1158          "for"
1159          "if"
1160          "implements"
1161          "import"
1162          "instanceof"
1163          "interface"
1164          "module"
1165          "native"
1166          "new"
1167          "non-sealed"
1168          "open"
1169          "opens"
1170          "package"
1171          "permits"
1172          "private"
1173          "protected"
1174          "provides"
1175          "public"
1176          "requires"
1177          "record"
1178          "return"
1179          "sealed"
1180          "static"
1181          "strictfp"
1182          "switch"
1183          "synchronized"
1184          "throw"
1185          "throws"
1186          "to"
1187          "transient"
1188          "transitive"
1189          "try"
1190          "uses"
1191          "volatile"
1192          "when"
1193          "while"
1194          "with"
1195          "yield"
1196        ] @keyword
1197        """####,
1198        "javascript": ####"""
1199        ; Variables
1200        ;----------
1201
1202        (identifier) @variable
1203
1204        ; Properties
1205        ;-----------
1206
1207        (property_identifier) @property
1208
1209        ; Function and method definitions
1210        ;--------------------------------
1211
1212        (function_expression
1213          name: (identifier) @function)
1214        (function_declaration
1215          name: (identifier) @function)
1216        (method_definition
1217          name: (property_identifier) @function.method)
1218
1219        (pair
1220          key: (property_identifier) @function.method
1221          value: [(function_expression) (arrow_function)])
1222
1223        (assignment_expression
1224          left: (member_expression
1225            property: (property_identifier) @function.method)
1226          right: [(function_expression) (arrow_function)])
1227
1228        (variable_declarator
1229          name: (identifier) @function
1230          value: [(function_expression) (arrow_function)])
1231
1232        (assignment_expression
1233          left: (identifier) @function
1234          right: [(function_expression) (arrow_function)])
1235
1236        ; Function and method calls
1237        ;--------------------------
1238
1239        (call_expression
1240          function: (identifier) @function)
1241
1242        (call_expression
1243          function: (member_expression
1244            property: (property_identifier) @function.method))
1245
1246        ; Special identifiers
1247        ;--------------------
1248
1249        ((identifier) @constructor
1250         (#match? @constructor "^[A-Z]"))
1251
1252        ([
1253            (identifier)
1254            (shorthand_property_identifier)
1255            (shorthand_property_identifier_pattern)
1256         ] @constant
1257         (#match? @constant "^[A-Z_][A-Z\\d_]+$"))
1258
1259        ((identifier) @variable.builtin
1260         (#match? @variable.builtin "^(arguments|module|console|window|document)$")
1261         (#is-not? local))
1262
1263        ((identifier) @function.builtin
1264         (#eq? @function.builtin "require")
1265         (#is-not? local))
1266
1267        ; Literals
1268        ;---------
1269
1270        (this) @variable.builtin
1271        (super) @variable.builtin
1272
1273        [
1274          (true)
1275          (false)
1276          (null)
1277          (undefined)
1278        ] @constant.builtin
1279
1280        (comment) @comment
1281
1282        [
1283          (string)
1284          (template_string)
1285        ] @string
1286
1287        (regex) @string.special
1288        (number) @number
1289
1290        ; Tokens
1291        ;-------
1292
1293        [
1294          ";"
1295          (optional_chain)
1296          "."
1297          ","
1298        ] @punctuation.delimiter
1299
1300        [
1301          "-"
1302          "--"
1303          "-="
1304          "+"
1305          "++"
1306          "+="
1307          "*"
1308          "*="
1309          "**"
1310          "**="
1311          "/"
1312          "/="
1313          "%"
1314          "%="
1315          "<"
1316          "<="
1317          "<<"
1318          "<<="
1319          "="
1320          "=="
1321          "==="
1322          "!"
1323          "!="
1324          "!=="
1325          "=>"
1326          ">"
1327          ">="
1328          ">>"
1329          ">>="
1330          ">>>"
1331          ">>>="
1332          "~"
1333          "^"
1334          "&"
1335          "|"
1336          "^="
1337          "&="
1338          "|="
1339          "&&"
1340          "||"
1341          "??"
1342          "&&="
1343          "||="
1344          "??="
1345        ] @operator
1346
1347        [
1348          "("
1349          ")"
1350          "["
1351          "]"
1352          "{"
1353          "}"
1354        ]  @punctuation.bracket
1355
1356        (template_substitution
1357          "${" @punctuation.special
1358          "}" @punctuation.special) @embedded
1359
1360        [
1361          "as"
1362          "async"
1363          "await"
1364          "break"
1365          "case"
1366          "catch"
1367          "class"
1368          "const"
1369          "continue"
1370          "debugger"
1371          "default"
1372          "delete"
1373          "do"
1374          "else"
1375          "export"
1376          "extends"
1377          "finally"
1378          "for"
1379          "from"
1380          "function"
1381          "get"
1382          "if"
1383          "import"
1384          "in"
1385          "instanceof"
1386          "let"
1387          "new"
1388          "of"
1389          "return"
1390          "set"
1391          "static"
1392          "switch"
1393          "target"
1394          "throw"
1395          "try"
1396          "typeof"
1397          "var"
1398          "void"
1399          "while"
1400          "with"
1401          "yield"
1402        ] @keyword
1403        """####,
1404        "json": ####"""
1405        (pair
1406          key: (_) @string.special.key)
1407
1408        (string) @string
1409
1410        (number) @number
1411
1412        [
1413          (null)
1414          (true)
1415          (false)
1416        ] @constant.builtin
1417
1418        (escape_sequence) @escape
1419
1420        (comment) @comment
1421        """####,
1422        "lua": ####"""
1423        ; Keywords
1424        "return" @keyword.return
1425
1426        [
1427          "goto"
1428          "in"
1429          "local"
1430          "global"
1431        ] @keyword
1432
1433        (label_statement) @label
1434
1435        (break_statement) @keyword
1436
1437        (do_statement
1438          [
1439            "do"
1440            "end"
1441          ] @keyword)
1442
1443        (while_statement
1444          [
1445            "while"
1446            "do"
1447            "end"
1448          ] @repeat)
1449
1450        (repeat_statement
1451          [
1452            "repeat"
1453            "until"
1454          ] @repeat)
1455
1456        (if_statement
1457          [
1458            "if"
1459            "elseif"
1460            "else"
1461            "then"
1462            "end"
1463          ] @conditional)
1464
1465        (elseif_statement
1466          [
1467            "elseif"
1468            "then"
1469            "end"
1470          ] @conditional)
1471
1472        (else_statement
1473          [
1474            "else"
1475            "end"
1476          ] @conditional)
1477
1478        (for_statement
1479          [
1480            "for"
1481            "do"
1482            "end"
1483          ] @repeat)
1484
1485        (function_declaration
1486          [
1487            "function"
1488            "end"
1489          ] @keyword.function)
1490
1491        (function_definition
1492          [
1493            "function"
1494            "end"
1495          ] @keyword.function)
1496
1497        ; Operators
1498        (binary_expression
1499          operator: _ @operator)
1500
1501        (unary_expression
1502          operator: _ @operator)
1503
1504        "=" @operator
1505
1506        [
1507          "and"
1508          "not"
1509          "or"
1510        ] @keyword.operator
1511
1512        ; Punctuations
1513        [
1514          ";"
1515          ":"
1516          ","
1517          "."
1518        ] @punctuation.delimiter
1519
1520        ; Brackets
1521        [
1522          "("
1523          ")"
1524          "["
1525          "]"
1526          "{"
1527          "}"
1528        ] @punctuation.bracket
1529
1530        ; Variables
1531        (identifier) @variable
1532
1533        ((identifier) @variable.builtin
1534          (#eq? @variable.builtin "self"))
1535
1536        (variable_list
1537          (attribute
1538            "<" @punctuation.bracket
1539            (identifier) @attribute
1540            ">" @punctuation.bracket))
1541
1542        ; Constants
1543        ((identifier) @constant
1544          (#match? @constant "^[A-Z][A-Z_0-9]*$"))
1545
1546        (vararg_expression) @constant
1547
1548        (nil) @constant.builtin
1549
1550        [
1551          (false)
1552          (true)
1553        ] @boolean
1554
1555        ; Tables
1556        (field
1557          name: (identifier) @field)
1558
1559        (dot_index_expression
1560          field: (identifier) @field)
1561
1562        (table_constructor
1563          [
1564            "{"
1565            "}"
1566          ] @constructor)
1567
1568        ; Functions
1569        (parameters
1570          (identifier) @parameter)
1571
1572        (function_declaration
1573          name: [
1574            (identifier) @function
1575            (dot_index_expression
1576              field: (identifier) @function)
1577          ])
1578
1579        (function_declaration
1580          name: (method_index_expression
1581            method: (identifier) @method))
1582
1583        (assignment_statement
1584          (variable_list
1585            .
1586            name: [
1587              (identifier) @function
1588              (dot_index_expression
1589                field: (identifier) @function)
1590            ])
1591          (expression_list
1592            .
1593            value: (function_definition)))
1594
1595        (table_constructor
1596          (field
1597            name: (identifier) @function
1598            value: (function_definition)))
1599
1600        (function_call
1601          name: [
1602            (identifier) @function.call
1603            (dot_index_expression
1604              field: (identifier) @function.call)
1605            (method_index_expression
1606              method: (identifier) @method.call)
1607          ])
1608
1609        (function_call
1610          (identifier) @function.builtin
1611          (#any-of? @function.builtin
1612            ; built-in functions in Lua 5.1
1613            "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile"
1614            "loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawset" "require"
1615            "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall"))
1616
1617        ; Others
1618        (comment) @comment
1619
1620        (hash_bang_line) @preproc
1621
1622        (number) @number
1623
1624        (string) @string
1625
1626        (escape_sequence) @string.escape
1627        """####,
1628        "python": ####"""
1629        ; Identifier naming conventions
1630
1631        (identifier) @variable
1632
1633        ((identifier) @constructor
1634         (#match? @constructor "^[A-Z]"))
1635
1636        ((identifier) @constant
1637         (#match? @constant "^[A-Z][A-Z_]*$"))
1638
1639        ; Function calls
1640
1641        (decorator) @function
1642        (decorator
1643          (identifier) @function)
1644
1645        (call
1646          function: (attribute attribute: (identifier) @function.method))
1647        (call
1648          function: (identifier) @function)
1649
1650        ; Builtin functions
1651
1652        ((call
1653          function: (identifier) @function.builtin)
1654         (#match?
1655           @function.builtin
1656           "^(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__)$"))
1657
1658        ; Function definitions
1659
1660        (function_definition
1661          name: (identifier) @function)
1662
1663        (attribute attribute: (identifier) @property)
1664        (type (identifier) @type)
1665
1666        ; Literals
1667
1668        [
1669          (none)
1670          (true)
1671          (false)
1672        ] @constant.builtin
1673
1674        [
1675          (integer)
1676          (float)
1677        ] @number
1678
1679        (comment) @comment
1680        (string) @string
1681        (escape_sequence) @escape
1682
1683        (interpolation
1684          "{" @punctuation.special
1685          "}" @punctuation.special) @embedded
1686
1687        [
1688          "-"
1689          "-="
1690          "!="
1691          "*"
1692          "**"
1693          "**="
1694          "*="
1695          "/"
1696          "//"
1697          "//="
1698          "/="
1699          "&"
1700          "&="
1701          "%"
1702          "%="
1703          "^"
1704          "^="
1705          "+"
1706          "->"
1707          "+="
1708          "<"
1709          "<<"
1710          "<<="
1711          "<="
1712          "<>"
1713          "="
1714          ":="
1715          "=="
1716          ">"
1717          ">="
1718          ">>"
1719          ">>="
1720          "|"
1721          "|="
1722          "~"
1723          "@="
1724          "and"
1725          "in"
1726          "is"
1727          "not"
1728          "or"
1729          "is not"
1730          "not in"
1731        ] @operator
1732
1733        [
1734          "as"
1735          "assert"
1736          "async"
1737          "await"
1738          "break"
1739          "class"
1740          "continue"
1741          "def"
1742          "del"
1743          "elif"
1744          "else"
1745          "except"
1746          "exec"
1747          "finally"
1748          "for"
1749          "from"
1750          "global"
1751          "if"
1752          "import"
1753          "lambda"
1754          "nonlocal"
1755          "pass"
1756          "print"
1757          "raise"
1758          "return"
1759          "try"
1760          "while"
1761          "with"
1762          "yield"
1763          "match"
1764          "case"
1765        ] @keyword
1766        """####,
1767        "r": ####"""
1768        ; highlights.scm
1769
1770        ; Literals
1771
1772        (integer) @number
1773        (float) @number
1774        (complex) @number
1775
1776        (string) @string
1777        (string (string_content (escape_sequence) @string.escape))
1778
1779        ; Comments
1780
1781        (comment) @comment
1782
1783        ; Operators
1784
1785        [
1786          "?" ":=" "=" "<-" "<<-" "->" "->>"
1787          "~" "|>" "||" "|" "&&" "&"
1788          "<" "<=" ">" ">=" "==" "!="
1789          "+" "-" "*" "/" "::" ":::"
1790          "**" "^" "$" "@" ":" "!"
1791          "special"
1792        ] @operator
1793
1794        ; Punctuation
1795
1796        [
1797          "("  ")"
1798          "{"  "}"
1799          "["  "]"
1800          "[[" "]]"
1801        ] @punctuation.bracket
1802
1803        (comma) @punctuation.delimiter
1804
1805        ; Variables
1806
1807        (identifier) @variable
1808
1809        ; Functions
1810
1811        (binary_operator
1812            lhs: (identifier) @function
1813            operator: "<-"
1814            rhs: (function_definition)
1815        )
1816
1817        (binary_operator
1818            lhs: (identifier) @function
1819            operator: "="
1820            rhs: (function_definition)
1821        )
1822
1823        ; Calls
1824
1825        (call function: (identifier) @function)
1826
1827        ; - `return` is just a regular identifier in our grammar (#189), but people
1828        ;   expect `return()` to be highlighted
1829        ; - We feel confident that we can use `#eq?` here, as other grammars use
1830        ;   `#eq?` and `#match?` predicates already, even though support for predicates
1831        ;   is dependent on the library that binds to tree-sitter's C library, not the
1832        ;   C library itself.
1833        ;   https://github.com/tree-sitter/tree-sitter-javascript/blob/58404d8cf191d69f2674a8fd507bd5776f46cb11/queries/highlights.scm#L65-L67
1834        ;   https://github.com/tree-sitter/tree-sitter-rust/blob/77a3747266f4d621d0757825e6b11edcbf991ca5/queries/highlights.scm#L9-L11
1835        ; - Placed after `(call function: (identifier) @function)` for correct precedence
1836        (
1837            (call function: (identifier) @keyword)
1838            (#eq? @keyword "return")
1839        )
1840
1841        ; Parameters
1842
1843        (parameters (parameter name: (identifier) @variable.parameter))
1844        (arguments (argument name: (identifier) @variable.parameter))
1845
1846        ; Namespace
1847
1848        (namespace_operator lhs: (identifier) @namespace)
1849
1850        (call
1851            function: (namespace_operator rhs: (identifier) @function)
1852        )
1853
1854        ; Keywords
1855
1856        (function_definition name: "function" @keyword.function)
1857        (function_definition name: "\\" @operator)
1858
1859        [
1860          "in"
1861          (next)
1862          (break)
1863        ] @keyword
1864
1865        [
1866          "if"
1867          "else"
1868        ] @conditional
1869
1870        [
1871          "while"
1872          "repeat"
1873          "for"
1874        ] @repeat
1875
1876        [
1877          (true)
1878          (false)
1879        ] @boolean
1880
1881        [
1882          (null)
1883          (inf)
1884          (nan)
1885          (na)
1886          (dots)
1887          (dot_dot_i)
1888        ] @constant.builtin
1889
1890        ; Error
1891
1892        (ERROR) @error
1893        """####,
1894        "ruby": ####"""
1895        (identifier) @variable
1896
1897        ((identifier) @function.method
1898         (#is-not? local))
1899
1900        [
1901          "alias"
1902          "and"
1903          "begin"
1904          "break"
1905          "case"
1906          "class"
1907          "def"
1908          "do"
1909          "else"
1910          "elsif"
1911          "end"
1912          "ensure"
1913          "for"
1914          "if"
1915          "in"
1916          "module"
1917          "next"
1918          "or"
1919          "rescue"
1920          "retry"
1921          "return"
1922          "then"
1923          "unless"
1924          "until"
1925          "when"
1926          "while"
1927          "yield"
1928        ] @keyword
1929
1930        ((identifier) @keyword
1931         (#match? @keyword "^(private|protected|public)$"))
1932
1933        (constant) @constructor
1934
1935        ; Function calls
1936
1937        "defined?" @function.method.builtin
1938
1939        (call
1940          method: [(identifier) (constant)] @function.method)
1941
1942        ((identifier) @function.method.builtin
1943         (#eq? @function.method.builtin "require"))
1944
1945        ; Function definitions
1946
1947        (alias (identifier) @function.method)
1948        (setter (identifier) @function.method)
1949        (method name: [(identifier) (constant)] @function.method)
1950        (singleton_method name: [(identifier) (constant)] @function.method)
1951
1952        ; Identifiers
1953
1954        [
1955          (class_variable)
1956          (instance_variable)
1957        ] @property
1958
1959        ((identifier) @constant.builtin
1960         (#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
1961
1962        (file) @constant.builtin
1963        (line) @constant.builtin
1964        (encoding) @constant.builtin
1965
1966        (hash_splat_nil
1967          "**" @operator) @constant.builtin
1968
1969        ((constant) @constant
1970         (#match? @constant "^[A-Z\\d_]+$"))
1971
1972        [
1973          (self)
1974          (super)
1975        ] @variable.builtin
1976
1977        (block_parameter (identifier) @variable.parameter)
1978        (block_parameters (identifier) @variable.parameter)
1979        (destructured_parameter (identifier) @variable.parameter)
1980        (hash_splat_parameter (identifier) @variable.parameter)
1981        (lambda_parameters (identifier) @variable.parameter)
1982        (method_parameters (identifier) @variable.parameter)
1983        (splat_parameter (identifier) @variable.parameter)
1984
1985        (keyword_parameter name: (identifier) @variable.parameter)
1986        (optional_parameter name: (identifier) @variable.parameter)
1987
1988        ; Literals
1989
1990        [
1991          (string)
1992          (bare_string)
1993          (subshell)
1994          (heredoc_body)
1995          (heredoc_beginning)
1996        ] @string
1997
1998        [
1999          (simple_symbol)
2000          (delimited_symbol)
2001          (hash_key_symbol)
2002          (bare_symbol)
2003        ] @string.special.symbol
2004
2005        (regex) @string.special.regex
2006        (escape_sequence) @escape
2007
2008        [
2009          (integer)
2010          (float)
2011        ] @number
2012
2013        [
2014          (nil)
2015          (true)
2016          (false)
2017        ] @constant.builtin
2018
2019        (interpolation
2020          "#{" @punctuation.special
2021          "}" @punctuation.special) @embedded
2022
2023        (comment) @comment
2024
2025        ; Operators
2026
2027        [
2028        "="
2029        "=>"
2030        "->"
2031        ] @operator
2032
2033        [
2034          ","
2035          ";"
2036          "."
2037        ] @punctuation.delimiter
2038
2039        [
2040          "("
2041          ")"
2042          "["
2043          "]"
2044          "{"
2045          "}"
2046          "%w("
2047          "%i("
2048        ] @punctuation.bracket
2049        """####,
2050        "rust": ####"""
2051        ; Identifiers
2052
2053        (type_identifier) @type
2054        (primitive_type) @type.builtin
2055        (field_identifier) @property
2056
2057        ; Identifier conventions
2058
2059        ; Assume all-caps names are constants
2060        ((identifier) @constant
2061         (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
2062
2063        ; Assume uppercase names are enum constructors
2064        ((identifier) @constructor
2065         (#match? @constructor "^[A-Z]"))
2066
2067        ; Assume that uppercase names in paths are types
2068        ((scoped_identifier
2069          path: (identifier) @type)
2070         (#match? @type "^[A-Z]"))
2071        ((scoped_identifier
2072          path: (scoped_identifier
2073            name: (identifier) @type))
2074         (#match? @type "^[A-Z]"))
2075        ((scoped_type_identifier
2076          path: (identifier) @type)
2077         (#match? @type "^[A-Z]"))
2078        ((scoped_type_identifier
2079          path: (scoped_identifier
2080            name: (identifier) @type))
2081         (#match? @type "^[A-Z]"))
2082
2083        ; Assume all qualified names in struct patterns are enum constructors. (They're
2084        ; either that, or struct names; highlighting both as constructors seems to be
2085        ; the less glaring choice of error, visually.)
2086        (struct_pattern
2087          type: (scoped_type_identifier
2088            name: (type_identifier) @constructor))
2089
2090        ; Function calls
2091
2092        (call_expression
2093          function: (identifier) @function)
2094        (call_expression
2095          function: (field_expression
2096            field: (field_identifier) @function.method))
2097        (call_expression
2098          function: (scoped_identifier
2099            "::"
2100            name: (identifier) @function))
2101
2102        (generic_function
2103          function: (identifier) @function)
2104        (generic_function
2105          function: (scoped_identifier
2106            name: (identifier) @function))
2107        (generic_function
2108          function: (field_expression
2109            field: (field_identifier) @function.method))
2110
2111        (macro_invocation
2112          macro: (identifier) @function.macro
2113          "!" @function.macro)
2114
2115        ; Function definitions
2116
2117        (function_item (identifier) @function)
2118        (function_signature_item (identifier) @function)
2119
2120        (line_comment) @comment
2121        (block_comment) @comment
2122
2123        (line_comment (doc_comment)) @comment.documentation
2124        (block_comment (doc_comment)) @comment.documentation
2125
2126        "(" @punctuation.bracket
2127        ")" @punctuation.bracket
2128        "[" @punctuation.bracket
2129        "]" @punctuation.bracket
2130        "{" @punctuation.bracket
2131        "}" @punctuation.bracket
2132
2133        (type_arguments
2134          "<" @punctuation.bracket
2135          ">" @punctuation.bracket)
2136        (type_parameters
2137          "<" @punctuation.bracket
2138          ">" @punctuation.bracket)
2139
2140        "::" @punctuation.delimiter
2141        ":" @punctuation.delimiter
2142        "." @punctuation.delimiter
2143        "," @punctuation.delimiter
2144        ";" @punctuation.delimiter
2145
2146        (parameter (identifier) @variable.parameter)
2147
2148        (lifetime (identifier) @label)
2149
2150        "as" @keyword
2151        "async" @keyword
2152        "await" @keyword
2153        "break" @keyword
2154        "const" @keyword
2155        "continue" @keyword
2156        "default" @keyword
2157        "dyn" @keyword
2158        "else" @keyword
2159        "enum" @keyword
2160        "extern" @keyword
2161        "fn" @keyword
2162        "for" @keyword
2163        "gen" @keyword
2164        "if" @keyword
2165        "impl" @keyword
2166        "in" @keyword
2167        "let" @keyword
2168        "loop" @keyword
2169        "macro_rules!" @keyword
2170        "match" @keyword
2171        "mod" @keyword
2172        "move" @keyword
2173        "pub" @keyword
2174        "raw" @keyword
2175        "ref" @keyword
2176        "return" @keyword
2177        "static" @keyword
2178        "struct" @keyword
2179        "trait" @keyword
2180        "type" @keyword
2181        "union" @keyword
2182        "unsafe" @keyword
2183        "use" @keyword
2184        "where" @keyword
2185        "while" @keyword
2186        "yield" @keyword
2187        (crate) @keyword
2188        (mutable_specifier) @keyword
2189        (use_list (self) @keyword)
2190        (scoped_use_list (self) @keyword)
2191        (scoped_identifier (self) @keyword)
2192        (super) @keyword
2193
2194        (self) @variable.builtin
2195
2196        (char_literal) @string
2197        (string_literal) @string
2198        (raw_string_literal) @string
2199
2200        (boolean_literal) @constant.builtin
2201        (integer_literal) @constant.builtin
2202        (float_literal) @constant.builtin
2203
2204        (escape_sequence) @escape
2205
2206        (attribute_item) @attribute
2207        (inner_attribute_item) @attribute
2208
2209        "*" @operator
2210        "&" @operator
2211        "'" @operator
2212        """####,
2213        "scheme": ####"""
2214        ["(" ")" "[" "]" "{" "}"] @punctuation.bracket
2215
2216        (number) @number
2217        (character) @constant.builtin
2218        (boolean) @constant.builtin
2219        (symbol) @variable
2220
2221        (string) @string
2222
2223        (escape_sequence) @escape
2224
2225        (list
2226          .
2227          (symbol) @function)
2228
2229        (list
2230          .
2231          "["
2232          .
2233          (symbol)+ @variable
2234          .
2235          "]")
2236
2237        ((symbol) @operator
2238         (#match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$"))
2239
2240        (list
2241          .
2242          (symbol) @keyword
2243          (#match? @keyword
2244           "^(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)$"
2245           ))
2246
2247        (list
2248          .
2249          (symbol) @function.builtin
2250          (#match? @function.builtin
2251           "^(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\\?)$"
2252           ))
2253
2254        ;; quote ;;
2255
2256        ;; hardcoded highlight four levels of nested structure
2257
2258        ; 'atom
2259        (quote
2260          _ @constant)
2261
2262        ; '()
2263        (quote
2264          (_ _* @constant))
2265
2266        ; '(())
2267        (quote
2268          (_ (_ _* @constant)))
2269
2270        ; '((()))
2271        (quote
2272          (_ (_ (_ _* @constant))))
2273
2274        ;; sexp comment ;;
2275
2276        ;; hardcoded highlight four levels of nested structure
2277
2278        ; #;atom
2279        (comment
2280          _ @comment)
2281
2282        ; #;(list)
2283        (comment
2284          (_ _* @comment))
2285
2286        ; #;(list (list))
2287        (comment
2288          (_ (_ _* @comment)))
2289
2290        ; #;(list (list (list)))
2291        (comment
2292          (_ (_ (_ _ @comment))))
2293
2294        [(comment)
2295         (block_comment)
2296         (directive)] @comment
2297        """####,
2298        "toml": ####"""
2299        ; TOML highlights for Orgstar: table names as types, keys as properties. The grammar's own
2300        ; query captures whole pairs as properties, which colors values too.
2301        (comment) @comment
2302        (string) @string
2303        (quoted_key) @string
2304        [(integer) (float)] @number
2305        (boolean) @constant
2306        [(offset_date_time) (local_date_time) (local_date) (local_time)] @string.special
2307        (table (bare_key) @type)
2308        (table (dotted_key (bare_key) @type))
2309        (table_array_element (bare_key) @type)
2310        (table_array_element (dotted_key (bare_key) @type))
2311        (pair (bare_key) @property)
2312        (pair (dotted_key (bare_key) @property))
2313        "=" @operator
2314        """####,
2315        "yaml": ####"""
2316        (boolean_scalar) @boolean
2317
2318        (null_scalar) @constant.builtin
2319
2320        [
2321          (double_quote_scalar)
2322          (single_quote_scalar)
2323          (block_scalar)
2324          (string_scalar)
2325        ] @string
2326
2327        [
2328          (integer_scalar)
2329          (float_scalar)
2330        ] @number
2331
2332        (comment) @comment
2333
2334        [
2335          (anchor_name)
2336          (alias_name)
2337        ] @label
2338
2339        (tag) @type
2340
2341        [
2342          (yaml_directive)
2343          (tag_directive)
2344          (reserved_directive)
2345        ] @attribute
2346
2347        (block_mapping_pair
2348          key: (flow_node
2349            [
2350              (double_quote_scalar)
2351              (single_quote_scalar)
2352            ] @property))
2353
2354        (block_mapping_pair
2355          key: (flow_node
2356            (plain_scalar
2357              (string_scalar) @property)))
2358
2359        (flow_mapping
2360          (_
2361            key: (flow_node
2362              [
2363                (double_quote_scalar)
2364                (single_quote_scalar)
2365              ] @property)))
2366
2367        (flow_mapping
2368          (_
2369            key: (flow_node
2370              (plain_scalar
2371                (string_scalar) @property))))
2372
2373        [
2374          ","
2375          "-"
2376          ":"
2377          ">"
2378          "?"
2379          "|"
2380        ] @punctuation.delimiter
2381
2382        [
2383          "["
2384          "]"
2385          "{"
2386          "}"
2387        ] @punctuation.bracket
2388
2389        [
2390          "*"
2391          "&"
2392          "---"
2393          "..."
2394        ] @punctuation.special
2395        """####,
2396    ]
2397}