From 3b05ef44927cc245d2c68873d0a526592d3f93cd Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Thu, 16 Dec 2021 22:40:06 +0100 Subject: Add support for new golang `go.work` files The new golang 1.18 version (currently in beta) [introduced](https://github.com/golang/go/issues/45713) a new file type called `go.work`. This commit adds support for the syntax of that file using the https://github.com/omertuc/tree-sitter-go-work repository That repository is heavily based on previous work in the https://github.com/camdencheek/tree-sitter-go-mod repository, with a few minor changes to make it work on the very similar `go.work` files. --- README.md | 1 + ftdetect/gowork.vim | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 10 ++++++++++ queries/gomod/injections.scm | 1 + queries/gowork/highlights.scm | 14 ++++++++++++++ queries/gowork/injections.scm | 1 + 7 files changed, 31 insertions(+) create mode 100644 ftdetect/gowork.vim create mode 100644 queries/gomod/injections.scm create mode 100644 queries/gowork/highlights.scm create mode 100644 queries/gowork/injections.scm diff --git a/README.md b/README.md index ec9876d6..8fef504b 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [go](https://github.com/tree-sitter/tree-sitter-go) (maintained by @theHamsta, @WinWisely268) - [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] [gowork](https://github.com/omertuc/tree-sitter-go-work) (maintained by @omertuc) - [x] [graphql](https://github.com/bkegley/tree-sitter-graphql) (maintained by @bkegley) - [ ] [haskell](https://github.com/tree-sitter/tree-sitter-haskell) - [x] [hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann) diff --git a/ftdetect/gowork.vim b/ftdetect/gowork.vim new file mode 100644 index 00000000..47edcb63 --- /dev/null +++ b/ftdetect/gowork.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile go.work set filetype=gowork diff --git a/lockfile.json b/lockfile.json index b3391b43..ca0a6f70 100644 --- a/lockfile.json +++ b/lockfile.json @@ -89,6 +89,9 @@ "gomod": { "revision": "3cbcb572109ea0bc476a292208722c326c9e6c3a" }, + "gowork": { + "revision": "aafab008b4c855f20871cb978e41cf3b94466c70" + }, "graphql": { "revision": "5e66e961eee421786bdda8495ed1db045e06b5fe" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 57280e82..304166ef 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -184,6 +184,16 @@ list.gomod = { filetype = "gomod", } +list.gowork = { + install_info = { + url = "https://github.com/omertuc/tree-sitter-go-work", + branch = "main", + files = { "src/parser.c" }, + }, + maintainers = { "@omertuc" }, + filetype = "gowork", +} + list.graphql = { install_info = { url = "https://github.com/bkegley/tree-sitter-graphql", diff --git a/queries/gomod/injections.scm b/queries/gomod/injections.scm new file mode 100644 index 00000000..4bb7d675 --- /dev/null +++ b/queries/gomod/injections.scm @@ -0,0 +1 @@ +(comment) @comment diff --git a/queries/gowork/highlights.scm b/queries/gowork/highlights.scm new file mode 100644 index 00000000..9c84bcc4 --- /dev/null +++ b/queries/gowork/highlights.scm @@ -0,0 +1,14 @@ +[ + "replace" + "go" + "use" +] @keyword + +"=>" @operator + +(comment) @comment + +[ +(version) +(go_version) +] @string diff --git a/queries/gowork/injections.scm b/queries/gowork/injections.scm new file mode 100644 index 00000000..4bb7d675 --- /dev/null +++ b/queries/gowork/injections.scm @@ -0,0 +1 @@ +(comment) @comment -- cgit v1.2.3