revert removing fillstruct as some gopls user saw issues

pull/429/merge
ray-x 2 months ago
parent a3ce5016f5
commit 6bdba9e1f3

@ -375,7 +375,7 @@ return {
require('go.iferr').run()
end)
create_cmd('GoFillStruct', function(_)
require('go.lsp').codeaction('apply_fix', 'refactor.rewrite')
require('go.reftool').fillstruct()
end)
create_cmd('GoFillSwitch', function(_)
require('go.reftool').fillswitch()

@ -16,6 +16,7 @@ local url = {
callgraph = 'golang.org/x/tools/cmd/callgraph',
guru = 'golang.org/x/tools/cmd/guru',
impl = 'github.com/josharian/impl',
fillstruct = 'github.com/davidrjenni/reftools/cmd/fillstruct',
fillswitch = 'github.com/davidrjenni/reftools/cmd/fillswitch',
dlv = 'github.com/go-delve/delve/cmd/dlv',
ginkgo = 'github.com/onsi/ginkgo/v2/ginkgo',

@ -257,7 +257,7 @@ write", "source", "source.organizeImports" }
-- action / fix to take
-- only gopls
M.codeaction = function(gopls_cmd, only, hdlr)
hdlr = hdlr or function () end
hdlr = hdlr or function() end
local params = vim.lsp.util.make_range_params()
if not gopls_cmd:find('gopls') then
gopls_cmd = 'gopls.' .. gopls_cmd

@ -30,9 +30,9 @@ end
-- can only be fillstruct and fillswitch
local function fill(cmd)
if cmd ~= 'fillswitch' then
log(cmd, 'not found')
error('cmd not supported by go.nvim', cmd)
if vim.tbl_contains({ 'fillstruct', 'fillswitch' }, cmd) == false then
error('reftool fill cmd not supported: ' .. cmd)
return
end
require('go.install').install(cmd)
@ -62,6 +62,19 @@ local function fill(cmd)
})
end
local function gopls_fillstruct()
log('fill struct with gopls')
require('go.lsp').codeaction('apply_fix', 'refactor.rewrite')
end
function reftool.fillstruct()
if _GO_NVIM_CFG.fillstruct == 'gopls' then
gopls_fillstruct()
else
fill('fillstruct')
end
end
reftool.fillswitch = function()
fill('fillswitch')
end

Loading…
Cancel
Save