aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCezary Drożak <cezdro@alatek.com.pl>2022-09-07 10:30:43 +0200
committerStephan Seitz <stephan.seitz@fau.de>2022-09-10 11:09:10 -0700
commitf2d3d509d95943c00975c8a83dbb35907262e30b (patch)
treed4da824548cb7cd5eafefba1f799dadf40f7ce5a
parenthighlights(phpdoc): check spell within `text` (diff)
downloadnvim-treesitter-f2d3d509d95943c00975c8a83dbb35907262e30b.tar
nvim-treesitter-f2d3d509d95943c00975c8a83dbb35907262e30b.tar.gz
nvim-treesitter-f2d3d509d95943c00975c8a83dbb35907262e30b.tar.bz2
nvim-treesitter-f2d3d509d95943c00975c8a83dbb35907262e30b.tar.lz
nvim-treesitter-f2d3d509d95943c00975c8a83dbb35907262e30b.tar.xz
nvim-treesitter-f2d3d509d95943c00975c8a83dbb35907262e30b.tar.zst
nvim-treesitter-f2d3d509d95943c00975c8a83dbb35907262e30b.zip
feat: add jsonnet
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/jsonnet/highlights.scm76
4 files changed, 88 insertions, 0 deletions
diff --git a/README.md b/README.md
index b636ad5aa..2804fbfdd 100644
--- a/README.md
+++ b/README.md
@@ -220,6 +220,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) (maintained by @steelsojka)
- [x] [json](https://github.com/tree-sitter/tree-sitter-json) (maintained by @steelsojka)
- [x] [json5](https://github.com/Joakker/tree-sitter-json5) (maintained by @Joakker)
+- [x] [Jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) (maintained by @nawordar)
- [x] [JSON with comments](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git) (maintained by @WhyNotHugo)
- [x] [julia](https://github.com/tree-sitter/tree-sitter-julia) (maintained by @mroavi, @theHamsta)
- [x] [kotlin](https://github.com/fwcd/tree-sitter-kotlin) (maintained by @SalBakraa)
diff --git a/lockfile.json b/lockfile.json
index 3d338a747..9ad2d1fa5 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -176,6 +176,9 @@
"jsonc": {
"revision": "02b01653c8a1c198ae7287d566efa86a135b30d5"
},
+ "jsonnet": {
+ "revision": "0475a5017ad7dc84845d1d33187f2321abcb261d"
+ },
"julia": {
"revision": "0572cebf7b8e8ef5990b4d1e7f44f0b36f62922c"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 7abe2aa95..208ae189b 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -370,6 +370,14 @@ list.json = {
maintainers = { "@steelsojka" },
}
+list.jsonnet = {
+ install_info = {
+ url = "https://github.com/sourcegraph/tree-sitter-jsonnet",
+ files = { "src/parser.c", "src/scanner.c" },
+ },
+ maintainers = { "@nawordar" },
+}
+
list.css = {
install_info = {
url = "https://github.com/tree-sitter/tree-sitter-css",
diff --git a/queries/jsonnet/highlights.scm b/queries/jsonnet/highlights.scm
new file mode 100644
index 000000000..eb8d22be9
--- /dev/null
+++ b/queries/jsonnet/highlights.scm
@@ -0,0 +1,76 @@
+[
+ (true)
+ (false)
+] @boolean
+
+(comment) @comment
+(id) @variable
+(import) @include
+(null) @constant.builtin
+(number) @number
+(string) @string
+
+(fieldname (id) @label)
+
+[
+ "["
+ "]"
+ "{"
+ "}"
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ "."
+ ","
+ ";"
+ ":"
+ "::"
+ ":::"
+] @punctuation.delimiter
+
+(expr
+ operator: (_) @operator)
+[
+ "+"
+ "="
+] @operator
+
+"in" @keyword.operator
+
+[
+ (local)
+ "assert"
+] @keyword
+
+[
+ "else"
+ "if"
+ "then"
+] @conditional
+
+[
+ (dollar)
+ (self)
+] @variable.builtin
+((id) @variable.builtin
+ (#eq? @variable.builtin "std"))
+
+; Function declaration
+(bind
+ function: (id) @function
+ params: (params
+ (param
+ identifier: (id) @parameter)))
+
+; Function call
+(expr
+ (expr (id) @function.call)
+ "("
+ (args
+ (named_argument
+ (id) @parameter))?
+ ")")
+
+(ERROR) @error