mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-06 05:20:00 -04:00
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`
307 lines
4.4 KiB
Scheme
307 lines
4.4 KiB
Scheme
; Keywords
|
|
|
|
[
|
|
"class"
|
|
"clone"
|
|
"delete"
|
|
"enum"
|
|
"extends"
|
|
"rawcall"
|
|
"resume"
|
|
"var"
|
|
] @keyword
|
|
|
|
[
|
|
"function"
|
|
] @keyword.function
|
|
|
|
[
|
|
"in"
|
|
"instanceof"
|
|
"typeof"
|
|
] @keyword.operator
|
|
|
|
[
|
|
"return"
|
|
"yield"
|
|
] @keyword.return
|
|
|
|
((global_variable
|
|
"::"
|
|
(_) @keyword.coroutine)
|
|
(#any-of? @keyword.coroutine "suspend" "newthread"))
|
|
|
|
; Conditionals
|
|
|
|
[
|
|
"if"
|
|
"else"
|
|
"switch"
|
|
"case"
|
|
"default"
|
|
"break"
|
|
] @keyword.conditional
|
|
|
|
; Repeats
|
|
|
|
[
|
|
"for"
|
|
"foreach"
|
|
"do"
|
|
"while"
|
|
"continue"
|
|
] @keyword.repeat
|
|
|
|
; Exceptions
|
|
|
|
[
|
|
"try"
|
|
"catch"
|
|
"throw"
|
|
] @keyword.exception
|
|
|
|
; Storageclasses
|
|
|
|
[
|
|
"local"
|
|
] @keyword.storage
|
|
|
|
; Qualifiers
|
|
|
|
[
|
|
"static"
|
|
"const"
|
|
] @type.qualifier
|
|
|
|
; Variables
|
|
|
|
(identifier) @variable
|
|
|
|
(local_declaration
|
|
(identifier) @variable.local
|
|
. "=")
|
|
|
|
|
|
(global_variable) @variable.global
|
|
|
|
((identifier) @variable.builtin
|
|
(#any-of? @variable.builtin "base" "this" "vargv"))
|
|
|
|
; Parameters
|
|
|
|
(parameter
|
|
. (identifier) @variable.parameter)
|
|
|
|
; Properties (Slots)
|
|
|
|
(deref_expression
|
|
"."
|
|
. (identifier) @property)
|
|
|
|
(member_declaration
|
|
(identifier) @property
|
|
. "=")
|
|
|
|
((table_slot
|
|
. (identifier) @property
|
|
. ["=" ":"])
|
|
(#set! "priority" 105))
|
|
|
|
; Types
|
|
|
|
((identifier) @type
|
|
(#lua-match? @type "^[A-Z]"))
|
|
|
|
(class_declaration
|
|
(identifier) @type
|
|
"extends"? . (identifier)? @type)
|
|
|
|
(enum_declaration
|
|
(identifier) @type)
|
|
|
|
; Attributes
|
|
|
|
(attribute_declaration
|
|
left: (identifier) @attribute)
|
|
|
|
; Functions & Methods
|
|
|
|
(member_declaration
|
|
(function_declaration
|
|
"::"? (_) @function.method . "(" (_)? ")"))
|
|
|
|
((function_declaration
|
|
"::"? (_) @function . "(" (_)? ")")
|
|
(#not-has-ancestor? @function member_declaration))
|
|
|
|
(call_expression
|
|
function: (identifier) @function.call)
|
|
|
|
(call_expression
|
|
function: (deref_expression
|
|
"." . (identifier) @function.call))
|
|
|
|
(call_expression
|
|
(global_variable
|
|
"::"
|
|
(_) @function.call))
|
|
|
|
(_
|
|
(identifier) @function
|
|
"="
|
|
(lambda_expression
|
|
"@" @string.special.symbol))
|
|
|
|
(call_expression
|
|
[
|
|
function: (identifier) @function.builtin
|
|
function: (global_variable "::" (_) @function.builtin)
|
|
function: (deref_expression "." (_) @function.builtin)
|
|
]
|
|
(#any-of? @function.builtin
|
|
; General Methods
|
|
"assert" "array" "callee" "collectgarbage" "compilestring"
|
|
"enabledebughook" "enabledebuginfo" "error" "getconsttable"
|
|
"getroottable" "print" "resurrectunreachable" "setconsttable"
|
|
"setdebughook" "seterrorhandler" "setroottable" "type"
|
|
|
|
; Hidden Methods
|
|
"_charsize_" "_intsize_" "_floatsize_" "_version_" "_versionnumber_"
|
|
|
|
; Number Methods
|
|
"tofloat" "tostring" "tointeger" "tochar"
|
|
|
|
; String Methods
|
|
"len" "slice" "find" "tolower" "toupper"
|
|
|
|
; Table Methods
|
|
"rawget" "rawset" "rawdelete" "rawin" "clear"
|
|
"setdelegate" "getdelegate" "filter" "keys" "values"
|
|
|
|
; Array Methods
|
|
"append" "push" "extend" "pop" "top" "insert" "remove" "resize" "sort"
|
|
"reverse" "map" "apply" "reduce"
|
|
|
|
; Function Methods
|
|
"call" "pcall" "acall" "pacall" "setroot" "getroot" "bindenv" "getinfos"
|
|
|
|
; Class Methods
|
|
"instance" "getattributes" "setattributes" "newmember" "rawnewmember"
|
|
|
|
; Class Instance Methods
|
|
"getclass"
|
|
|
|
; Generator Methods
|
|
"getstatus"
|
|
|
|
; Thread Methods
|
|
"call" "wakeup" "wakeupthrow" "getstackinfos"
|
|
|
|
; Weak Reference Methods
|
|
"ref" "weakref"
|
|
))
|
|
|
|
(member_declaration
|
|
"constructor" @constructor)
|
|
|
|
; Constants
|
|
|
|
(const_declaration
|
|
"const"
|
|
. (identifier) @constant)
|
|
|
|
(enum_declaration
|
|
"{"
|
|
. (identifier) @constant)
|
|
|
|
((identifier) @constant
|
|
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
|
|
|
|
; Operators
|
|
|
|
[
|
|
"+"
|
|
"-"
|
|
"*"
|
|
"/"
|
|
"%"
|
|
"||"
|
|
"&&"
|
|
"|"
|
|
"^"
|
|
"&"
|
|
"=="
|
|
"!="
|
|
"<=>"
|
|
">"
|
|
">="
|
|
"<="
|
|
"<"
|
|
"<<"
|
|
">>"
|
|
">>>"
|
|
"="
|
|
"<-"
|
|
"+="
|
|
"-="
|
|
"*="
|
|
"/="
|
|
"%="
|
|
"~"
|
|
"!"
|
|
"++"
|
|
"--"
|
|
] @operator
|
|
|
|
; Punctuation
|
|
|
|
[ "{" "}" ] @punctuation.bracket
|
|
|
|
[ "[" "]" ] @punctuation.bracket
|
|
|
|
[ "(" ")" ] @punctuation.bracket
|
|
|
|
[ "</" "/>" ] @punctuation.bracket
|
|
|
|
[
|
|
"."
|
|
","
|
|
";"
|
|
":"
|
|
] @punctuation.delimiter
|
|
|
|
[
|
|
"::"
|
|
"..."
|
|
] @punctuation.special
|
|
|
|
; Ternaries
|
|
|
|
(ternary_expression
|
|
"?" @keyword.conditional.ternary
|
|
":" @keyword.conditional.ternary)
|
|
|
|
; Literals
|
|
|
|
(string) @string
|
|
|
|
(verbatim_string) @string.special
|
|
|
|
(char) @character
|
|
|
|
(escape_sequence) @string.escape
|
|
|
|
(integer) @number
|
|
|
|
(float) @number.float
|
|
|
|
(bool) @boolean
|
|
|
|
(null) @constant.builtin
|
|
|
|
; Comments
|
|
|
|
(comment) @comment @spell
|
|
|
|
((comment) @comment.documentation
|
|
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|