diff --git a/lua/custom/DAP/dap_config.lua b/lua/custom/DAP/dap_config.lua new file mode 100644 index 00000000..c6c4a9f6 --- /dev/null +++ b/lua/custom/DAP/dap_config.lua @@ -0,0 +1,73 @@ +local mason_dap = require 'mason-nvim-dap' +local dap = require 'dap' +local ui = require 'dapui' +local dap_virtual_text = require 'nvim-dap-virtual-text' + +-- Dap Virtual Text +dap_virtual_text.setup() + +mason_dap.setup { + ensure_installed = { 'cppdbg', 'debugpy' }, + automatic_installation = true, + handlers = { + function(config) + require('mason-nvim-dap').default_setup(config) + end, + }, +} +-- Configurations +dap.configurations = { + c = { + { + name = 'Launch file', + type = 'cppdbg', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopAtEntry = false, + MIMode = 'lldb', + }, + { + name = 'Attach to lldbserver :1234', + type = 'cppdbg', + request = 'launch', + MIMode = 'lldb', + miDebuggerServerAddress = 'localhost:1234', + miDebuggerPath = '/usr/bin/lldb', + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + }, + }, + python = { + type = 'python', + request = 'launch', + name = 'Launch file', + program = '${file}', + pythonPath = function() + return '/usr/bin/python3' + end, + }, +} + +-- Dap UI + +ui.setup() + +vim.fn.sign_define('DapBreakpoint', { text = '🐞' }) + +dap.listeners.before.attach.dapui_config = function() + ui.open() +end +dap.listeners.before.launch.dapui_config = function() + ui.open() +end +dap.listeners.before.event_terminated.dapui_config = function() + ui.close() +end +dap.listeners.before.event_exited.dapui_config = function() + ui.close() +end diff --git a/lua/custom/autocommands.lua b/lua/custom/autocommands.lua index 55951d04..76a5a198 100644 --- a/lua/custom/autocommands.lua +++ b/lua/custom/autocommands.lua @@ -8,7 +8,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { desc = 'Highlight when yanking (copying) text', group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), callback = function() - vim.highlight.on_yank() + vim.hl.on_yank() end, }) vim.api.nvim_create_user_command('FormatDisable', function() diff --git a/lua/custom/keymap.lua b/lua/custom/keymap.lua index 4e6160d4..089652e8 100644 --- a/lua/custom/keymap.lua +++ b/lua/custom/keymap.lua @@ -44,3 +44,76 @@ vim.keymap.set('n', '', 'TmuxNavigateDown', { desc = 'Move to down vim.keymap.set('n', '', 'TmuxNavigateUp', { desc = 'Move to up pane in tumx' }) vim.keymap.set('n', '', 'TmuxNavigateRight', { desc = 'Move to right pane in tumx' }) vim.keymap.set('n', '', 'TmuxNavigatePrevious', { desc = 'Move to last pane in tumx' }) + +vim.keymap.set('n', 'dt', function() + require('dap').toggle_breakpoint() +end, { + desc = 'Toggle Breakpoint', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'dc', function() + require('dap').continue() +end, { + desc = 'Continue', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'di', function() + require('dap').step_into() +end, { + desc = 'Step Into', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'do', function() + require('dap').step_over() +end, { + desc = 'Step Over', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'du', function() + require('dap').step_out() +end, { + desc = 'Step Out', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'dr', function() + require('dap').repl.open() +end, { + desc = 'Open REPL', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'dl', function() + require('dap').run_last() +end, { + desc = 'Run Last', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'dq', function() + require('dap').terminate() + require('dapui').close() + require('nvim-dap-virtual-text').toggle() +end, { + desc = 'Terminate', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'db', function() + require('dap').list_breakpoints() +end, { + desc = 'List Breakpoints', + nowait = true, + remap = false, +}) +vim.keymap.set('n', 'de', function() + require('dap').set_exception_breakpoints { 'all' } +end, { + desc = 'Set Exception Breakpoints', + nowait = true, + remap = false, +})