filter on _test.go files

pull/277/head
ray-x 1 year ago
parent 13f5e15fd7
commit 19e6350fc8

@ -491,6 +491,10 @@ M.test_file = function(...)
-- local fpath = vfn.expand("%:p")
local fpath = '.' .. sep .. vfn.fnamemodify(vfn.expand('%:p'), ':.')
local is_test = fpath:find('_test%.go$')
if not is_test then
fpath = '.' .. sep .. vfn.fnamemodify(vfn.expand('%:p'), ':.:r') .. '_test.go'
end
-- utils.log(args)
local cmd = [[cat ]] .. fpath .. [[| sed -n 's/func.*\(Test.*\)(.*/\1/p' | xargs | sed 's/ /\\|/g']]
-- TODO maybe with treesitter or lsp list all functions in current file and regex with Test

@ -142,6 +142,10 @@ return {
filetypes = { 'go' },
generator = {
fn = function(params)
local _, is_test = require('go.alternate').is_test_file()
if not is_test then
return
end
local actions = {}
local gt = require('go.gotest')

Loading…
Cancel
Save