Debugger Setup
AstroNvim v2.9 introduced debugging support with AstroNvim. We use a combination of nvim-dap
for the debugger, mason-nvim-dap
for interoperability with the Mason package manager, and nvim-dap-ui
for a nice user interface while debugging.
Installing Debuggers With Mason
By default there are a few debuggers that can be automatically installed and configured just through Mason (with the help of mason-nvim-dap
). This can be done using either the :DapInstall
command or through the Mason UI with :Mason
. For details on configuring mason-nvim-dap
as well as which debuggers are supported, please check their README
and documentation. It provides a function for setting up custom handlers for when a recognizable debugger is installed, this can be configured by extending the config
function of the plugin:
Automatically Install Debuggers
mason-nvim-dap
also allows you to automatically install debuggers that you may want. This can be configured by extending the mason-nvim-dap
plugin options:
Setting Up Custom Debuggers
Not all debugging adapters are supported by mason-nvim-dap
or to be installed with Mason itself. For these it may be necessary for manually configuring adapters and configurations for dap
directly. For details on configuring debuggers manually, please refer to the nvim-dap
wiki. Here is an example of configuring nvim-dap
directly to add the python debugger:
Disabling Auto Debugging UI
By default, AstroNvim sets up event listeners with nvim-dap
to automatically open and close the nvim-dap-ui
. This can be disabled by overriding the require("dapui").setup({...})
call with the function override method:
Add parsing of JSON5
By default nvim-dap
will attempt to parse and load .vscode/launch.json
files in a project to load debugging targets. By default this uses the built in vim.json.decode
function. This function doesnβt support JSON5 which adds compatibility for trailing commas and comments. If you need support for these JSON syntaxes you can add the lua-json5
plugin to your configuration: