nvim-treesitter/queries/pony/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

288 lines
3.7 KiB
Scheme

; Includes
[
"use"
] @keyword.import
; Keywords
[
"type"
"actor"
"class"
"primitive"
"interface"
"trait"
"struct"
"embed"
"let"
"var"
(compile_intrinsic)
"as"
"consume"
"recover"
"object"
"where"
] @keyword
[
"fun"
] @keyword.function
[
"be"
] @keyword.coroutine
[
"in"
"is"
] @keyword.operator
[
"return"
] @keyword.return
; Qualifiers
[
"iso"
"trn"
"ref"
"val"
"box"
"tag"
"#read"
"#send"
"#share"
"#alias"
"#any"
] @type.qualifier
; Conditionals
[
"if"
"ifdef"
"iftype"
"then"
"else"
"elseif"
"match"
] @keyword.conditional
(if_statement "end" @keyword.conditional)
(iftype_statement "end" @keyword.conditional)
(match_statement "end" @keyword.conditional)
; Repeats
[
"repeat"
"until"
"while"
"for"
"continue"
"do"
"break"
] @keyword.repeat
(do_block "end" @keyword.repeat)
(repeat_statement "end" @keyword.repeat)
; Exceptions
[
"try"
(error)
"compile_error"
] @keyword.exception
(try_statement "end" @keyword.exception)
(recover_statement "end" @keyword.exception)
; Attributes
(annotation) @attribute
; Variables
(identifier) @variable
(this) @variable.builtin
; Fields
(field name: (identifier) @variable.member)
(member_expression "." (identifier) @variable.member)
; Constructors
(constructor "new" @keyword.operator (identifier) @constructor)
; Methods
(method (identifier) @function.method)
(behavior (identifier) @function.method)
(ffi_method (identifier) @function.method)
((ffi_method (string) @string.special)
(#set! "priority" 105))
(call_expression
callee:
[
(identifier) @function.method.call
(ffi_identifier (identifier) @function.method.call)
(member_expression "." (identifier) @function.method.call)
])
; Parameters
(parameter name: (identifier) @variable.parameter)
(lambda_parameter name: (identifier) @variable.parameter)
; Types
(type_alias (identifier) @type.definition)
(base_type name: (identifier) @type)
(generic_parameter (identifier) @type)
(lambda_type (identifier)? @function.method)
((identifier) @type
(#lua-match? @type "^_*[A-Z][a-zA-Z0-9_]*$"))
; Operators
(unary_expression
operator: ["not" "addressof" "digestof"] @keyword.operator)
(binary_expression
operator: ["and" "or" "xor" "is" "isnt"] @keyword.operator)
[
"="
"?"
"|"
"&"
"-~"
"+"
"-"
"*"
"/"
"%"
"%%"
"<<"
">>"
"=="
"!="
">"
">="
"<="
"<"
"+~"
"-~"
"*~"
"/~"
"%~"
"%%~"
"<<~"
">>~"
"==~"
"!=~"
">~"
">=~"
"<=~"
"<~"
"+?"
"-?"
"*?"
"/?"
"%?"
"%%?"
"<:"
] @operator
; Literals
(string) @string
(source_file (string) @string.documentation)
(actor_definition (string) @string.documentation)
(class_definition (string) @string.documentation)
(primitive_definition (string) @string.documentation)
(interface_definition (string) @string.documentation)
(trait_definition (string) @string.documentation)
(struct_definition (string) @string.documentation)
(type_alias (string) @string.documentation)
(field (string) @string.documentation)
(constructor
[
(string) @string.documentation
(block . (string) @string.documentation)
])
(method
[
(string) @string.documentation
(block . (string) @string.documentation)
])
(behavior
[
(string) @string.documentation
(block . (string) @string.documentation)
])
(character) @character
(escape_sequence) @string.escape
(number) @number
(float) @number.float
(boolean) @boolean
; Punctuation
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket
[
"."
","
";"
":"
"~"
".>"
"->"
"=>"
] @punctuation.delimiter
[
"@"
"!"
"^"
"..."
] @punctuation.special
; Comments
[
(line_comment)
(block_comment)
] @comment @spell