A nvim go test runner based on [email protected] and telescope.nvim.
This extension helps you choose and run a go test func withtelescope
.
- [email protected] (required)
go install github.com/sshelll/gott/v2@latest
- telescope.nvim (required)
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.x' }
- gott.nvim (optional, but highly recommend)
Plug 'sshelll/gott.nvim'
use your nvim plug manager, for example:
Plug 'sshelll/telescope-gott.nvim'
require('telescope').load_extension('gott')
require('telescope').setup {
defaults = {
-- ...
},
pickers = {
-- ...
},
-- config telescope-gott here ⬇️
extensions = {
gott = {
test_args = "-v -vet=off", -- go test args
test_args_list = {
"-v",
'-gcflags=\"all=-l -N\" -v'
}, -- go test args list, if this is empty, use test_args. Otherwise, you'll see another picker to choose args.
timeout = 3000, -- try to close go test result notification after 3s.
keep = function() -- decide whether to keep the notification after timeout(3s).
return false -- you can use 'return true' to keep the notification window forever.
end,
render = 'default', -- default / minimal / simple / compact, controls the notification style.
theme = 'dropdown', -- cursor / dropdown / ivy, telescope picker theme
layout_config = { -- telescope picker layout
width = 0.2,
height = 0.4,
},
display_with_buf = { -- display go test result with buf instead of vim.notify
enabled = false, -- set to true to enable this feature
modifiable = false, -- set to true to make the buf modifiable
height = 20, -- set the buf height
},
},
}
}
:Telescope gott
, use this command to open the test selector.:lua require('notify').dismiss()
, use this command to clear the test result pop-up notifications.
It's recommended to make your own custom key map or cmd for the 2nd command.
Also note that the 2nd command will clear all notifications made by the 'notify' plug.
If you have
gott.nvim
installed, you can use:GottClear
instead of the 2nd command.
There's similar tool to run test - gott.nvim.
The differences between gott.nvim
and telescope-gott.nvim
:
gott.nvim
provides a vim cmd to run the test under the cursor, whiletelescope-gott.nvim
provides a interactive way to choose a go test to run.gott.nvim
allows you to enter go test args, such as:Gott -v -race
, whiletelescope-gott.nvim
can only exec go tests with configured args.
And that's why I highly recommend you to install both of them 🎉!