vimspector
The plugin is a capable Vim graphical debugger for multiple languages
DAP (Debug Adapter Protocol)
nvim-dap
is a Debug Adapter Protocol client implementation for Neovim (>= 0.5). nvim-dap
allows you to:
- Launch an application to debug
- Attach to running applications and debug them
- Set breakpoints and step through code
- Inspect the state of the application
Delve
Delve is a debugger for the Go programming language. The goal of the project is to provide a simple, full featured debugging tool for Go. Delve should be easy to invoke and easy to use. Chances are if you’re using a debugger, things aren’t going your way. With that in mind, Delve should stay out of your way as much as possible.
go install github.com/go-delve/delve/cmd/dlv@latest
Neovim key mapping
let g:vimspector_enable_mappings = 'HUMAN'nmap <leader>vl :call vimspector#Launch()<CR>
nmap <leader>vr :VimspectorReset<CR>
nmap <leader>ve :VimspectorEval
nmap <leader>vw :VimspectorWatch
nmap <leader>vo :VimspectorShowOutput
nmap <leader>vi <Plug>VimspectorBalloonEval
xmap <leader>vi <Plug>VimspectorBalloonEval
" for normal mode - the word under the cursor
nmap <Leader>di <Plug>VimspectorBalloonEval
" for visual mode, the visually selected text
xmap <Leader>di <Plug>VimspectorBalloonEval
let g:vimspector_install_gadgets = [ 'debugpy', 'vscode-go', 'CodeLLDB', 'vscode-node-debug2' ]
Run :VimspectorInstall
and the 4 adapters should be installed.
Golang Debugging
Under the project root folder, create a file called .vimspector.json
with the following content. Do change the dlvToolPath
path accordingly.
{
"configurations": {
"run": {
"adapter": "vscode-go",
"configuration": {
"request": "launch",
"program": "${fileDirname}",
"mode": "debug",
"dlvToolPath": "$HOME/workspace/development/go-lang/bin/dlv" }
}
}
}
Human Mode
Key | Function | API |
---|---|---|
F5 | When debugging, continue. Otherwise start debugging. | vimspector#Continue() |
F3 | Stop debugging. | vimspector#Stop() |
F4 | Restart debugging with the same configuration. | vimspector#Restart() |
F6 | Pause debuggee. | vimspector#Pause() |
F9 | Toggle line breakpoint on the current line. | vimspector#ToggleBreakpoint() |
<leader>F9 | Toggle conditional line breakpoint on the current line. | vimspector#ToggleBreakpoint( { trigger expr, hit count expr } ) |
F8 | Add a function breakpoint for the expression under cursor | vimspector#AddFunctionBreakpoint( '<cexpr>' ) |
<leader>F8 | Run to Cursor | vimspector#RunToCursor() |
F10 | Step Over | vimspector#StepOver() |
F11 | Step Into | vimspector#StepInto() |
F12 | Step out of current function scope | vimspector#StepOut() |