Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nvim-dap not lazy loading #1216

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 53 additions & 22 deletions lua/kickstart/plugins/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,59 @@ return {
-- Add your own debuggers here
'leoluz/nvim-dap-go',
},
keys = function(_, keys)
local dap = require 'dap'
local dapui = require 'dapui'
return {
-- Basic debugging keymaps, feel free to change to your liking!
{ '<F5>', dap.continue, desc = 'Debug: Start/Continue' },
{ '<F1>', dap.step_into, desc = 'Debug: Step Into' },
{ '<F2>', dap.step_over, desc = 'Debug: Step Over' },
{ '<F3>', dap.step_out, desc = 'Debug: Step Out' },
{ '<leader>b', dap.toggle_breakpoint, desc = 'Debug: Toggle Breakpoint' },
{
'<leader>B',
function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end,
desc = 'Debug: Set Breakpoint',
},
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
{ '<F7>', dapui.toggle, desc = 'Debug: See last session result.' },
unpack(keys),
}
end,
keys = {
-- Basic debugging keymaps, feel free to change to your liking!
{
'<F5>',
function()
require('dap').continue()
end,
desc = 'Debug: Start/Continue',
},
{
'<F1>',
function()
require('dap').step_into()
end,
desc = 'Debug: Step Into',
},
{
'<F2>',
function()
require('dap').step_over()
end,
desc = 'Debug: Step Over',
},
{
'<F3>',
function()
require('dap').step_out()
end,
desc = 'Debug: Step Out',
},
{
'<leader>b',
function()
require('dap').toggle_breakpoint()
end,
desc = 'Debug: Toggle Breakpoint',
},
Comment on lines +29 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest that we try this approach:

    { '<F5>', <cmd>DapContinue<CR>, desc = 'Debug: Start/Continue' },
    { '<F1>', <cmd>DapStepInto<CR>, desc = 'Debug: Step Into' },
    { '<F2>', <cmd>DapStepOver<CR>, desc = 'Debug: Step Over' },
    { '<F3>', <cmd>DapStepOut<CR>, desc = 'Debug: Step Out' },
    { '<leader>b', <cmd>DapToggleBreakpoint<CR>, desc = 'Debug: Toggle Breakpoint' },

Copy link
Contributor Author

@kaezrr kaezrr Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I have tested this and this works ok, and lazy loads nvim-dap but it is missing the <F7> and <leader>B keybinds and I dont know the commands for those. (dap-ui toggle and set breakpoint condition respectively)

Copy link
Contributor

@glmlm glmlm Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, there does not seem to be a user command defined for them at this time.
There are several ways to do like:

  • Create a user command
vim.api.nvim_create_user_command('DapUiToggle', function()
  require('dapui').toggle()
end, { nargs = 0 })
return {
  ...
    { '<F7>', '<cmd>DapUiToggle<CR>', desc = 'Debug: See last session result.' },
  ...
}
  • Write as a command of lua function
return {
  ...
    { '<F7>', '<cmd>lua require("dapui").toggle()<CR>', desc = 'Debug: See last session result.' },
  ...
}
  • Keep the status quo

I'm not going to be involved in the decision which you choose, and there might well be a better way of doing it.
In any case, it would be best to leave the final decision to the community.

{
'<leader>B',
function()
require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end,
desc = 'Debug: Set Breakpoint',
},
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
{
'<F7>',
function()
require('dapui').toggle()
end,
desc = 'Debug: See last session result.',
},
},
config = function()
local dap = require 'dap'
local dapui = require 'dapui'
Expand Down
Loading