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

273 lines
2.9 KiB
Scheme
Raw Normal View History

2023-03-11 03:02:30 -05:00
; Variables
(identifier) @variable
; Types
(type) @type
(scoped_type_identifier
2024-01-06 15:05:50 +09:00
(identifier)
.
(identifier) @type)
2023-03-11 03:02:30 -05:00
(struct_literal
2024-01-06 15:05:50 +09:00
.
(identifier) @type)
2023-03-11 03:02:30 -05:00
(builtin_type) @type.builtin
; Constants
((identifier) @constant
(#lua-match? @constant "^[A-Z_]+$"))
; Includes
[
"use"
"export"
] @keyword.import
2023-03-11 03:02:30 -05:00
(use_statement
(scoped_type_identifier
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))
2024-01-06 15:05:50 +09:00
2023-03-11 03:02:30 -05:00
(use_statement
2024-01-06 15:05:50 +09:00
(identifier) @module
"{")
2023-03-11 03:02:30 -05:00
(use_statement
2024-01-06 15:05:50 +09:00
.
(identifier) @module .)
2023-03-11 03:02:30 -05:00
((scoped_type_identifier
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
path: (_) @module)
(#set! priority 105))
2023-03-11 03:02:30 -05:00
; Keywords
[
"def"
"let"
2024-04-23 12:23:15 -07:00
] @keyword
[
"enum"
2023-03-11 03:02:30 -05:00
"struct"
"union"
2024-04-23 12:23:15 -07:00
"type"
] @keyword.type
2023-03-11 03:02:30 -05:00
2024-01-06 15:05:50 +09:00
"fn" @keyword.function
2023-03-11 03:02:30 -05:00
[
"defer"
"yield"
"return"
] @keyword.return
[
"as"
"is"
] @keyword.operator
; Typedefs
(type_declaration
2024-01-06 15:05:50 +09:00
"type"
(identifier) @type.definition
.
"=")
2023-03-11 03:02:30 -05:00
; Qualifiers
[
"const"
"static"
"nullable"
] @keyword.modifier
2023-03-11 03:02:30 -05:00
; Attributes
[
"@fini"
"@init"
"@test"
"@noreturn"
"@packed"
(declaration_attribute)
] @attribute
; Labels
((label) @label
(#set! priority 105))
2023-03-11 03:02:30 -05:00
; Functions
(function_declaration
2024-01-06 15:05:50 +09:00
"fn"
.
(identifier) @function)
2023-03-11 03:02:30 -05:00
(call_expression
2024-01-06 15:05:50 +09:00
.
(identifier) @function.call)
2023-03-11 03:02:30 -05:00
(call_expression
2024-01-06 15:05:50 +09:00
.
(scoped_type_identifier
.
(identifier)
.
"::"
.
(identifier) @function.method.call))
2023-03-11 03:02:30 -05:00
((call_expression
2024-01-06 15:05:50 +09:00
.
(identifier) @function.builtin)
2023-03-11 03:02:30 -05:00
(#any-of? @function.builtin "align" "assert" "free" "len" "offset" "size"))
(size_expression
"size" @function.builtin)
((function_declaration
2024-01-06 15:05:50 +09:00
"fn"
.
(identifier) @constructor)
2023-03-11 03:02:30 -05:00
(#eq? @constructor "init"))
((call_expression
2024-01-06 15:05:50 +09:00
.
(identifier) @constructor)
2023-03-11 03:02:30 -05:00
(#eq? @constructor "init"))
; Parameters
(parameter
2024-01-06 15:05:50 +09:00
(_) @variable.parameter
.
":")
2023-03-11 03:02:30 -05:00
; Fields
((member_expression
2024-01-06 15:05:50 +09:00
"."
(_) @variable.member)
(#set! priority 105))
2023-03-11 03:02:30 -05:00
(field
2024-01-06 15:05:50 +09:00
.
(identifier) @variable.member)
2023-03-11 03:02:30 -05:00
(field_assignment
2024-01-06 15:05:50 +09:00
.
(identifier) @variable.member)
2023-03-11 03:02:30 -05:00
; Repeats
2024-01-06 15:05:50 +09:00
"for" @keyword.repeat
2023-03-11 03:02:30 -05:00
; Conditionals
[
"if"
"else"
"break"
"switch"
"match"
"case"
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
] @keyword.conditional
2023-03-11 03:02:30 -05:00
; Operators
[
"+"
"-"
"*"
"/"
"%"
"||"
"&&"
"^^"
"|"
"&"
"^"
"=="
"!="
">"
">="
"<="
"<"
"<<"
">>"
"~"
"!"
"+="
"-="
"*="
"/="
"%="
"<<="
">>="
"|="
"&="
"^="
"||="
"&&="
"^^="
"="
"?"
] @operator
; Punctuation
2024-01-06 15:05:50 +09:00
[
"{"
"}"
] @punctuation.bracket
2023-03-11 03:02:30 -05:00
2024-01-06 15:05:50 +09:00
[
"["
"]"
] @punctuation.bracket
2023-03-11 03:02:30 -05:00
2024-01-06 15:05:50 +09:00
[
"("
")"
] @punctuation.bracket
2023-03-11 03:02:30 -05:00
[
".."
"..."
"_"
] @punctuation.special
2024-01-06 15:05:50 +09:00
(pointer_type
"*" @punctuation.special)
2023-03-11 03:02:30 -05:00
2024-01-06 15:05:50 +09:00
(slice_type
"*" @punctuation.special)
2023-03-11 03:02:30 -05:00
2024-01-06 15:05:50 +09:00
(error_type
"!" @punctuation.special)
2023-03-11 03:02:30 -05:00
[
","
"."
":"
";"
"::"
"=>"
] @punctuation.delimiter
; Literals
[
(string)
(raw_string)
] @string
(rune) @character
(escape_sequence) @string.escape
(number) @number
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
(float) @number.float
2023-03-11 03:02:30 -05:00
(boolean) @boolean
[
(void)
(null)
] @constant.builtin
; Comments
(comment) @comment @spell