Compare commits

...

3 Commits

@ -711,6 +711,7 @@ The plugin will setup debugger. But you need to install
- dap ui (optional)
- 'rcarriga/nvim-dap-ui'
- 'nvim-neotest/nvim-nio'
- dap virtual text (optional)
- 'theHamsta/nvim-dap-virtual-text'
@ -722,6 +723,7 @@ Sample vimrc for DAP
```viml
Plug 'mfussenegger/nvim-dap'
Plug 'rcarriga/nvim-dap-ui'
Plug 'nvim-neotest/nvim-nio'
Plug 'theHamsta/nvim-dap-virtual-text'
" Plug 'nvim-telescope/telescope-dap.nvim'
```
@ -754,6 +756,7 @@ require('go').setup({
go='go', -- go command, can be go[default] or go1.18beta1
goimports ='gopls', -- goimports command, can be gopls[default] or either goimports or golines if need to split long lines
gofmt = 'gopls', -- gofmt through gopls: alternative is gofumpt, goimports, golines, gofmt, etc
fillstruct = 'gopls', -- set to fillstruct if gopls fails to fill struct
max_line_len = 0, -- max line length in golines format, Target maximum line length for golines
tag_transform = false, -- can be transform option("snakecase", "camelcase", etc) check gomodifytags for details and more options
tag_options = 'json=omitempty', -- sets options sent to gomodifytags, i.e., json=omitempty

@ -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

@ -4,6 +4,7 @@ vim.cmd([[set runtimepath=$VIMRUNTIME]])
local tmpdir = vim.loop.os_tmpdir() .. '/nvim'
packpath = tmpdir .. '/lazy'
vim.cmd([[set packpath=]] .. packpath)
-- print(packpath)
local package_root = packpath
local plugin_folder = function()
@ -48,6 +49,7 @@ local function load_plugins()
dependencies = {
'mfussenegger/nvim-dap', -- Debug Adapter Protocol
'rcarriga/nvim-dap-ui',
'nvim-neotest/nvim-nio',
'theHamsta/nvim-dap-virtual-text',
'ray-x/guihua.lua',
},
@ -56,9 +58,9 @@ local function load_plugins()
verbose = true,
-- log_path = '~/tmp/go.log',
lsp_cfg = true,
goimports = 'gopls',
gofmt = 'gopls',
max_line_len = 80,
goimports = 'gopls',
gofmt = 'gopls',
max_line_len = 80,
},
},
}

Loading…
Cancel
Save