nvim-treesitter/queries/apex/highlights.scm
Christian Clason 1ae9b0e455 feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.

Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.

Specifically:

* tree-sitter "standard capture names"
  (3f44b89685/highlight/src/lib.rs (L20-L72)):

  - `@parameter` -> `@variable.parameter`
  - `@field` -> `@variable.member`
  - `@namespace` -> `@module`
  - `@float` -> `@number.float`
  - `@symbol` -> `@string.special.symbol`
  - `@string.regex` -> `@string.regexp`
  - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
  - `@text.title` -> `@markup.heading`
  - `@text.literal` -> `@markup.raw`
  - `@text.reference` -> `@markup.link`
  - `@text.uri` -> `@markup.link.url` (in markup links)
  - `@string.special` -> `@markup.link.label` (non-url links)
  - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)

* Helix captures
  (https://docs.helix-editor.com/master/themes.html#syntax-highlighting):

  - `@method` -> `@function.method`
  - `@method.call` -> `@function.method.call`
  - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
  - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
  - `@text.uri` -> `@string.special.url` (outside markup)
  - `@preproc` -> `@keyword.directive`
  - `@define` -> `@keyword.directive`(`.define`?)
  - `@storageclass` -> `@keyword.storage`
  - `@conditional` -> `@keyword.conditional`
  - `@debug` -> `@keyword.debug`
  - `@exception` -> `@keyword.exception`
  - `@include` -> `@keyword.import`
  - `@repeat` -> `@keyword.repeat`

* cleanup

  - remove some redundant `@conceal` (but still allow it for conceal-only patterns)
  - remove obsolete `@error` (syntax linting is out of scope for this repo)
  - sort, cleanup capture list in `CONTRIBUTING.md`
2024-01-19 16:58:37 +01:00

248 lines
3.2 KiB
Scheme

; inherits: soql
;;; Apex + SOQL
[
"["
"]"
"{"
"}"
"("
")"
] @punctuation.bracket
[
","
"."
":"
"?"
";"
] @punctuation.delimiter
;; Default general color defination
(identifier) @variable
(type_identifier) @type
;; Methods
(method_declaration
name: (identifier) @function.method)
(method_invocation
name: (identifier) @function.method.call)
(super) @function.builtin
;; Annotations
(annotation
name: (identifier) @attribute)
;; Types
(interface_declaration
name: (identifier) @type)
(class_declaration
name: (identifier) @type)
(class_declaration
(superclass) @type)
(enum_declaration
name: (identifier) @type)
(enum_constant
name: (identifier) @constant)
(type_arguments "<" @punctuation.delimiter)
(type_arguments ">" @punctuation.delimiter)
((field_access
object: (identifier) @type))
(field_access
field: (identifier) @property)
((scoped_identifier
scope: (identifier) @type)
(#match? @type "^[A-Z]"))
((method_invocation
object: (identifier) @type)
(#match? @type "^[A-Z]"))
(method_declaration
(formal_parameters
(formal_parameter
name: (identifier) @variable.parameter)))
(constructor_declaration
name: (identifier) @constructor)
(dml_type) @function.builtin
(assignment_operator) @operator
(update_expression ["++" "--"] @operator)
(trigger_declaration
name: (identifier) @type
object: (identifier) @type
(trigger_event) @keyword
("," (trigger_event) @keyword)*)
[
"@"
"="
"!="
"<="
">="
] @operator
(binary_expression
operator: [
">"
"<"
"=="
"==="
"!=="
"&&"
"||"
"+"
"-"
"*"
"/"
"&"
"|"
"^"
"%"
"<<"
">>"
">>>"] @operator)
(unary_expression
operator: [
"+"
"-"
"!"
"~"
]) @operator
(map_initializer "=>" @operator)
[
(boolean_type)
(void_type)
] @type.builtin;;
; Fields
(field_declaration
declarator: (variable_declarator
name: (identifier) @variable.member))
(field_access
field: (identifier) @variable.member)
; Variables
(field_declaration
(modifiers (modifier ["final" "static"])(modifier ["final" "static"]))
(variable_declarator
name: (identifier) @constant))
(variable_declarator
(identifier) @property)
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) ; SCREAM SNAKE CASE
(this) @variable.builtin
; Literals
[
(int)
(decimal)
(currency_literal)
] @number
(string_literal) @string
[
(line_comment)
(block_comment)
] @comment
(null_literal) @constant.builtin
;; ;; Keywords
[
"abstract"
"final"
"private"
"protected"
"public"
"static"
] @type.qualifier
[
"if"
"else"
"switch"
] @keyword.conditional
[
"for"
"while"
"do"
"break"
] @keyword.repeat
[
"return"
] @keyword.return
[
"throw"
"finally"
"try"
"catch"
] @keyword.exception
"new" @keyword.operator
[
"abstract"
"class"
"continue"
"default"
"enum"
"extends"
"final"
"get"
"global"
"implements"
"instanceof"
"interface"
"on"
"private"
"protected"
"public"
"set"
"static"
"testMethod"
"transient"
"trigger"
"virtual"
"when"
"with_sharing"
"without_sharing"
"inherited_sharing"
] @keyword
"System.runAs" @type.builtin