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

152 lines
2 KiB
Scheme

; Keywords
[
"@module"
"@package"
] @keyword.import
[
"@class"
"@type"
"@param"
"@alias"
"@field"
"@generic"
"@vararg"
"@diagnostic"
"@deprecated"
"@meta"
"@source"
"@version"
"@operator"
"@nodiscard"
"@cast"
"@overload"
"@enum"
"@language"
"@see"
"extends"
(diagnostic_identifier)
] @keyword
[
"@async"
] @keyword.coroutine
(language_injection "@language" (identifier) @keyword)
(function_type ["fun" "function"] @keyword.function)
(source_annotation
filename: (identifier) @string.special.path
extension: (identifier) @string.special.path)
(version_annotation
version: _ @constant.builtin)
[
"@return"
] @keyword.return
; Qualifiers
[
"public"
"protected"
"private"
"@public"
"@protected"
"@private"
] @type.qualifier
; Variables
(identifier) @variable
[
"..."
"self"
] @variable.builtin
; Macros
(alias_annotation (identifier) @function.macro)
; Parameters
(param_annotation (identifier) @variable.parameter)
(parameter (identifier) @variable.parameter)
; Fields
(field_annotation (identifier) @variable.member)
(table_literal_type field: (identifier) @variable.member)
(member_type ["#" "."] . (identifier) @variable.member)
; Types
(table_type "table" @type.builtin)
(builtin_type) @type.builtin
(class_annotation (identifier) @type)
(enum_annotation (identifier) @type)
((array_type ["[" "]"] @type)
(#set! "priority" 105))
(type) @type
; Operators
[
"|"
] @operator
; Literals
(string) @module ; only used in @module
(literal_type) @string
(number) @number
; Punctuation
[ "[" "]" ] @punctuation.bracket
[ "{" "}" ] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket
[ "<" ">" ] @punctuation.bracket
[
","
"."
"#"
":"
] @punctuation.delimiter
[
"@"
"?"
] @punctuation.special
; Comments
(comment) @comment @spell
(at_comment
(identifier) @type
(_) @comment @spell)
(class_at_comment
(identifier) @type
("extends"? (identifier)? @type)
(_) @comment @spell)