mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 10:20:11 -04:00
feat(promql,yaml): add parser and yaml injections
Signed-off-by: Michael Hoffmann <mhoffm@posteo.de>
This commit is contained in:
parent
a2c3a7319f
commit
b64ea2ec44
6 changed files with 105 additions and 0 deletions
|
|
@ -395,6 +395,9 @@
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"revision": "eca2596a355b1a9952b4f80f8f9caed300a272b5"
|
"revision": "eca2596a355b1a9952b4f80f8f9caed300a272b5"
|
||||||
},
|
},
|
||||||
|
"promql": {
|
||||||
|
"revision": "655afc4fe6813f38bde087d6493d8fd4920d6d4a"
|
||||||
|
},
|
||||||
"proto": {
|
"proto": {
|
||||||
"revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f"
|
"revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1187,6 +1187,15 @@ list.prisma = {
|
||||||
maintainers = { "@elianiva" },
|
maintainers = { "@elianiva" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.promql = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/MichaHoffmann/tree-sitter-promql",
|
||||||
|
files = { "src/parser.c" },
|
||||||
|
experimental = true,
|
||||||
|
},
|
||||||
|
maintainers = { "@MichaHoffmann" },
|
||||||
|
}
|
||||||
|
|
||||||
list.proto = {
|
list.proto = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/mitchellh/tree-sitter-proto",
|
url = "https://github.com/mitchellh/tree-sitter-proto",
|
||||||
|
|
|
||||||
54
queries/promql/highlights.scm
Normal file
54
queries/promql/highlights.scm
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
; highlights.scm
|
||||||
|
|
||||||
|
[
|
||||||
|
"*"
|
||||||
|
"/"
|
||||||
|
"%"
|
||||||
|
"+"
|
||||||
|
"-"
|
||||||
|
">"
|
||||||
|
">="
|
||||||
|
"<"
|
||||||
|
"<="
|
||||||
|
"="
|
||||||
|
"=~"
|
||||||
|
"!="
|
||||||
|
"!~"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"and"
|
||||||
|
"unless"
|
||||||
|
"or"
|
||||||
|
"bool"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
[
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
(float_literal) @float
|
||||||
|
(string_literal) @string
|
||||||
|
|
||||||
|
(metric_name) @type
|
||||||
|
(range_selection) @text.strong @type
|
||||||
|
(subquery_range_selection) @text.strong @type
|
||||||
|
|
||||||
|
(label_name) @field
|
||||||
|
(label_value) @text.underline @string.regex
|
||||||
|
|
||||||
|
(function_name) @function.call
|
||||||
|
|
||||||
|
[
|
||||||
|
"by"
|
||||||
|
"without"
|
||||||
|
] @function
|
||||||
|
|
||||||
|
(comment) @comment @spell
|
||||||
|
(ERROR) @error
|
||||||
|
|
||||||
1
queries/promql/injections.scm
Normal file
1
queries/promql/injections.scm
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
((label_value) @regex (#offset! @regex 0 1 0 -1))
|
||||||
|
|
@ -25,3 +25,29 @@
|
||||||
(block_sequence_item
|
(block_sequence_item
|
||||||
(block_node
|
(block_node
|
||||||
(block_scalar) @bash (#offset! @bash 0 1 0 0))))))
|
(block_scalar) @bash (#offset! @bash 0 1 0 0))))))
|
||||||
|
|
||||||
|
;; Prometheus Alertmanager ("expr")
|
||||||
|
(block_mapping_pair
|
||||||
|
key: (flow_node) @_expr (#eq? @_expr "expr")
|
||||||
|
value: (flow_node
|
||||||
|
(plain_scalar) @promql))
|
||||||
|
|
||||||
|
(block_mapping_pair
|
||||||
|
key: (flow_node) @_expr (#eq? @_expr "expr")
|
||||||
|
value: (block_node
|
||||||
|
(block_scalar) @promql (#offset! @promql 0 2 0 0)))
|
||||||
|
|
||||||
|
(block_mapping_pair
|
||||||
|
key: (flow_node) @_expr (#eq? @_expr "expr")
|
||||||
|
value: (block_node
|
||||||
|
(block_sequence
|
||||||
|
(block_sequence_item
|
||||||
|
(flow_node) @promql))))
|
||||||
|
|
||||||
|
(block_mapping_pair
|
||||||
|
key: (flow_node) @_expr (#eq @_expr "expr")
|
||||||
|
value: (block_node
|
||||||
|
(block_sequence
|
||||||
|
(block_sequence_item
|
||||||
|
(block_node
|
||||||
|
(block_scalar) @promql (#offset! @promql 0 2 0 0))))))
|
||||||
|
|
|
||||||
12
tests/query/injections/yaml/promql-on-prometheus-rules.yaml
Normal file
12
tests/query/injections/yaml/promql-on-prometheus-rules.yaml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
groups:
|
||||||
|
- name: Hardware alerts
|
||||||
|
rules:
|
||||||
|
- alert: Node down
|
||||||
|
expr: up{job="node_exporter"} == 0
|
||||||
|
# ^ promql
|
||||||
|
for: 3m
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
annotations:
|
||||||
|
title: Node {{ $labels.instance }} is down
|
||||||
|
description: Failed to scrape {{ $labels.job }} on {{ $labels.instance }} for more than 3 minutes. Node seems down.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue