nvim-treesitter/runtime/queries/lua/highlights.scm

250 lines
4.2 KiB
Scheme
Raw Normal View History

2024-01-06 15:05:50 +09:00
; Keywords
"return" @keyword.return
[
2024-01-06 15:05:50 +09:00
"goto"
"in"
"local"
] @keyword
(break_statement) @keyword
(do_statement
2024-01-06 15:05:50 +09:00
[
"do"
"end"
] @keyword)
(while_statement
2024-01-06 15:05:50 +09:00
[
"while"
"do"
"end"
] @keyword.repeat)
(repeat_statement
2024-01-06 15:05:50 +09:00
[
"repeat"
"until"
] @keyword.repeat)
(if_statement
2024-01-06 15:05:50 +09:00
[
"if"
"elseif"
"else"
"then"
"end"
] @keyword.conditional)
(elseif_statement
2024-01-06 15:05:50 +09:00
[
"elseif"
"then"
"end"
] @keyword.conditional)
(else_statement
2024-01-06 15:05:50 +09:00
[
"else"
"end"
] @keyword.conditional)
(for_statement
2024-01-06 15:05:50 +09:00
[
"for"
"do"
"end"
] @keyword.repeat)
(function_declaration
2024-01-06 15:05:50 +09:00
[
"function"
"end"
] @keyword.function)
2020-04-20 16:18:02 +02:00
(function_definition
2024-01-06 15:05:50 +09:00
[
"function"
"end"
] @keyword.function)
2024-01-06 15:05:50 +09:00
; Operators
(binary_expression
operator: _ @operator)
(unary_expression
operator: _ @operator)
"=" @operator
[
2024-01-06 15:05:50 +09:00
"and"
"not"
"or"
] @keyword.operator
2024-01-06 15:05:50 +09:00
; Punctuations
[
";"
":"
2023-03-19 21:04:38 -04:00
"::"
","
"."
] @punctuation.delimiter
2024-01-06 15:05:50 +09:00
; Brackets
[
2024-01-06 15:05:50 +09:00
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
2020-04-20 16:18:02 +02:00
2024-01-06 15:05:50 +09:00
; Variables
(identifier) @variable
((identifier) @constant.builtin
(#eq? @constant.builtin "_VERSION"))
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
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
((identifier) @module.builtin
(#any-of? @module.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
((identifier) @keyword.coroutine
(#eq? @keyword.coroutine "coroutine"))
2022-11-01 12:27:29 +01:00
(variable_list
2023-09-07 11:45:24 +06:00
(attribute
"<" @punctuation.bracket
(identifier) @attribute
">" @punctuation.bracket))
2022-11-01 12:27:29 +01:00
2024-01-06 15:05:50 +09:00
; Labels
(label_statement
(identifier) @label)
2023-03-19 21:04:38 -04:00
2024-01-06 15:05:50 +09:00
(goto_statement
(identifier) @label)
2024-01-06 15:05:50 +09:00
; Constants
((identifier) @constant
2024-01-06 15:05:50 +09:00
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
2020-04-20 16:18:02 +02:00
(nil) @constant.builtin
[
(false)
(true)
] @boolean
2024-01-06 15:05:50 +09:00
; Tables
(field
name: (identifier) @property)
2024-01-06 15:05:50 +09:00
(dot_index_expression
field: (identifier) @variable.member)
(table_constructor
2024-01-06 15:05:50 +09:00
[
"{"
"}"
] @constructor)
2024-01-06 15:05:50 +09:00
; Functions
(parameters
(identifier) @variable.parameter)
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
(vararg_expression) @variable.parameter.builtin
(function_declaration
name: [
(identifier) @function
(dot_index_expression
field: (identifier) @function)
])
2024-01-06 15:05:50 +09:00
(function_declaration
name: (method_index_expression
method: (identifier) @function.method))
2024-01-06 15:05:50 +09:00
(assignment_statement
(variable_list
.
name: [
(identifier) @function
(dot_index_expression
field: (identifier) @function)
])
2024-01-06 15:05:50 +09:00
(expression_list
.
value: (function_definition)))
2020-09-05 09:27:13 -05:00
(table_constructor
(field
name: (identifier) @function
value: (function_definition)))
(function_call
name: [
(identifier) @function.call
(dot_index_expression
field: (identifier) @function.call)
(method_index_expression
method: (identifier) @function.method.call)
])
2020-09-05 09:27:13 -05:00
(function_call
(identifier) @function.builtin
(#any-of? @function.builtin
; built-in functions in Lua 5.1
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile"
"loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset"
"require" "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall"
"__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc" "__idiv"
"__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex" "__pairs"
"__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
2024-01-06 15:05:50 +09:00
; Others
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
(hash_bang_line) @keyword.directive
2020-04-20 19:13:24 +02:00
(number) @number
(string) @string
2020-04-20 16:18:02 +02:00
(escape_sequence) @string.escape
2023-12-21 15:31:40 -08:00
; string.match("123", "%d+")
(function_call
(dot_index_expression
field: (identifier) @_method
(#any-of? @_method "find" "match" "gmatch" "gsub"))
arguments: (arguments
.
(_)
.
(string
content: (string_content) @string.regexp)))
2023-12-21 15:31:40 -08:00
;("123"):match("%d+")
(function_call
(method_index_expression
method: (identifier) @_method
(#any-of? @_method "find" "match" "gmatch" "gsub"))
arguments: (arguments
.
(string
content: (string_content) @string.regexp)))