aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhaown <51357674+chaozwn@users.noreply.github.com>2024-07-07 23:27:21 +0800
committerGitHub <noreply@github.com>2024-07-07 17:27:21 +0200
commitf9aa4f060ef73b487932696a84ed48b67eb1373e (patch)
tree1fd4107e229454c33eb0414a19ca05f380d34d76
parentfeat(ruby): highlights for special methods (#6735) (diff)
downloadnvim-treesitter-f9aa4f060ef73b487932696a84ed48b67eb1373e.tar
nvim-treesitter-f9aa4f060ef73b487932696a84ed48b67eb1373e.tar.gz
nvim-treesitter-f9aa4f060ef73b487932696a84ed48b67eb1373e.tar.bz2
nvim-treesitter-f9aa4f060ef73b487932696a84ed48b67eb1373e.tar.lz
nvim-treesitter-f9aa4f060ef73b487932696a84ed48b67eb1373e.tar.xz
nvim-treesitter-f9aa4f060ef73b487932696a84ed48b67eb1373e.tar.zst
nvim-treesitter-f9aa4f060ef73b487932696a84ed48b67eb1373e.zip
feat: add goctl parser and queries
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/goctl/folds.scm11
-rw-r--r--queries/goctl/highlights.scm79
-rw-r--r--queries/goctl/injections.scm3
6 files changed, 105 insertions, 0 deletions
diff --git a/README.md b/README.md
index f45c2bfe5..7946ca252 100644
--- a/README.md
+++ b/README.md
@@ -254,6 +254,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [GN (Generate Ninja)](https://github.com/amaanq/tree-sitter-gn) (maintained by @amaanq)
- [x] [gnuplot](https://github.com/dpezto/tree-sitter-gnuplot) (maintained by @dpezto)
- [x] [go](https://github.com/tree-sitter/tree-sitter-go) (maintained by @theHamsta, @WinWisely268)
+- [x] [goctl](https://github.com/chaozwn/tree-sitter-goctl) (maintained by @chaozwn)
- [x] [Godot Resources (gdresource)](https://github.com/PrestonKnopp/tree-sitter-godot-resource) (maintained by @pierpo)
- [x] [gomod](https://github.com/camdencheek/tree-sitter-go-mod) (maintained by @camdencheek)
- [x] [gosum](https://github.com/amaanq/tree-sitter-go-sum) (maintained by @amaanq)
diff --git a/lockfile.json b/lockfile.json
index 89b3ae6d4..0d02affec 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -242,6 +242,9 @@
"go": {
"revision": "7ee8d928db5202f6831a78f8112fd693bf69f98b"
},
+ "goctl": {
+ "revision": "f107937259c7ec4bb05f7e3d2c24b89ac36d4cc3"
+ },
"godot_resource": {
"revision": "2ffb90de47417018651fc3b970e5f6b67214dc9d"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 14555c57a..65d9313ae 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -757,6 +757,14 @@ list.go = {
maintainers = { "@theHamsta", "@WinWisely268" },
}
+list.goctl = {
+ install_info = {
+ url = "https://github.com/chaozwn/tree-sitter-goctl.git",
+ files = { "src/parser.c" },
+ },
+ maintainers = { "@chaozwn" },
+}
+
list.godot_resource = {
install_info = {
url = "https://github.com/PrestonKnopp/tree-sitter-godot-resource",
diff --git a/queries/goctl/folds.scm b/queries/goctl/folds.scm
new file mode 100644
index 000000000..704928675
--- /dev/null
+++ b/queries/goctl/folds.scm
@@ -0,0 +1,11 @@
+[
+ (typeGroupSpec)
+ (typeSingleSpec)
+ (typeStruct)
+ (serviceSpec)
+ (serviceBody)
+ (importStatement)
+ (serviceServerSpec)
+ (infoStatement)
+ (structType)
+] @fold
diff --git a/queries/goctl/highlights.scm b/queries/goctl/highlights.scm
new file mode 100644
index 000000000..a4b809a1c
--- /dev/null
+++ b/queries/goctl/highlights.scm
@@ -0,0 +1,79 @@
+; Key Symbol
+"=" @operator
+
+[
+ "."
+ ","
+ ":"
+ ";"
+] @punctuation.delimiter
+
+[
+ "("
+ ")"
+ "{"
+ "}"
+ "["
+ "]"
+] @punctuation.bracket
+
+; Keywords
+[
+ "syntax"
+ "info"
+ "service"
+] @keyword
+
+"import" @keyword.import
+
+"returns" @keyword.return
+
+[
+ "type"
+ "struct"
+] @keyword.type
+
+[
+ "@doc"
+ "@handler"
+ "@server"
+] @attribute
+
+; Service
+(serviceName) @type
+
+; Httpmethod
+(HTTPMETHOD) @keyword.operator
+
+; Field
+(fieldType) @type.builtin
+
+(fieldName) @variable.member
+
+(anonymousField) @variable.member
+
+; Functions
+(handlerValue) @function.method
+
+; Strings
+(VALUE) @string
+
+(tag) @string.documentation
+
+(PATH) @string.special.path
+
+; Comments
+(comment) @comment @spell
+
+(key) @variable.member
+
+(identValue) @string
+
+(DURATION) @number
+
+(NUMBER) @number
+
+; Struct
+(structNameId) @type
+
+(body) @type
diff --git a/queries/goctl/injections.scm b/queries/goctl/injections.scm
new file mode 100644
index 000000000..a53abee57
--- /dev/null
+++ b/queries/goctl/injections.scm
@@ -0,0 +1,3 @@
+; Inject comment language for goctl
+((comment) @injection.content
+ (#set! injection.language "comment"))