feat(vrl): Add vrl parser and queries

This commit is contained in:
belltoy 2024-07-28 13:15:43 +08:00 committed by Christian Clason
parent cc69a061fe
commit 9f8c99e980
8 changed files with 172 additions and 0 deletions

View file

@ -451,6 +451,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [vhs](https://github.com/charmbracelet/tree-sitter-vhs) (maintained by @caarlos0)
- [x] [vim](https://github.com/neovim/tree-sitter-vim) (maintained by @clason)
- [x] [vimdoc](https://github.com/neovim/tree-sitter-vimdoc) (maintained by @clason)
- [x] [vrl](https://github.com/belltoy/tree-sitter-vrl) (maintained by @belltoy)
- [x] [vue](https://github.com/tree-sitter-grammars/tree-sitter-vue) (maintained by @WhyNotHugo, @lucario387)
- [x] [wgsl](https://github.com/szebniok/tree-sitter-wgsl) (maintained by @szebniok)
- [x] [wgsl_bevy](https://github.com/theHamsta/tree-sitter-wgsl-bevy) (maintained by @theHamsta)

View file

@ -833,6 +833,9 @@
"vimdoc": {
"revision": "2249c44ecd3f5cf22da3dcccfb74f816ddb29245"
},
"vrl": {
"revision": "274b3ce63f72aa8ffea18e7fc280d3062d28f0ba"
},
"vue": {
"revision": "22bdfa6c9fc0f5ffa44c6e938ec46869ac8a99ff"
},

View file

@ -2398,6 +2398,14 @@ list.vimdoc = {
maintainers = { "@clason" },
}
list.vrl = {
install_info = {
url = "https://github.com/belltoy/tree-sitter-vrl",
files = { "src/parser.c" },
},
maintainers = { "@belltoy" },
}
list.vue = {
install_info = {
url = "https://github.com/tree-sitter-grammars/tree-sitter-vue",

6
queries/vrl/folds.scm Normal file
View file

@ -0,0 +1,6 @@
[
(block)
(object)
(array)
(arguments)
] @fold

108
queries/vrl/highlights.scm Normal file
View file

@ -0,0 +1,108 @@
(comment) @comment @spell
(null) @constant.builtin
(timestamp) @constant
(closure_variables
(ident) @variable.parameter)
(integer) @number
(float) @number.float
[
(string)
(raw_string)
] @string
[
(raw_string_escape_sequence)
(escape_sequence)
(regex_escape_sequence)
] @string.escape
(string_template
"{{" @punctuation.special
(_)
"}}" @punctuation.special)
(regex) @string.regexp
(boolean) @boolean
(ident) @variable
(noop) @variable.builtin
(function_call
(ident) @function.call)
; VRL queries
(query
[
(event)
(metadata)
] @variable.builtin)
(query
(path
[
(field) @variable
(string) @string
(index) @number
"." @punctuation.delimiter
]))
"return" @keyword.return
"abort" @keyword.exception
[
"if"
"else"
] @keyword.conditional
[
"="
"=="
"!="
"|="
">"
">="
"<"
"<="
"+"
"-"
"*"
"/"
"&&"
"||"
"??"
"|"
"!"
] @operator
[
"->"
":"
";"
","
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(closure_variables
"|" @punctuation.bracket)
(function_call
(ident) @keyword.exception
"!"
(#any-of? @keyword.exception "assert" "assert_eq"))

24
queries/vrl/indents.scm Normal file
View file

@ -0,0 +1,24 @@
[
(block)
(object)
(array)
(arguments)
] @indent.begin
(block
"}" @indent.end)
(object
"}" @indent.end)
(array
"]" @indent.end)
(arguments
")" @indent.end)
[
")"
"]"
"}"
] @indent.branch

View file

@ -0,0 +1,6 @@
((comment) @injection.content
(#set! injection.language "comment"))
((regex) @injection.content
(#offset! @injection.content 0 2 0 -1)
(#set! injection.language "regex"))

16
queries/vrl/locals.scm Normal file
View file

@ -0,0 +1,16 @@
(closure_variables
(ident) @local.definition.parameter)
[
(ident)
(metadata)
] @local.reference
(query
(event) @local.reference)
[
(block)
(closure)
(if_statement)
] @local.scope