diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-12-11 20:46:32 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-12-11 20:47:59 +0100 |
commit | f22f1723c01b56da14ae1de3491a78af1bc4c464 (patch) | |
tree | 030411c811d3474c4b322eca29d1bf8e96b7511f /private_dot_config/nvim/lua/dap_conf.lua | |
parent | d8713792f93473fe14e01d151529fb6ef139448f (diff) |
Dot files with `chezmoi`
Diffstat (limited to 'private_dot_config/nvim/lua/dap_conf.lua')
-rw-r--r-- | private_dot_config/nvim/lua/dap_conf.lua | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/private_dot_config/nvim/lua/dap_conf.lua b/private_dot_config/nvim/lua/dap_conf.lua new file mode 100644 index 0000000..b3cee89 --- /dev/null +++ b/private_dot_config/nvim/lua/dap_conf.lua @@ -0,0 +1,52 @@ +local dap, dapui = require('dap'), require('dapui') +local dapgo = require('dap-go') +dapui.setup() +dapgo.setup() +dap.listeners.before.attach.dapui_config = function() + dapui.open() +end +dap.listeners.before.launch.dapui_config = function() + dapui.open() +end + +dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "--interpreter=dap", "--eval-command", "set print pretty on" } +} + +local configurations = {'c', 'cpp', 'rust'} + +for _, conf in ipairs(configurations) do + dap.configurations[conf] = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, + } +end + +-- Include the next few lines until the comment only if you feel you need it +dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() +end +dap.listeners.before.event_exited.dapui_config = function() + dapui.close() +end +-- Include everything after this + + +vim.keymap.set('n', '<F5>', function() require('dap').continue() end) +vim.keymap.set('n', '<F10>', function() require('dap').step_over() end) +vim.keymap.set('n', '<F11>', function() require('dap').step_into() end) +vim.keymap.set('n', '<F12>', function() require('dap').step_out() end) +vim.keymap.set('n', '<C-K>', function() require('dap').toggle_breakpoint() end) +vim.api.nvim_create_user_command('DapRepeat',function() require('dap').run_last() end, {}) +vim.api.nvim_create_user_command('DapOpen',function() dapui.open() end, {}) +vim.api.nvim_create_user_command('DapClose',function() dapui.close() end, {}) |