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

150 lines
2.4 KiB
Scheme

; Includes
((command_name) @keyword.import
(#eq? @keyword.import "import"))
; Keywords
[
"arguments"
"classdef"
"end"
"enumeration"
"events"
"global"
"methods"
"persistent"
"properties"
] @keyword
; Conditionals
(if_statement [ "if" "end" ] @keyword.conditional)
(elseif_clause "elseif" @keyword.conditional)
(else_clause "else" @keyword.conditional)
(switch_statement [ "switch" "end" ] @keyword.conditional)
(case_clause "case" @keyword.conditional)
(otherwise_clause "otherwise" @keyword.conditional)
(break_statement) @keyword.conditional
; Repeats
(for_statement [ "for" "parfor" "end" ] @keyword.repeat)
(while_statement [ "while" "end" ] @keyword.repeat)
(continue_statement) @keyword.repeat
; Exceptions
(try_statement [ "try" "end" ] @keyword.exception)
(catch_clause "catch" @keyword.exception)
; Variables
(identifier) @variable
; Constants
(events (identifier) @constant)
(attribute (identifier) @constant)
"~" @constant.builtin
; Fields/Properties
(field_expression field: (identifier) @variable.member)
(superclass "." (identifier) @property)
(property_name "." (identifier) @property)
(property name: (identifier) @property)
; Types
(class_definition name: (identifier) @type)
(attributes (identifier) @constant)
(enum . (identifier) @type)
((identifier) @type
(#lua-match? @type "^_*[A-Z][a-zA-Z0-9_]+$"))
; Functions
(function_definition
"function" @keyword.function
name: (identifier) @function
[ "end" "endfunction" ]? @keyword.function)
(function_signature name: (identifier) @function)
(function_call
name: (identifier) @function.call)
(handle_operator (identifier) @function)
(validation_functions (identifier) @function)
(command (command_name) @function.call)
(command_argument) @variable.parameter
(return_statement) @keyword.return
; Parameters
(function_arguments (identifier) @variable.parameter)
; Punctuation
[ ";" "," "." ] @punctuation.delimiter
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
; Operators
[
"+"
".+"
"-"
".*"
"*"
".*"
"/"
"./"
"\\"
".\\"
"^"
".^"
"'"
".'"
"|"
"&"
"?"
"@"
"<"
"<="
">"
">="
"=="
"~="
"="
"&&"
"||"
":"
] @operator
; Literals
(string) @string
(escape_sequence) @string.escape
(formatting_sequence) @string.special
(number) @number
(boolean) @boolean
; Comments
[ (comment) (line_continuation) ] @comment @spell