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

146 lines
2.2 KiB
Scheme

; Tags
; TODO apply to every symbol in list? I think it should probably only be applied to the first child of the list
(list
(symbol) @tag)
; Includes
(list .
((symbol) @keyword.import
(#eq? @keyword.import "include")))
; Keywords
; I think there's a bug in tree-sitter the anchor doesn't seem to be working, see
; https://github.com/tree-sitter/tree-sitter/pull/2107
(list .
((symbol) @keyword
(#any-of? @keyword "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "geometry" "children" "struts")))
; Loop
(loop_widget . "for" @keyword.repeat . (symbol) @variable . "in" @keyword.operator)
(loop_widget . "for" @keyword.repeat . (symbol) @variable . "in" @keyword.operator . (symbol) @variable)
; Builtin widgets
(list .
((symbol) @tag.builtin
(#any-of? @tag.builtin
"box"
"button"
"calendar"
"centerbox"
"checkbox"
"circular-progress"
"color-button"
"color-chooser"
"combo-box-text"
"eventbox"
"expander"
"graph"
"image"
"input"
"label"
"literal"
"overlay"
"progress"
"revealer"
"scale"
"scroll"
"transform")))
; Variables
(ident) @variable
(array
(symbol) @variable)
; Properties & Fields
(keyword) @property
(json_access
(_)
"["
(simplexpr
(ident) @property))
(json_safe_access
(_)
"?."
"["
(simplexpr
(ident) @property))
(json_dot_access
(index) @property)
(json_safe_dot_access
(index) @property)
(json_object
(simplexpr
(ident) @variable.member))
; Functions
(function_call
name: (ident) @function.call)
; Operators
[
"+"
"-"
"*"
"/"
"%"
"||"
"&&"
"=="
"!="
"=~"
">"
"<"
">="
"<="
"!"
"?."
"?:"
] @operator
; Punctuation
[":" "." ","] @punctuation.delimiter
["{" "}" "[" "]" "(" ")"] @punctuation.bracket
; Ternary expression
(ternary_expression
["?" ":"] @keyword.conditional.ternary)
; Literals
(number) @number
(float) @number.float
(boolean) @boolean
; Strings
[ (string_fragment) "\"" "'" "`" ] @string
(string_interpolation
"${" @punctuation.special
"}" @punctuation.special)
(escape_sequence) @string.escape
; Comments
(comment) @comment @spell