nvim-dap-r adds R support to nvim-dap through rarr or
daptadap.
It is not the debugger. It registers the R adapter, default R configurations,
and a few helper commands. The DAP server and R runtime state live in rarr or
in the active R console through daptadap.
- Neovim with nvim-dap
- rarr with DAP support
- Optional:
daptadapfor the classic R.nvim console backend - Optional: rarr.nvim for its R console workflow
- Optional: nvim-dap-ui or nvim-dap-view for debugger panes
- Optional: nvim-dap-virtual-text for inline values
rarr.nvim and R.nvim do not install this adapter. Add nvim-dap-r
separately when you want R debugging through nvim-dap.
Install it like any other Neovim plugin:
{
"ilyaZar/nvim-dap-r",
dependencies = {
"mfussenegger/nvim-dap",
},
config = function()
require("dap-r").setup()
end,
}For a local development checkout, point your plugin manager at this repository:
{
name = "nvim-dap-r",
dir = vim.fn.expand("~/path/to/nvim-dap-r"),
dependencies = {
"mfussenegger/nvim-dap",
},
config = function()
require("dap-r").setup()
end,
}Call setup in your Neovim config:
require("dap-r").setup()This registers two nvim-dap configurations for R buffers:
Attach to rarrLaunch rarr
If rarr.nvim is installed, nvim-dap-r can discover its active rarr
console session. Otherwise, Launch rarr starts rarr and attaches
nvim-dap.
To use the classic R.nvim console backend, install daptadap in the R
library used by your console and select the classic backend:
require("dap-r").setup({
backend = "classic",
classic = {
auto_start = false,
watch_console = true,
console = "r-nvim",
},
})Use the commands:
:DapRStart
:DapRAttach
:DapRLaunch
:DapRDebugSource
:DapRClassicStart
:DapRClassicAttach
:DapRClassicDebugSource:DapRStartattaches to the activerarrsession or startsrarr:DapRAttachattaches to an existingrarrsession:DapRLaunchstartsrarrand attachesnvim-dap:DapRDebugSourceattaches with the current source file asprogram:DapRClassicStartstartsdaptadapin the activeR.nvimconsole:DapRClassicAttachattachesnvim-dapto the classic console backend:DapRClassicDebugSourcesources the current file throughdaptadap
The same actions are available from Lua:
require("dap-r").start()
require("dap-r").attach()
require("dap-r").launch()
require("dap-r").debug_source()
require("dap-r").classic_start()
require("dap-r").classic_attach()
require("dap-r").classic_debug_source()After attaching, use regular nvim-dap commands:
require("dap").continue()
require("dap").toggle_breakpoint()
require("dap").step_over()
require("dap").step_into()
require("dap").step_out()
require("dap").terminate()nvim-dap-r does not set global keymaps. It does install guarded R-buffer step
maps by default:
ccontinuesnsteps overssteps intoSsteps out
These maps call nvim-dap only while an R DAP session is stopped. Otherwise
they pass the original key back to Vim, so normal search, substitute, and change
commands keep working outside the debugger.
Change or disable them in setup:
require("dap-r").setup({
debug_keymaps = {
enabled = true,
continue = "c",
step_over = "n",
step_into = "s",
step_out = "S",
},
})Set one key to false, or disable the whole group with
debug_keymaps = false.
For common breakpoint and start keys, let nvim-dap-r create R-buffer maps:
require("dap-r").setup({
keymaps = {
start = "<leader>dc",
breakpoint = "<leader>db",
},
})Or call the helper yourself from an R filetype callback:
require("dap-r").setup_keymaps(bufnr, {
start = "<leader>dc",
breakpoint = "<leader>db",
})If you also want c, n, s, and S inside nvim-dap-ui buffers, map them
there with normal require("dap").* calls. Those buffers are owned by
nvim-dap-ui, not by nvim-dap-r.
nvim-dap-r does not manage debugger panes, watches, scopes, virtual text, or
the nvim-dap-ui control row. Use regular nvim-dap UI plugins for that:
- nvim-dap-ui for scopes, stack frames, watches, breakpoints, and REPL/console panes
- nvim-dap-view as an alternative UI
- nvim-dap-virtual-text for inline values and stop reasons
The default nvim-dap-ui controls are clickable icons, not number keys:
| Icon | Action |
|---|---|
/ |
continue/pause |
|
step into |
|
step over |
|
step out |
|
step back |
|
run last |
|
terminate |
|
disconnect |
The icons can vary with your font and nvim-dap-ui config. Some actions, such
as step back, also depend on adapter support.
Most users can keep the defaults:
require("dap-r").setup({
backend = "rarr",
rarr = {
command = "rarr",
args = {},
mode = "auto",
host = "127.0.0.1",
port = nil,
metadata_path = nil,
},
classic = {
enabled = true,
package = "daptadap",
host = "127.0.0.1",
port = 0,
metadata_path = nil,
auto_start = true,
watch_console = true,
console = "r-nvim",
},
configurations = true,
filetypes = { "r", "rmd", "quarto", "rnoweb" },
integrate_rarr_nvim = true,
commands = true,
keymaps = false,
debug_keymaps = {
enabled = true,
step_over = "n",
step_into = "s",
step_out = "S",
continue = "c",
},
source_window = {
enabled = true,
focus_on_stop = true,
focus_delay_ms = 30,
},
})Set source_window = false if you want to manage nvim-dap source window
selection entirely in your own config.