nvim-treesitter/queries/teal/highlights.scm

133 lines
3.4 KiB
Scheme
Raw Normal View History

2020-10-04 19:39:12 -05:00
2021-03-23 16:06:02 -05:00
;; Primitives
(boolean) @boolean
2022-09-26 10:19:02 +01:00
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-][-]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
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" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/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`
2023-12-24 10:00:20 +01:00
(shebang_comment) @keyword.directive
2021-03-23 16:06:02 -05:00
(identifier) @variable
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
(nil) @constant.builtin
(number) @number
(string) @string
(table_constructor ["{" "}"] @constructor)
(varargs "..." @constant.builtin)
[ "," "." ":" ";" ] @punctuation.delimiter
(escape_sequence) @string.escape
(format_specifier) @string.escape
2020-12-16 16:42:33 -06:00
;; Basic statements/Keywords
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" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/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`
2023-12-24 10:00:20 +01:00
[ "if" "then" "elseif" "else" ] @keyword.conditional
[ "for" "while" "repeat" "until" ] @keyword.repeat
"return" @keyword.return
2021-07-25 15:27:51 +02:00
[ "in" "local" (break) (goto) "do" "end" ] @keyword
2020-10-04 19:39:12 -05:00
(label) @label
2020-12-16 16:42:33 -06:00
;; Global isn't a real keyword, but it gets special treatment in these places
2020-10-04 19:39:12 -05:00
(var_declaration "global" @keyword)
2020-12-16 16:42:33 -06:00
(type_declaration "global" @keyword)
2020-10-04 19:39:12 -05:00
(function_statement "global" @keyword)
2020-12-16 16:42:33 -06:00
(record_declaration "global" @keyword)
(enum_declaration "global" @keyword)
2020-10-04 19:39:12 -05:00
2020-12-03 20:55:11 +01:00
;; Ops
2021-03-23 16:06:02 -05:00
(bin_op (op) @operator)
(unary_op (op) @operator)
[ "=" "as" ] @operator
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
;; Functions
(function_statement
"function" @keyword.function
. name: (_) @function)
(anon_function
"function" @keyword.function)
(function_body "end" @keyword.function)
2020-10-04 19:39:12 -05:00
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" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/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`
2023-12-24 10:00:20 +01:00
(arg name: (identifier) @variable.parameter)
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
(function_signature
(arguments
. (arg name: (identifier) @variable.builtin))
(#eq? @variable.builtin "self"))
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
(typeargs
"<" @punctuation.bracket
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" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/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`
2023-12-24 10:00:20 +01:00
. (_) @variable.parameter
. ("," . (_) @variable.parameter)*
2020-12-16 16:42:33 -06:00
. ">" @punctuation.bracket)
2020-10-04 19:39:12 -05:00
(function_call
2020-12-16 16:42:33 -06:00
(identifier) @function . (arguments))
(function_call
(index (_) key: (identifier) @function) . (arguments))
(function_call
(method_index (_) key: (identifier) @function) . (arguments))
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
;; Types
(record_declaration
. "record" @keyword
name: (identifier) @type)
(anon_record . "record" @keyword)
(record_body
2021-07-25 15:27:51 +02:00
(record_declaration
. [ "record" ] @keyword
. name: (identifier) @type))
(record_body
(enum_declaration
. [ "enum" ] @keyword
. name: (identifier) @type))
2021-01-05 09:33:11 -06:00
(record_body
2021-07-25 15:27:51 +02:00
(typedef
2020-12-16 16:42:33 -06:00
. "type" @keyword
2021-07-25 15:27:51 +02:00
. name: (identifier) @type . "="))
2021-01-05 09:33:11 -06:00
(record_body
(metamethod "metamethod" @keyword))
(record_body
(userdata) @keyword)
2020-12-16 16:42:33 -06:00
(enum_declaration
"enum" @keyword
name: (identifier) @type)
2020-10-04 19:39:12 -05:00
(type_declaration "type" @keyword)
2021-07-25 15:27:51 +02:00
(type_declaration (identifier) @type)
2021-11-03 11:25:14 +00:00
(simple_type name: (identifier) @type)
(type_index (identifier) @type)
2020-12-16 16:42:33 -06:00
(type_union "|" @operator)
2020-10-04 19:39:12 -05:00
(function_type "function" @type)
2020-12-16 16:42:33 -06:00
;; The rest of it
(var_declaration
2021-07-25 15:27:51 +02:00
declarators: (var_declarators
(var name: (identifier) @variable)))
2020-12-16 16:42:33 -06:00
(var_declaration
2021-07-25 15:27:51 +02:00
declarators: (var_declarators
(var
"<" @punctuation.bracket
. attribute: (attribute) @attribute
. ">" @punctuation.bracket)))
2020-12-16 16:42:33 -06:00
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
2021-03-23 16:06:02 -05:00
;; Only highlight format specifiers in calls to string.format
;; string.format('...')
;(function_call
; called_object: (index
; (identifier) @base
; key: (identifier) @entry)
; arguments: (arguments .
; (string (format_specifier) @string.escape))
;
; (#eq? @base "string")
; (#eq? @entry "format"))
;; ('...'):format()
;(function_call
; called_object: (method_index
; (string (format_specifier) @string.escape)
; key: (identifier) @func-name)
; (#eq? @func-name "format"))