Skip to content

Commit

Permalink
feat(prql): add prql support (helix-editor#6126)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-Q authored and estin committed Mar 4, 2023
1 parent 0fe34bd commit f08f04a
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
| prisma || | | `prisma-language-server` |
| prolog | | | | `swipl` |
| protobuf || || |
| prql || | | |
| purescript || | | `purescript-language-server` |
| python |||| `pylsp` |
| qml || || `qmlls` |
Expand Down
13 changes: 13 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,19 @@ indent = { tab-width = 2, unit = " " }
name = "yuck"
source = { git = "https://github.com/Philipp-M/tree-sitter-yuck", rev = "9e97da5773f82123a8c8cccf8f7e795d140ed7d1" }

[[language]]
name = "prql"
scope = "source.prql"
injection-regex = "prql"
file-types = ["prql"]
roots = []
comment-token = "#"
indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "prql"
source = { git = "https://github.com/PRQL/tree-sitter-prql", rev = "3f27cac466f030ee7d985d91eba5470e01dd21ea" }

[[language]]
name = "po"
scope = "source.po"
Expand Down
136 changes: 136 additions & 0 deletions runtime/queries/prql/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
[
(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) @string

(assignment
alias: (field) @variable.other.member)

alias: (identifier) @variable.other.member

(f_string) @string.special
(s_string) @string.special

(comment) @comment

(keyword_func) @keyword.function

(function_call
(identifier) @function)

[
"+"
"-"
"*"
"/"
"="
"=="
"<"
"<="
"!="
">="
">"
"->"
(bang)
] @operator

[
"("
")"
"["
"]"
] @punctuation.bracket

[
","
"."
(pipe)
] @punctuation.delimiter

(literal
(integer) @constant.numeric.integer)

(integer) @constant.numeric.integer

(literal
(decimal_number) @constant.numeric.float)

(decimal_number) @constant.numeric.float

[
(keyword_min)
(keyword_max)
(keyword_count)
(keyword_count_distinct)
(keyword_average)
(keyword_avg)
(keyword_sum)
(keyword_stddev)
(keyword_count)
] @function

[
(keyword_side)
(keyword_version)
(keyword_target)
(keyword_null)
(keyword_format)
] @attribute

(target) @function.builtin

[
(date)
(time)
(timestamp)
] @string.special

[
(keyword_left)
(keyword_inner)
(keyword_right)
(keyword_full)
(keyword_csv)
(keyword_json)
] @function.method

[
(keyword_true)
(keyword_false)
] @constant.builtin.boolean

[
(keyword_and)
(keyword_or)
] @keyword.operator

(function_definition
(keyword_func)
name: (identifier) @function)

(parameter
(identifier) @variable.parameter)

(variable
(keyword_let)
name: (identifier) @constant)
8 changes: 8 additions & 0 deletions runtime/queries/prql/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
((s_string) @injection.content
(#set! injection.language "sql"))

(from_text
(keyword_from_text)
(keyword_json)
(literal) @injection.content
(#set! injection.language "json"))

0 comments on commit f08f04a

Please sign in to comment.