Skip to content

Commit

Permalink
feat(lang): add go.mod and go.work support (#2197)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys3 authored Apr 20, 2022
1 parent 8d335f6 commit 4144c9d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 1 deletion.
2 changes: 2 additions & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
| gleam || | | |
| glsl || || |
| go |||| `gopls` |
| gomod || | | `gopls` |
| gowork || | | `gopls` |
| graphql || | | |
| haskell || | | `haskell-language-server-wrapper` |
| hcl || || `terraform-ls` |
Expand Down
32 changes: 31 additions & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,36 @@ args = { mode = "local", processId = "{0}" }
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"
Expand Down Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions runtime/queries/gomod/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
"require"
"replace"
"go"
"exclude"
"retract"
"module"
] @keyword

"=>" @operator

(comment) @comment

[
(version)
(go_version)
] @string
2 changes: 2 additions & 0 deletions runtime/queries/gomod/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))
14 changes: 14 additions & 0 deletions runtime/queries/gowork/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
"replace"
"go"
"use"
] @keyword

"=>" @operator

(comment) @comment

[
(version)
(go_version)
] @string
2 changes: 2 additions & 0 deletions runtime/queries/gowork/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))

0 comments on commit 4144c9d

Please sign in to comment.