Skip to content

Commit

Permalink
chore(nvim): improve dap configuration and keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
silveiralexf committed Oct 22, 2024
1 parent 35fb255 commit b5c84cf
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 176 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


### [2024-10-22]
* [[7f6d42a]](https://github.com/silveiralexf/.dotfiles/commit/7f6d42a03d5f5f6f0d533f6078230a0178c279ea) chore(nvim): improve lua support with lazydev (silveiralexf@gmail.com)


* [[bab6421]](https://github.com/silveiralexf/.dotfiles/commit/bab642182a4158ad43f9377b7783123125ca2d3d) chore: deps, comments, small fixes (silveiralexf@gmail.com)


Expand Down
204 changes: 204 additions & 0 deletions nvim/lua/plugins/dap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
return {
{
'mfussenegger/nvim-dap',
event = 'VeryLazy',
dependencies = {
{
'leoluz/nvim-dap-go',
'nvim-neotest/nvim-nio',
'williamboman/mason.nvim',
'rcarriga/nvim-dap-ui',
dependencies = {
'nvim-neotest/nvim-nio',
},
opts = {},
config = function(_, opts)
local dap = require('dap')
local dapui = require('dapui')

require('dapui').setup()
require('dap-go').setup()

-- Adapters customizations
dap.adapters.go = {
type = 'server',
port = '${port}',
executable = {
command = 'dlv',
args = { 'dap', '-l', '127.0.0.1:${port}' },
},
}

-- Events and listeners settings
dapui.setup(opts)
dap.listeners.before.attach['dapui_config'] = function()
dapui.open({})
end
dap.listeners.before.launch['dapui_config'] = function()
dapui.open({})
end
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open({})
end
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close({})
end
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close({})
end
end,
keys = {
{
'<leader>du',
function()
require('dapui').toggle({})
end,
desc = '[d]ap [u]i',
},
{
'<leader>de',
function()
require('dapui').eval()
end,
desc = '[d]ap [e]val',
},
},
},
},
keys = {
{
'<leader>db',
function()
require('dap').toggle_breakpoint()
end,
desc = 'toggle [d]ebug [b]reakpoint',
},
{
'<leader>dB',
function()
require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))
end,
desc = '[d]ebug [B]reakpoint',
},
{
'<leader>dc',
function()
require('dap').continue()
end,
desc = '[d]ebug [c]ontinue (start here)',
},
{
'<leader>di',
function()
require('dap').step_into()
end,
desc = '[d]ebug [i]nto',
},
{
'<leader>do',
function()
require('dap').step_over()
end,
desc = '[d]ebug step [o]ver',
},
{
'<leader>dO',
function()
require('dap').step_out()
end,
desc = '[d]ebug step [O]ut',
},
{
'<leader>dh',
function()
require('dap').step_back()
end,
desc = '[d]ebug step back [h]',
},
{
'<leader>dx',
function()
require('dap').restart()
end,
desc = '[d]ebug restart [x]',
},
{
'<leader>dC',
function()
require('dap').run_to_cursor()
end,
desc = '[d]ebug [C]ursor',
},
{
'<leader>dg',
function()
require('dap').goto_()
end,
desc = '[d]ebug [g]o to line',
},
{
'<leader>dj',
function()
require('dap').down()
end,
desc = '[d]ebug [j]ump down',
},
{
'<leader>dk',
function()
require('dap').up()
end,
desc = '[d]ebug [k]ump up',
},
{
'<leader>dl',
function()
require('dap').run_last()
end,
desc = '[d]ebug [l]ast',
},
{
'<leader>dp',
function()
require('dap').pause()
end,
desc = '[d]ebug [p]ause',
},
{
'<leader>dr',
function()
require('dap').repl.toggle()
end,
desc = '[d]ebug [r]epl',
},
{
'<leader>dR',
function()
require('dap').clear_breakpoints()
end,
desc = '[d]ebug [R]emove breakpoints',
},
{
'<leader>ds',
function()
require('dap').session()
end,
desc = '[d]ebug [s]ession',
},
{
'<leader>dt',
function()
require('dap').terminate()
end,
desc = '[d]ebug [t]erminate',
},
{
'<leader>dw',
function()
require('dap.ui.widgets').hover()
end,
desc = '[d]ebug [w]idgets',
},
},
},
}
176 changes: 0 additions & 176 deletions nvim/lua/plugins/neotest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,180 +144,4 @@ return {
},
},
},

-- DAP setup
{
'mfussenegger/nvim-dap',
event = 'VeryLazy',
dependencies = {
{
'rcarriga/nvim-dap-ui',
dependencies = {
'nvim-neotest/nvim-nio',
},
opts = {},
config = function(_, opts)
-- setup dap config by VsCode launch.json file
-- require("dap.ext.vscode").load_launchjs()
local dap = require('dap')
local dapui = require('dapui')
dapui.setup(opts)
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open({})
end
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close({})
end
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close({})
end
end,
keys = {
{
'<leader>du',
function()
require('dapui').toggle({})
end,
desc = '[d]ap [u]i',
},
{
'<leader>de',
function()
require('dapui').eval()
end,
desc = '[d]ap [e]val',
},
},
},
{
'theHamsta/nvim-dap-virtual-text',
opts = {},
},
{
'leoluz/nvim-dap-go',
opts = {},
},
},
keys = {
{
'<leader>db',
function()
require('dap').toggle_breakpoint()
end,
desc = 'toggle [d]ebug [b]reakpoint',
},
{
'<leader>dB',
function()
require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))
end,
desc = '[d]ebug [B]reakpoint',
},
{
'<leader>dc',
function()
require('dap').continue()
end,
desc = '[d]ebug [c]ontinue (start here)',
},
{
'<leader>dC',
function()
require('dap').run_to_cursor()
end,
desc = '[d]ebug [C]ursor',
},
{
'<leader>dg',
function()
require('dap').goto_()
end,
desc = '[d]ebug [g]o to line',
},
{
'<leader>do',
function()
require('dap').step_over()
end,
desc = '[d]ebug step [o]ver',
},
{
'<leader>dO',
function()
require('dap').step_out()
end,
desc = '[d]ebug step [O]ut',
},
{
'<leader>di',
function()
require('dap').step_into()
end,
desc = '[d]ebug [i]nto',
},
{
'<leader>dj',
function()
require('dap').down()
end,
desc = '[d]ebug [j]ump down',
},
{
'<leader>dk',
function()
require('dap').up()
end,
desc = '[d]ebug [k]ump up',
},
{
'<leader>dl',
function()
require('dap').run_last()
end,
desc = '[d]ebug [l]ast',
},
{
'<leader>dp',
function()
require('dap').pause()
end,
desc = '[d]ebug [p]ause',
},
{
'<leader>dr',
function()
require('dap').repl.toggle()
end,
desc = '[d]ebug [r]epl',
},
{
'<leader>dR',
function()
require('dap').clear_breakpoints()
end,
desc = '[d]ebug [R]emove breakpoints',
},
{
'<leader>ds',
function()
require('dap').session()
end,
desc = '[d]ebug [s]ession',
},
{
'<leader>dt',
function()
require('dap').terminate()
end,
desc = '[d]ebug [t]erminate',
},
{
'<leader>dw',
function()
require('dap.ui.widgets').hover()
end,
desc = '[d]ebug [w]idgets',
},
},
},
}

0 comments on commit b5c84cf

Please sign in to comment.