diff --git a/README.md b/README.md index 45edb3612..666d264b6 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lockfile.json b/lockfile.json index ee0f5de10..437e104a3 100644 --- a/lockfile.json +++ b/lockfile.json @@ -338,6 +338,9 @@ "proto": { "revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f" }, + "prql": { + "revision": "3f27cac466f030ee7d985d91eba5470e01dd21ea" + }, "pug": { "revision": "884e225b5ecca5d885ae627275f16ef648acd42e" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 743f0f3e5..d0b933779 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -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", diff --git a/queries/prql/highlights.scm b/queries/prql/highlights.scm new file mode 100644 index 000000000..3810bdda4 --- /dev/null +++ b/queries/prql/highlights.scm @@ -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 + + diff --git a/queries/prql/injections.scm b/queries/prql/injections.scm new file mode 100644 index 000000000..a6d4ccb12 --- /dev/null +++ b/queries/prql/injections.scm @@ -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