This context provides a guide on enhancing the debugging experience using DAP in Neovim for Python, Golang, Rust, Node.js, Javascript/Typescript, and Lua.
Abstract
The context begins with an overview of the guide and references to previous articles on configuring LSP and DAP for Neovim using both nvim-dap and vimspector. The guide focuses on enhancing the debugging experience using nvim-dap for Python, Node.js/Javascript/Typescript, Golang, Rust, and Lua. The guide provides step-by-step instructions on installing and configuring plugins, setting up key bindings, and using virtual text and UI for debugging. It also introduces the use of telescope-dap for viewing nvim-dap commands and variables, and vim-ultest for debugging test cases. The guide concludes with instructions on installing DAPInstall.nvim for managing various debuggers and configuring other languages such as Node.js, Golang, Rust, and Lua.
Bullet points
The guide provides instructions on enhancing the debugging experience using nvim-dap for Python, Node.js/Javascript/Typescript, Golang, Rust, and Lua.
The guide provides step-by-step instructions on installing and configuring plugins, setting up key bindings, and using virtual text and UI for debugging.
The guide introduces the use of telescope-dap for viewing nvim-dap commands and variables, and vim-ultest for debugging test cases.
The guide concludes with instructions on installing DAPInstall.nvim for managing various debuggers and configuring other languages such as Node.js, Golang, Rust, and Lua.
Neovim DAP Enhanced
Enhance your debugging experience using DAP in Neovim for Python, Golang, Rust, Node.js, Javascript/Typescript, and Lua.
Neovim DAP Enhanced
Overview
In my previous articles, I walked through with you how to configure LSP and DAP for Neovim using both nvim-dap and vimspector. In this article, let’s continue to enhance the debugging experience using nvim-dap. I am going to focus on Python, Node.js/Javascript/Typescript, Golang, Rust, and Lua.
In the main init.lua file, add the following line to load the debug module.
require('dbg')
Debugging
Open a project and press <Leader>dtb to toggle a breakpoint.
Press <Leader>dct to start debugging.
The application should stop at the breakpoint. Now press <Leader>dro to open the REPL.
nvim-dap: Debugging
By default nvim-dap provides widgets and UIs to display the variables. E.g. press <Leader>duf to display a floating window with details of the variables.
nvim-dap: Widget
Enhance DAP Experience
Let’s continue to enhance the debugging experience.
telescope-dap
I already installed telescope-dap. Using this plugin I can look at the debugging commands, list the variables, configurations, and breakpoints.
E.g., type :Telescope dap commands to view nvim-dap commands.
vim-ultestbuilds upon vim-test to make it even better while maintaining the ability to use your existing configuration. It also supports debugging using nvim-dap.
use {
"rcarriga/vim-ultest",
config = "require('config.ultest').post()",
run = ":UpdateRemotePlugins",
requires = {"vim-test/vim-test"}
}
Create a file call ultest.lua underlua/config with the following content.
Run :luafile % and :PackerInstall to install the plugin.
Now open a file with test cases, and run :UltestDebug.
vim-ultest: Debuggingvim-ultest: Test Summary
DAPInstall
Before continuing to explore other languages, let’s install DAPInstall which is a NeoVim plugin written in Lua that extends nvim-dap’s functionality for managing various debuggers.
use {'Pocco81/DAPInstall.nvim'}
Run :luafile % and :PackerInstall to install this plugin.
Refer to the documentation for a list of supported debuggers.
Configure Other Languages
Node.js
Run :DIInstall jsnode_dbg to install the debugger.
Create a new file lua/dbg/node.lua with the following content.
In lua/dbg/init.lua, import the module.
require('dbg.node')
Restart Neovim and now you can debug Node.js application.
nvim-dap: Debugging Node.js
Golang
Run :DIInstall go_delve_dbg to install the debugger.
Create a new file lua/dbg/go.lua with the following content.
In lua/dbg/init.lua, import the module.
require('dbg.go')
Restart Neovim and now you can debug Golang application.
nvim-dap: Debugging Golang
Rust
Run :DIInstall ccppr_lldb_dbg to install the debugger.
Create a new file lua/dbg/rust.lua with the following content.
In lua/dbg/init.lua, import the module.
require('dbg.rust')
Restart Neovim and now you can debug Rust application (Note: You will be asked to input the Rust executable path).