An extension for nvim-dap providing configurations for launching debug.rb.
Lazy.nvim:
{
"mfussenegger/nvim-dap",
dependencies = {
"suketa/nvim-dap-ruby"
},
config = function()
require("dap-ruby").setup()
end
}
Vim-plug:
Plug 'mfussenegger/nvim-dap'
Plug 'suketa/nvim-dap-ruby'
If you're not using Lazy.nvim, you'll need to call the setup function to register and setup the adapter:
lua require('dap-ruby').setup()
Call :lua require('dap').continue()
to start debugging.
Ensure that the debug gem is included in your project.
bundle add debug
Then run rails with debugging turned on. For example, this can be done with environment variables.
RUBY_DEBUG_OPEN=true RUBY_DEBUG_HOST=127.0.0.1 RUBY_DEBUG_PORT=38698 bin/rails server
RUBY_DEBUG_OPEN=true RUBY_DEBUG_HOST=127.0.0.1 RUBY_DEBUG_PORT=38698 bin/dev # If using esbuild
- You need to see
DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:38698)
somewhere in the console output. - Open nvim in your project's directory, and open a ruby file into a buffer.
- Start the debugger e.g.
:DapContinue
and select the option toattach existing (port 38698)
. - Now set breakpoints and make the app hit one of those by navigating to the page that you are working on in a web browser.
Now that you have confirmed the above works, you can also start your rails server and run the debugger directly from nvim.
Start the debugger with one of the following configurations: run rails
for bin/rails s
or bin/dev
for bin/dev
.
It will automatically set the debugger environment variables, run the command, and attach to the session.
- Start debugger with current opened file.
- RSpec
- Start debugger with current opened spec file (
bundle exec rspec /path/to/file_spec.rb
) - Start debugger with
bundle exec rspec ./spec
- Start debugger with current opened spec file (
- Rails integration
- Connect running rdbg
- Rake test
Thanks to nvim-dap-go for the inspiration.