aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorttys32022-04-20 16:16:02 +0000
committerGitHub2022-04-20 16:16:02 +0000
commit4144c9d2f2e712475d0ee54d029653f2c7dffff5 (patch)
tree1b2a61b218abe9870f0793c56f7025e5ebbc2e7c
parent8d335f63f00755c33721b656f289357d3bd5dfb7 (diff)
feat(lang): add go.mod and go.work support (#2197)
-rw-r--r--book/src/generated/lang-support.md2
-rw-r--r--languages.toml32
-rw-r--r--runtime/queries/gomod/highlights.scm17
-rw-r--r--runtime/queries/gomod/injections.scm2
-rw-r--r--runtime/queries/gowork/highlights.scm14
-rw-r--r--runtime/queries/gowork/injections.scm2
6 files changed, 68 insertions, 1 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index a1746c4c..ef3c9451 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -24,6 +24,8 @@
| gleam | ✓ | | | |
| glsl | ✓ | | ✓ | |
| go | ✓ | ✓ | ✓ | `gopls` |
+| gomod | ✓ | | | `gopls` |
+| gowork | ✓ | | | `gopls` |
| graphql | ✓ | | | |
| haskell | ✓ | | | `haskell-language-server-wrapper` |
| hcl | ✓ | | ✓ | `terraform-ls` |
diff --git a/languages.toml b/languages.toml
index fdf794a6..76b4ca16 100644
--- a/languages.toml
+++ b/languages.toml
@@ -269,6 +269,36 @@ name = "go"
source = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "0fa917a7022d1cd2e9b779a6a8fc5dc7fad69c75" }
[[language]]
+name = "gomod"
+scope = "source.gomod"
+injection-regex = "gomod"
+file-types = ["go.mod"]
+roots = []
+auto-format = true
+comment-token = "//"
+language-server = { command = "gopls" }
+indent = { tab-width = 4, unit = "\t" }
+
+[[grammar]]
+name = "gomod"
+source = { git = "https://github.com/camdencheek/tree-sitter-go-mod", rev = "e8f51f8e4363a3d9a427e8f63f4c1bbc5ef5d8d0" }
+
+[[language]]
+name = "gowork"
+scope = "source.gowork"
+injection-regex = "gowork"
+file-types = ["go.work"]
+roots = []
+auto-format = true
+comment-token = "//"
+language-server = { command = "gopls" }
+indent = { tab-width = 4, unit = "\t" }
+
+[[grammar]]
+name = "gowork"
+source = { git = "https://github.com/omertuc/tree-sitter-go-work", rev = "6dd9dd79fb51e9f2abc829d5e97b15015b6a8ae2" }
+
+[[language]]
name = "javascript"
scope = "source.js"
injection-regex = "^(js|javascript)$"
@@ -998,7 +1028,7 @@ file-types = ["kt", "kts"]
roots = ["settings.gradle", "settings.gradle.kts"]
comment-token = "//"
indent = { tab-width = 4, unit = " " }
-language-server = { command = "kotlin-language-server" }
+language-server = { command = "kotlin-language-server" }
[[grammar]]
name = "kotlin"
diff --git a/runtime/queries/gomod/highlights.scm b/runtime/queries/gomod/highlights.scm
new file mode 100644
index 00000000..63e1f012
--- /dev/null
+++ b/runtime/queries/gomod/highlights.scm
@@ -0,0 +1,17 @@
+[
+ "require"
+ "replace"
+ "go"
+ "exclude"
+ "retract"
+ "module"
+] @keyword
+
+"=>" @operator
+
+(comment) @comment
+
+[
+(version)
+(go_version)
+] @string
diff --git a/runtime/queries/gomod/injections.scm b/runtime/queries/gomod/injections.scm
new file mode 100644
index 00000000..321c90ad
--- /dev/null
+++ b/runtime/queries/gomod/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/gowork/highlights.scm b/runtime/queries/gowork/highlights.scm
new file mode 100644
index 00000000..9c84bcc4
--- /dev/null
+++ b/runtime/queries/gowork/highlights.scm
@@ -0,0 +1,14 @@
+[
+ "replace"
+ "go"
+ "use"
+] @keyword
+
+"=>" @operator
+
+(comment) @comment
+
+[
+(version)
+(go_version)
+] @string
diff --git a/runtime/queries/gowork/injections.scm b/runtime/queries/gowork/injections.scm
new file mode 100644
index 00000000..321c90ad
--- /dev/null
+++ b/runtime/queries/gowork/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))