From c8e4a024b75b415c6e6c1614546a89c965268902 Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Wed, 20 Apr 2022 19:11:51 +0800 Subject: [PATCH 1/6] feat(lang): add go.mod support --- languages.toml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index fb54427d8bf2..abdac19bea44 100644 --- a/languages.toml +++ b/languages.toml @@ -268,6 +268,23 @@ 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" } +# TODO: gopls needs utf-8 offsets? +indent = { tab-width = 4, unit = "\t" } +grammar = "gomod" + +[[grammar]] +name = "gomod" +source = { git = "https://github.com/camdencheek/tree-sitter-go-mod", rev = "e8f51f8e4363a3d9a427e8f63f4c1bbc5ef5d8d0" } + [[language]] name = "javascript" scope = "source.js" @@ -998,7 +1015,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" From d6be17b44d2bd413edf58624c76727075f47170c Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Wed, 20 Apr 2022 22:11:36 +0800 Subject: [PATCH 2/6] chore: add gomod and gowork queries --- runtime/queries/gomod/highlights.scm | 17 +++++++++++++++++ runtime/queries/gomod/injections.scm | 1 + runtime/queries/gowork/highlights.scm | 14 ++++++++++++++ runtime/queries/gowork/injections.scm | 1 + 4 files changed, 33 insertions(+) create mode 100644 runtime/queries/gomod/highlights.scm create mode 100644 runtime/queries/gomod/injections.scm create mode 100644 runtime/queries/gowork/highlights.scm create mode 100644 runtime/queries/gowork/injections.scm diff --git a/runtime/queries/gomod/highlights.scm b/runtime/queries/gomod/highlights.scm new file mode 100644 index 000000000000..63e1f0128a33 --- /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 000000000000..4bb7d675dfac --- /dev/null +++ b/runtime/queries/gomod/injections.scm @@ -0,0 +1 @@ +(comment) @comment diff --git a/runtime/queries/gowork/highlights.scm b/runtime/queries/gowork/highlights.scm new file mode 100644 index 000000000000..9c84bcc44963 --- /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 000000000000..4bb7d675dfac --- /dev/null +++ b/runtime/queries/gowork/injections.scm @@ -0,0 +1 @@ +(comment) @comment From 269f7a7c47976a5933806d2e298ee40eddc57b58 Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Wed, 20 Apr 2022 22:13:47 +0800 Subject: [PATCH 3/6] feat(treesitter): add go.work support --- languages.toml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/languages.toml b/languages.toml index abdac19bea44..91c73572f7b8 100644 --- a/languages.toml +++ b/languages.toml @@ -277,14 +277,27 @@ roots = [] auto-format = true comment-token = "//" language-server = { command = "gopls" } -# TODO: gopls needs utf-8 offsets? indent = { tab-width = 4, unit = "\t" } -grammar = "gomod" [[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" From 89260c27e7215b114f2c98649b9d90ac3ae225df Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Wed, 20 Apr 2022 23:03:20 +0800 Subject: [PATCH 4/6] chore: fix comment injections --- runtime/queries/gomod/injections.scm | 4 +++- runtime/queries/gowork/injections.scm | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/queries/gomod/injections.scm b/runtime/queries/gomod/injections.scm index 4bb7d675dfac..ffe4da87b101 100644 --- a/runtime/queries/gomod/injections.scm +++ b/runtime/queries/gomod/injections.scm @@ -1 +1,3 @@ -(comment) @comment +((comment) @injection.content + (#set! injection.langauge "comment")) + diff --git a/runtime/queries/gowork/injections.scm b/runtime/queries/gowork/injections.scm index 4bb7d675dfac..82655fc404e9 100644 --- a/runtime/queries/gowork/injections.scm +++ b/runtime/queries/gowork/injections.scm @@ -1 +1,3 @@ -(comment) @comment +((comment) @injection.content + (#set! injection.langauge "comment")) + \ No newline at end of file From f7de73f17de42525e0cb12f43f59f1714e7999d5 Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Wed, 20 Apr 2022 23:14:30 +0800 Subject: [PATCH 5/6] docs: update book/src/generated/lang-support.md --- book/src/generated/lang-support.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index a1746c4c4897..ef3c94513984 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` | From ac0a8c77a8fa78dcf8232c0ec40fb250dc6d74c9 Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Thu, 21 Apr 2022 00:05:48 +0800 Subject: [PATCH 6/6] fixup! docs: update book/src/generated/lang-support.md --- runtime/queries/gomod/injections.scm | 3 +-- runtime/queries/gowork/injections.scm | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/runtime/queries/gomod/injections.scm b/runtime/queries/gomod/injections.scm index ffe4da87b101..321c90add371 100644 --- a/runtime/queries/gomod/injections.scm +++ b/runtime/queries/gomod/injections.scm @@ -1,3 +1,2 @@ ((comment) @injection.content - (#set! injection.langauge "comment")) - + (#set! injection.language "comment")) diff --git a/runtime/queries/gowork/injections.scm b/runtime/queries/gowork/injections.scm index 82655fc404e9..321c90add371 100644 --- a/runtime/queries/gowork/injections.scm +++ b/runtime/queries/gowork/injections.scm @@ -1,3 +1,2 @@ ((comment) @injection.content - (#set! injection.langauge "comment")) - \ No newline at end of file + (#set! injection.language "comment"))