on master help sign in
feat(lang): add go.mod and go.work support (#2197)
commit4144c9d2f2e712475d0ee54d029653f2c7dffff5 authorttys3 <41882455+ttys3@users.noreply.github.com> dateThu 21 Apr 2022, 00:16 (5 years ago) parent8d335f6
6 files changed+68−1
book/src/generated/lang-support.md+2 languages.toml+31−1 runtime/queries/gomod/highlights.scm+17 runtime/queries/gomod/injections.scm+2 runtime/queries/gowork/highlights.scm+14 runtime/queries/gowork/injections.scm+2
book/src/generated/lang-support.md+2
@@ -24,6 +24,8 @@
2424| gleam | ✓ | | | |
2525| glsl | ✓ | | ✓ | |
2626| go | ✓ | ✓ | ✓ | `gopls` |
27+| gomod | ✓ | | | `gopls` |
28+| gowork | ✓ | | | `gopls` |
2729| graphql | ✓ | | | |
2830| haskell | ✓ | | | `haskell-language-server-wrapper` |
2931| hcl | ✓ | | ✓ | `terraform-ls` |
languages.toml+31−1
@@ -268,6 +268,36 @@ args = { mode = "local", processId = "{0}" }
268268name = "go"
269269source = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "0fa917a7022d1cd2e9b779a6a8fc5dc7fad69c75" }
270270
271+[[language]]
272+name = "gomod"
273+scope = "source.gomod"
274+injection-regex = "gomod"
275+file-types = ["go.mod"]
276+roots = []
277+auto-format = true
278+comment-token = "//"
279+language-server = { command = "gopls" }
280+indent = { tab-width = 4, unit = "\t" }
281+
282+[[grammar]]
283+name = "gomod"
284+source = { git = "https://github.com/camdencheek/tree-sitter-go-mod", rev = "e8f51f8e4363a3d9a427e8f63f4c1bbc5ef5d8d0" }
285+
286+[[language]]
287+name = "gowork"
288+scope = "source.gowork"
289+injection-regex = "gowork"
290+file-types = ["go.work"]
291+roots = []
292+auto-format = true
293+comment-token = "//"
294+language-server = { command = "gopls" }
295+indent = { tab-width = 4, unit = "\t" }
296+
297+[[grammar]]
298+name = "gowork"
299+source = { git = "https://github.com/omertuc/tree-sitter-go-work", rev = "6dd9dd79fb51e9f2abc829d5e97b15015b6a8ae2" }
300+
271301[[language]]
272302name = "javascript"
273303scope = "source.js"
@@ -998,7 +1028,7 @@ file-types = ["kt", "kts"]
9981028roots = ["settings.gradle", "settings.gradle.kts"]
9991029comment-token = "//"
10001030indent = { tab-width = 4, unit = " " }
1001−language-server = { command = "kotlin-language-server" }
1031+language-server = { command = "kotlin-language-server" }
10021032
10031033[[grammar]]
10041034name = "kotlin"
runtime/queries/gomod/highlights.scmnew file+17
@@ -0,0 +1,17 @@
1+[
2+ "require"
3+ "replace"
4+ "go"
5+ "exclude"
6+ "retract"
7+ "module"
8+] @keyword
9+
10+"=>" @operator
11+
12+(comment) @comment
13+
14+[
15+(version)
16+(go_version)
17+] @string
runtime/queries/gomod/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/gowork/highlights.scmnew file+14
@@ -0,0 +1,14 @@
1+[
2+ "replace"
3+ "go"
4+ "use"
5+] @keyword
6+
7+"=>" @operator
8+
9+(comment) @comment
10+
11+[
12+(version)
13+(go_version)
14+] @string
runtime/queries/gowork/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))