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

155 lines
2.1 KiB
Scheme
Raw Normal View History

2023-02-20 17:55:06 +01:00
; Tags
2023-03-10 03:04:16 +01:00
; TODO apply to every symbol in list? I think it should probably only be applied to the first child of the list
2023-02-20 17:55:06 +01:00
(list
(symbol) @tag)
; Includes
2024-01-06 15:05:50 +09:00
(list
.
(symbol) @keyword.import
(#eq? @keyword.import "include"))
2023-02-20 17:55:06 +01:00
; Keywords
2024-01-06 15:05:50 +09:00
(list
.
(symbol) @keyword
(#any-of? @keyword
"defwindow" "defwidget" "defvar" "defpoll" "deflisten" "geometry" "children" "struts"))
2023-03-10 03:04:16 +01:00
; Loop
2024-01-06 15:05:50 +09:00
(loop_widget
.
"for" @keyword.repeat
.
(symbol) @variable
.
"in" @keyword.operator)
(loop_widget
.
"for" @keyword.repeat
.
(symbol) @variable
.
"in" @keyword.operator
.
(symbol) @variable)
2023-03-10 03:04:16 +01:00
; Builtin widgets
2024-01-06 15:05:50 +09:00
(list
.
(symbol) @tag.builtin
(#any-of? @tag.builtin
"box" "button" "calendar" "centerbox" "checkbox" "circular-progress" "color-button"
"color-chooser" "combo-box-text" "eventbox" "expander" "graph" "image" "input" "label" "literal"
"overlay" "progress" "revealer" "scale" "scroll" "transform"))
2023-02-20 17:55:06 +01:00
; Variables
2023-03-10 03:04:16 +01:00
(ident) @variable
2023-02-20 17:55:06 +01:00
(array
(symbol) @variable)
((ident) @variable.builtin
(#any-of? @variable.builtin
"EWW_TEMPS" "EWW_RAM" "EWW_DISK" "EWW_BATTERY" "EWW_CPU" "EWW_NET" "EWW_TIME" "EWW_CONFIG_DIR"
"EWW_CMD" "EWW_EXECUTABLE"))
; Properties
2023-02-20 17:55:06 +01:00
(keyword) @property
(json_access
(_)
"["
2023-03-10 03:04:16 +01:00
(simplexpr
(ident) @property))
2023-02-20 17:55:06 +01:00
(json_safe_access
(_)
"?."
"["
2023-03-10 03:04:16 +01:00
(simplexpr
(ident) @property))
2023-02-20 17:55:06 +01:00
(json_dot_access
(index) @property)
(json_safe_dot_access
(index) @property)
(json_object
2023-03-10 03:04:16 +01:00
(simplexpr
(ident) @property))
2023-02-20 17:55:06 +01:00
2023-03-10 03:04:16 +01:00
; Functions
(function_call
name: (ident) @function.call)
2023-02-20 17:55:06 +01:00
; Operators
[
"+"
"-"
"*"
"/"
"%"
"||"
"&&"
"=="
"!="
"=~"
">"
"<"
">="
"<="
"!"
"?."
2023-03-10 03:04:16 +01:00
"?:"
2023-02-20 17:55:06 +01:00
] @operator
; Punctuation
2024-01-06 15:05:50 +09:00
[
":"
"."
","
] @punctuation.delimiter
2023-02-20 17:55:06 +01:00
2024-01-06 15:05:50 +09:00
[
"{"
"}"
"["
"]"
"("
")"
] @punctuation.bracket
2023-02-20 17:55:06 +01:00
2023-03-10 03:04:16 +01:00
; Ternary expression
(ternary_expression
2024-01-06 15:05:50 +09:00
[
"?"
":"
] @keyword.conditional.ternary)
2023-03-10 03:04:16 +01:00
2023-02-20 17:55:06 +01:00
; Literals
(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-02-20 17:55:06 +01:00
(boolean) @boolean
; Strings
2024-01-06 15:05:50 +09:00
[
(string_fragment)
"\""
"'"
"`"
] @string
2023-02-20 17:55:06 +01:00
(string_interpolation
"${" @punctuation.special
"}" @punctuation.special)
(escape_sequence) @string.escape
; Comments
(comment) @comment @spell