go.nvim
go.nvim copied to clipboard
GoDebug cannot read config from launch
After editing the launch.json with command GoDbgConfig
and save it without changing anything, then I use GoDebug
and it didnot show the prompt but the error message as follow
What I expect: see the prompt so that I can choose the debug config from the launch.json
My nvim version: NVIM v0.8.0
My go.nvim version commit: 8f4386a683b7546a3c0de19c4a11ed84518258cb
My go.nvim config
require('go').setup({
goimport='gopls', -- goimport command, can be gopls[default] or goimport
gofmt = 'gopls', --gofmt cmd,
max_line_len = 120, -- max line length in goline format
tag_transform = false, -- tag_transfer check gomodifytags for details
test_template = '', -- default to testify if not set; g:go_nvim_tests_template check gotests for details
test_template_dir = '', -- default to nil if not set; g:go_nvim_tests_template_dir check gotests for details
comment_placeholder = 'ﳑ' , -- comment_placeholder your cool placeholder e.g.
icons = {breakpoint = '', currentpos = '🏃'},
verbose = true, -- output loginf in messages
lsp_cfg = {
capabilities = require('cmp_nvim_lsp').default_capabilities(),
handlers = handlers,
settings = {
gopls = {
directoryFilters = {
"-**/vendor/git.garena.com/shopee/pl/public/protobuf/go",
"-/vendor/git.garena.com/shopee/pl/public/protobuf/go",
},
-- see https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
analyses = {
shadow = false,
}
}
}
}, -- true: apply go.nvim non-default gopls setup, if it is a list, will merge with gopls setup e.g.
-- lsp_cfg = {settings={gopls={matcher='CaseInsensitive', ['local'] = 'your_local_module_path', gofumpt = true }}}
lsp_gofumpt = false, -- true: set default gofmt in gopls format to gofumpt
lsp_on_attach = on_attach, -- if a on_attach function provided: attach on_attach function to gopls
-- true: will use go.nvim on_attach if true
-- nil/false do nothing
lsp_codelens = true, -- set to false to disable codelens, true by default
lsp_diag_hdlr = true, -- hook lsp diag handler
lsp_diag_underline = true,
lsp_diag_update_in_insert = false,
lsp_inlay_hints = {
enable = true,
-- Only show inlay hints for the current line
only_current_line = false,
-- Event which triggers a refersh of the inlay hints.
-- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but
-- not that this may cause higher CPU usage.
-- This option is only respected when only_current_line and
-- autoSetHints both are true.
only_current_line_autocmd = "CursorHold",
-- whether to show variable name before type hints with the inlay hints or not
-- default: false
show_variable_name = false,
-- prefix for parameter hints
parameter_hints_prefix = " ",
show_parameter_hints = true,
-- prefix for all the other hints (type, chaining)
other_hints_prefix = "=> ",
-- whether to align to the lenght of the longest line in the file
max_len_align = false,
-- padding from the left if max_len_align is true
max_len_align_padding = 1,
-- whether to align to the extreme right or not
right_align = false,
-- padding from the right if right_align is true
right_align_padding = 6,
-- The color of the hints
highlight = "Comment",
},
gopls_remote_auto = true, -- add -remote=auto to gopls
gopls_cmd = nil, -- if you need to specify gopls path and cmd, e.g {"/home/user/lsp/gopls", "-logfile","/var/log/gopls.log" }
fillstruct = 'gopls', -- can be nil (use fillstruct, slower) and gopls
dap_debug = true, -- set to false to disable dap
--float term recommand if you use richgo/ginkgo with terminal color
dap_debug_keymap = true, -- set keymaps for debugger
dap_debug_gui = true, -- set to tru to enable dap gui, highly recommand
dap_debug_vt = true, -- set to true to enable dap virtual text
dap_retries = 20,
dap_timeout = 15, -- see dap option initialize_timeout_sec = 15,
dap_port = 38697,
run_in_floaterm = false, -- set to true to run in float window.
textobjects = true, -- enable default text jobects through treesittter-text-objects
test_runner = 'go', -- richgo, go test, richgo, dlv, ginkgo
build_tags = "" -- set default build tags
})
Looking forward to your help, thank you ~
What debug command and argument you were using when you trying to debug the target?
Do you have a minium setup so I can reproduce the issue?
I do not think it related to go.nvim
setup. It may be related to how you are running debug.
You are right. It was my launch.json's fault. After setting up my launch.json correctly, I can start the debugger and see the prompt to chose the configuration. However, I can still see the message Unable to find any nodes at pos. 16:2
, and then the prompter. Not sure whether this is related to go.nvim
Here is the my minium go.nvim setup file
require('go').setup({
goimport='gopls', -- goimport command, can be gopls[default] or goimport
gofmt = 'gopls', --gofmt cmd,
max_line_len = 120, -- max line length in goline format
icons = {breakpoint = '', currentpos = '🏃'},
verbose = true, -- output loginf in messages
lsp_cfg = {
capabilities = require('cmp_nvim_lsp').default_capabilities(),
handlers = handlers,
settings = {
gopls = {
directoryFilters = {
"-**/vendor/git.garena.com/shopee/pl/public/protobuf/go",
"-/vendor/git.garena.com/shopee/pl/public/protobuf/go",
},
-- see https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
analyses = {
shadow = false,
}
}
}
}, -- true: apply go.nvim non-default gopls setup, if it is a list, will merge with gopls setup e.g.
-- lsp_cfg = {settings={gopls={matcher='CaseInsensitive', ['local'] = 'your_local_module_path', gofumpt = true }}}
lsp_on_attach = on_attach, -- if a on_attach function provided: attach on_attach function to gopls
dap_debug = true, -- set to false to disable dap
--float term recommand if you use richgo/ginkgo with terminal color
dap_debug_keymap = true, -- set keymaps for debugger
dap_debug_gui = true, -- set to tru to enable dap gui, highly recommand
dap_debug_vt = true, -- set to true to enable dap virtual text
dap_retries = 20,
dap_timeout = 15, -- see dap option initialize_timeout_sec = 15,
dap_port = -1,
})
My mini project: test_debugger.zip
Well, I think the debug info should not appear here.
I pushed an update to fix those. Would you check if latest version works for you?
Also in your launch.json. change the request
to launch
may make it easy for debug. (unless you mean attach to running proccess.
{
"configurations": [
{
"args": [],
"buildFlags": "",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"host": "127.0.0.1",
"mode": "debug",
"name": "Attach main",
"port": 38697,
"processId": 99038,
"program": "${workspaceFolder}/main.go",
"remotePath": "",
"request": "launch",
"type": "go"
},
{
"mode": "local",
"name": "Attach to Process",
"processId": 99038,
"request": "attach",
"type": "go"
}
],
"version": "0.2.0"
}
Thanks!
@ccbhj Can you check if the latest version works for you?