mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
In Prometheus, label values are treated as strings when used with the
`=` and `!=` operators, and as regular expressions when used with the
`=~` and `!~` operators.
Injecting and then highlighting all label values as regex leads to a
situation where entirely valid **string** label values containing regex
special characters are mistakenly parsed and highlighted as regex. This
results in syntax errors, causing labels to be highlighted incorrectly.
For example, in `foo{bar=~"[a-z]{1,3}"}`, `{` and `}` are regex special
characters, so regex highlighting is expected. However, in
`foo{path="/foo/{id}"}`, `{` and `}` are just part of the string and
have no special meaning, so the whole value should be highlighted as a
string.
55 lines
541 B
Scheme
55 lines
541 B
Scheme
; highlights.scm
|
|
[
|
|
"*"
|
|
"/"
|
|
"%"
|
|
"+"
|
|
"-"
|
|
">"
|
|
">="
|
|
"<"
|
|
"<="
|
|
"="
|
|
"=~"
|
|
"!="
|
|
"!~"
|
|
] @operator
|
|
|
|
[
|
|
"{"
|
|
"}"
|
|
"["
|
|
"]"
|
|
"("
|
|
")"
|
|
] @punctuation.bracket
|
|
|
|
(float_literal) @number.float
|
|
|
|
(string_literal) @string
|
|
|
|
(metric_name) @type
|
|
|
|
(range_selection) @type
|
|
|
|
(subquery_range_selection) @type
|
|
|
|
(label_name) @variable.member
|
|
|
|
((label_name)
|
|
[
|
|
"=~"
|
|
"!~"
|
|
]
|
|
(label_value) @string.regexp)
|
|
|
|
((label_name)
|
|
[
|
|
"="
|
|
"!="
|
|
]
|
|
(label_value) @string)
|
|
|
|
(function_name) @function.call
|
|
|
|
(comment) @comment @spell
|