diff --git a/README.md b/README.md
index 0cbb5a6..f75f8a1 100644
--- a/README.md
+++ b/README.md
@@ -64,24 +64,6 @@ require("gopher").setup {
}
```
-
-
- For named tests to work you have to install gotests from develop branch. Next code snippets could be placed into the build step in the Lazy plugin declaration
-
-
- ```lua
- -- using mason-tool-installer
- require("mason-tool-installer").setup {
- ensure_installed = {
- { "gotests", version = "develop" },
- }
- }
-
- -- using `vim.fn.jobstart`
- vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
- ```
-
-
## Features
@@ -148,6 +130,8 @@ require("gopher").setup {
require("gopher").test.exported()
require("gopher").test.all()
```
+
+ For named tests see `:h gopher.nvim-gotests-named`
diff --git a/doc/gopher.nvim.txt b/doc/gopher.nvim.txt
index 3497b5f..236bf00 100644
--- a/doc/gopher.nvim.txt
+++ b/doc/gopher.nvim.txt
@@ -13,6 +13,7 @@ Table of Contents
Configuration...........................................|gopher.nvim-config|
Modifty struct tags................................|gopher.nvim-struct-tags|
Auto implementation of interface methods..................|gopher.nvim-impl|
+ Generating unit tests boilerplate......................|gopher.nvim-gotests|
Setup `nvim-dap` for Go......................................|gopher.nvim-dap|
------------------------------------------------------------------------------
@@ -145,6 +146,51 @@ simple example:
<
+==============================================================================
+------------------------------------------------------------------------------
+ *gopher.nvim-gotests*
+gotests is utilizing the `gotests` tool to generate unit tests boilerplate.
+Usage ~
+
+- generate unit test for spesisfic function/method
+ - to specift the function/method put your cursor on it
+ - run `:GoTestAdd`
+
+- generate unit tests for all functions/methods in current file
+ - run `:GoTestsAll`
+
+- generate unit tests only for exported(public) functions/methods
+ - run `:GoTestsExp`
+
+you can also specify the template to use for generating the tests. see |gopher.nvim-config|
+more details about templates can be found at: https://github.com/cweill/gotests
+
+
+------------------------------------------------------------------------------
+ *gopher.nvim-gotests-named*
+
+if you prefare using named tests, you can enable it in the config.
+but you would need to install `gotests@develop` because stable version doesn't support this feature.
+you can do it with:
+>lua
+ -- simply run go get in your shell:
+ go install github.com/cweill/gotests/...@develop
+
+ -- if you want to install it within neovim, you can use one of this:
+
+ vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
+
+ -- or if you want to use mason:
+ require("mason-tool-installer").setup {
+ ensure_installed = {
+ { "gotests", version = "develop" },
+ }
+ }
+<
+
+if you choose to install `gotests` within neovim, i recommend adding it to your `build` section in your |lazy.nvim|
+
+
==============================================================================
------------------------------------------------------------------------------
*gopher.nvim-dap*
diff --git a/lua/gopher/gotests.lua b/lua/gopher/gotests.lua
index 0ef52cc..3d96a05 100644
--- a/lua/gopher/gotests.lua
+++ b/lua/gopher/gotests.lua
@@ -1,3 +1,44 @@
+---@toc_entry Generating unit tests boilerplate
+---@tag gopher.nvim-gotests
+---@text gotests is utilizing the `gotests` tool to generate unit tests boilerplate.
+---@usage
+--- - generate unit test for spesisfic function/method
+--- - to specift the function/method put your cursor on it
+--- - run `:GoTestAdd`
+---
+--- - generate unit tests for all functions/methods in current file
+--- - run `:GoTestsAll`
+---
+--- - generate unit tests only for exported(public) functions/methods
+--- - run `:GoTestsExp`
+---
+--- you can also specify the template to use for generating the tests. see |gopher.nvim-config|
+--- more details about templates can be found at: https://github.com/cweill/gotests
+---
+
+---@tag gopher.nvim-gotests-named
+---@text
+--- if you prefare using named tests, you can enable it in the config.
+--- but you would need to install `gotests@develop` because stable version doesn't support this feature.
+--- you can do it with:
+--- >lua
+--- -- simply run go get in your shell:
+--- go install github.com/cweill/gotests/...@develop
+---
+--- -- if you want to install it within neovim, you can use one of this:
+---
+--- vim.fn.jobstart("go install github.com/cweill/gotests/...@develop")
+---
+--- -- or if you want to use mason:
+--- require("mason-tool-installer").setup {
+--- ensure_installed = {
+--- { "gotests", version = "develop" },
+--- }
+--- }
+--- <
+---
+--- if you choose to install `gotests` within neovim, i recommend adding it to your `build` section in your |lazy.nvim|
+
local c = require "gopher.config"
local ts_utils = require "gopher._utils.ts"
local r = require "gopher._utils.runner"
@@ -5,6 +46,7 @@ local u = require "gopher._utils"
local gotests = {}
---@param args table
+---@private
local function add_test(args)
if c.gotests.named then
table.insert(args, "-named")
@@ -35,7 +77,7 @@ local function add_test(args)
})
end
----generate unit test for one function
+-- generate unit test for one function
function gotests.func_test()
local ns = ts_utils.get_func_method_node_at_pos(unpack(vim.api.nvim_win_get_cursor(0)))
if ns == nil or ns.name == nil then
@@ -46,12 +88,12 @@ function gotests.func_test()
add_test { "-only", ns.name }
end
----generate unit tests for all functions in current file
+-- generate unit tests for all functions in current file
function gotests.all_tests()
add_test { "-all" }
end
----generate unit tests for all exported functions
+-- generate unit tests for all exported functions
function gotests.all_exported_tests()
add_test { "-exported" }
end
diff --git a/scripts/docgen.lua b/scripts/docgen.lua
index 2d3c8d9..e648e56 100644
--- a/scripts/docgen.lua
+++ b/scripts/docgen.lua
@@ -12,6 +12,7 @@ local files = {
"lua/gopher/config.lua",
"lua/gopher/struct_tags.lua",
"lua/gopher/impl.lua",
+ "lua/gopher/gotests.lua",
"lua/gopher/dap.lua",
}