nvim-treesitter/queries/jq/highlights.scm
Christian Clason 1ae9b0e455 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"
  (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`
2024-01-19 16:58:37 +01:00

332 lines
3.7 KiB
Scheme

; Variables
(variable) @variable
((variable) @constant.builtin
(#eq? @constant.builtin "$ENV"))
((variable) @constant.macro
(#eq? @constant.macro "$__loc__"))
; Properties
(index
(identifier) @property)
; Labels
(query
label: (variable) @label)
(query
break_statement: (variable) @label)
; Literals
(number) @number
(string) @string
[
"true"
"false"
] @boolean
("null") @type.builtin
; Interpolation
["\\(" ")"] @character.special
; Format
(format) @attribute
; Functions
(funcdef
(identifier) @function)
(funcdefargs
(identifier) @variable.parameter)
[
"reduce"
"foreach"
] @function.builtin
((funcname) @function.call . "(")
; jq -n 'builtins | map(split("/")[0]) | unique | .[]'
((funcname) @function.builtin
(#any-of? @function.builtin
"IN"
"INDEX"
"JOIN"
"acos"
"acosh"
"add"
"all"
"any"
"arrays"
"ascii_downcase"
"ascii_upcase"
"asin"
"asinh"
"atan"
"atan2"
"atanh"
"booleans"
"bsearch"
"builtins"
"capture"
"cbrt"
"ceil"
"combinations"
"contains"
"copysign"
"cos"
"cosh"
"debug"
"del"
"delpaths"
"drem"
"empty"
"endswith"
"env"
"erf"
"erfc"
"error"
"exp"
"exp10"
"exp2"
"explode"
"expm1"
"fabs"
"fdim"
"finites"
"first"
"flatten"
"floor"
"fma"
"fmax"
"fmin"
"fmod"
"format"
"frexp"
"from_entries"
"fromdate"
"fromdateiso8601"
"fromjson"
"fromstream"
"gamma"
"get_jq_origin"
"get_prog_origin"
"get_search_list"
"getpath"
"gmtime"
"group_by"
"gsub"
"halt"
"halt_error"
"has"
"hypot"
"implode"
"in"
"index"
"indices"
"infinite"
"input"
"input_filename"
"input_line_number"
"inputs"
"inside"
"isempty"
"isfinite"
"isinfinite"
"isnan"
"isnormal"
"iterables"
"j0"
"j1"
"jn"
"join"
"keys"
"keys_unsorted"
"last"
"ldexp"
"leaf_paths"
"length"
"lgamma"
"lgamma_r"
"limit"
"localtime"
"log"
"log10"
"log1p"
"log2"
"logb"
"ltrimstr"
"map"
"map_values"
"match"
"max"
"max_by"
"min"
"min_by"
"mktime"
"modf"
"modulemeta"
"nan"
"nearbyint"
"nextafter"
"nexttoward"
"normals"
"not"
"now"
"nth"
"nulls"
"numbers"
"objects"
"path"
"paths"
"pow"
"pow10"
"range"
"recurse"
"recurse_down"
"remainder"
"repeat"
"reverse"
"rindex"
"rint"
"round"
"rtrimstr"
"scalars"
"scalars_or_empty"
"scalb"
"scalbln"
"scan"
"select"
"setpath"
"significand"
"sin"
"sinh"
"sort"
"sort_by"
"split"
"splits"
"sqrt"
"startswith"
"stderr"
"strflocaltime"
"strftime"
"strings"
"strptime"
"sub"
"tan"
"tanh"
"test"
"tgamma"
"to_entries"
"todate"
"todateiso8601"
"tojson"
"tonumber"
"tostream"
"tostring"
"transpose"
"trunc"
"truncate_stream"
"type"
"unique"
"unique_by"
"until"
"utf8bytelength"
"values"
"walk"
"while"
"with_entries"
"y0"
"y1"
"yn"))
; Keywords
[
"def"
"as"
"label"
"module"
"break"
] @keyword
[
"import"
"include"
] @keyword.import
[
"if"
"then"
"elif"
"else"
"end"
] @keyword.conditional
[
"try"
"catch"
] @keyword.exception
[
"or"
"and"
] @keyword.operator
; Operators
[
"."
"=="
"!="
">"
">="
"<="
"<"
"="
"+"
"-"
"*"
"/"
"%"
"+="
"-="
"*="
"/="
"%="
"//="
"|"
"?"
"//"
"?//"
(recurse) ; ".."
] @operator
; Punctuation
[
";"
","
":"
] @punctuation.delimiter
[
"[" "]"
"{" "}"
"(" ")"
] @punctuation.bracket
; Comments
(comment) @comment @spell