Neovim — Debugging Application
Debugging application written in Python, Golang, Rust, and Javascript/Typescript.
Overview
In a previous article on Neovim LSP and DAP, I set up DAP using nvim-dap. In this article, let’s set up debuggers for Python, Golang, Rust, and Javascript/Typescript using vimspector.
Setup
Plugin Installation
I am going to leverage the dotfiles I configured in my previous article.
Inlua/plugins.lua
, add the following line to install vimspector
. You can use whatever plugin manager that you prefer.
-- Debugging
use { 'puremourning/vimspector' }
Run :luafile %
and :PackerInstall
to install the plugin.
Adapter Installation
Create a file called vimspector.vim
under the plugin folder with the following content.
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>VimspectorBalloonEvallet g:vimspector_install_gadgets = [ 'debugpy', 'vscode-go', 'CodeLLDB', 'vscode-node-debug2' ]
Below are the adapters used for each language.
- Python — debugpy
- Golang — vscode-go
- Rust — CodeLLDB
- Javascript/TypeScript — vscode-node-debug2 for Nodejs application
Make sure you have the dependencies installed, e.g. vscode-go needs delve to be installed.
Run :VimspectorInstall
and the 4 adapters should be installed.
Run :VimspectorToggleLog
to see the location of VIMSPECTOR_HOME
and gadgetDir
.