feat: add prql (#4393)

* feat: add prql

* highlights(prql): null as constant.builtin

* highlights(prql): add missing kwd, update queries

* highlights(prql): remove redundant queries

* highlights(prql): make `->` a delimiter

* highlights(prql): instructions to `@method.call`
This commit is contained in:
Matthias Q 2023-03-01 21:21:11 +01:00 committed by GitHub
parent 9dd1b9c097
commit 0572657d4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 168 additions and 0 deletions

View file

@ -286,6 +286,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [Path of Exile item filter](https://github.com/ObserverOfTime/tree-sitter-poe-filter) (experimental, maintained by @ObserverOfTime)
- [x] [prisma](https://github.com/victorhqc/tree-sitter-prisma) (maintained by @elianiva)
- [x] [proto](https://github.com/mitchellh/tree-sitter-proto) (maintained by @fsouza)
- [x] [prql](https://github.com/PRQL/tree-sitter-prql) (maintained by @matthias-Q)
- [x] [pug](https://github.com/zealot128/tree-sitter-pug) (experimental, maintained by @zealot128)
- [x] [python](https://github.com/tree-sitter/tree-sitter-python) (maintained by @stsewd, @theHamsta)
- [x] [ql](https://github.com/tree-sitter/tree-sitter-ql) (maintained by @pwntester)

View file

@ -338,6 +338,9 @@
"proto": {
"revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f"
},
"prql": {
"revision": "3f27cac466f030ee7d985d91eba5470e01dd21ea"
},
"pug": {
"revision": "884e225b5ecca5d885ae627275f16ef648acd42e"
},

View file

@ -1086,6 +1086,16 @@ list.proto = {
filetype = "proto",
}
list.prql = {
install_info = {
url = "https://github.com/PRQL/tree-sitter-prql",
branch = "main",
files = { "src/parser.c" },
},
maintainers = { "@matthias-Q" },
filetype = "prql",
}
list.pug = {
install_info = {
url = "https://github.com/zealot128/tree-sitter-pug",

141
queries/prql/highlights.scm Normal file
View file

@ -0,0 +1,141 @@
[
(keyword_from)
(keyword_filter)
(keyword_derive)
(keyword_group)
(keyword_aggregate)
(keyword_sort)
(keyword_take)
(keyword_window)
(keyword_join)
(keyword_select)
(keyword_switch)
(keyword_append)
(keyword_remove)
(keyword_intersect)
(keyword_rolling)
(keyword_rows)
(keyword_expanding)
(keyword_let)
(keyword_prql)
(keyword_from_text)
] @keyword
[
(literal)
(f_string)
(s_string)
] @string
(assignment
alias: (field) @field)
alias: (identifier) @field
(comment) @comment @spell
(keyword_func) @keyword.function
(function_call
(identifier) @function.call)
[
"+"
"-"
"*"
"/"
"="
"=="
"<"
"<="
"!="
">="
">"
(bang)
] @operator
[
"("
")"
"["
"]"
] @punctuation.bracket
[
","
"."
(pipe)
"->"
] @punctuation.delimiter
(integer) @number
(decimal_number) @float
[
(keyword_min)
(keyword_max)
(keyword_count)
(keyword_count_distinct)
(keyword_average)
(keyword_avg)
(keyword_sum)
(keyword_stddev)
(keyword_count)
] @function
[
(keyword_side)
(keyword_format)
] @attribute
[
(keyword_version)
(keyword_target)
] @type.qualifier
(target) @function.builtin
[
(date)
(time)
(timestamp)
] @string.special
[
(keyword_left)
(keyword_inner)
(keyword_right)
(keyword_full)
(keyword_csv)
(keyword_json)
] @method.call
[
(keyword_true)
(keyword_false)
] @boolean
[
(keyword_and)
(keyword_or)
(keyword_in)
] @keyword.operator
(function_definition
(keyword_func)
name: (identifier) @function)
(parameter
(identifier) @parameter)
(variable
(keyword_let)
name: (identifier) @constant)
(keyword_null) @constant.builtin

View file

@ -0,0 +1,13 @@
(
(s_string) @sql
(#offset! @sql 0 2 0 -1)
)
(from_text
(keyword_from_text)
(keyword_json)
(literal) @json
(#offset! @json 0 3 0 -3)
)
(comment) @comment