Skip to content

Commit a0b818a

Browse files
authored
Add files via upload
1 parent 6b4a704 commit a0b818a

File tree

3 files changed

+147
-1
lines changed

3 files changed

+147
-1
lines changed

lua/custom/DAP/dap_config.lua

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
local mason_dap = require 'mason-nvim-dap'
2+
local dap = require 'dap'
3+
local ui = require 'dapui'
4+
local dap_virtual_text = require 'nvim-dap-virtual-text'
5+
6+
-- Dap Virtual Text
7+
dap_virtual_text.setup()
8+
9+
mason_dap.setup {
10+
ensure_installed = { 'cppdbg', 'debugpy' },
11+
automatic_installation = true,
12+
handlers = {
13+
function(config)
14+
require('mason-nvim-dap').default_setup(config)
15+
end,
16+
},
17+
}
18+
-- Configurations
19+
dap.configurations = {
20+
c = {
21+
{
22+
name = 'Launch file',
23+
type = 'cppdbg',
24+
request = 'launch',
25+
program = function()
26+
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
27+
end,
28+
cwd = '${workspaceFolder}',
29+
stopAtEntry = false,
30+
MIMode = 'lldb',
31+
},
32+
{
33+
name = 'Attach to lldbserver :1234',
34+
type = 'cppdbg',
35+
request = 'launch',
36+
MIMode = 'lldb',
37+
miDebuggerServerAddress = 'localhost:1234',
38+
miDebuggerPath = '/usr/bin/lldb',
39+
cwd = '${workspaceFolder}',
40+
program = function()
41+
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
42+
end,
43+
},
44+
},
45+
python = {
46+
type = 'python',
47+
request = 'launch',
48+
name = 'Launch file',
49+
program = '${file}',
50+
pythonPath = function()
51+
return '/usr/bin/python3'
52+
end,
53+
},
54+
}
55+
56+
-- Dap UI
57+
58+
ui.setup()
59+
60+
vim.fn.sign_define('DapBreakpoint', { text = '🐞' })
61+
62+
dap.listeners.before.attach.dapui_config = function()
63+
ui.open()
64+
end
65+
dap.listeners.before.launch.dapui_config = function()
66+
ui.open()
67+
end
68+
dap.listeners.before.event_terminated.dapui_config = function()
69+
ui.close()
70+
end
71+
dap.listeners.before.event_exited.dapui_config = function()
72+
ui.close()
73+
end

lua/custom/autocommands.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ vim.api.nvim_create_autocmd('TextYankPost', {
88
desc = 'Highlight when yanking (copying) text',
99
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
1010
callback = function()
11-
vim.highlight.on_yank()
11+
vim.hl.on_yank()
1212
end,
1313
})
1414
vim.api.nvim_create_user_command('FormatDisable', function()

lua/custom/keymap.lua

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,76 @@ vim.keymap.set('n', '<c-j>', '<cmd>TmuxNavigateDown<cr>', { desc = 'Move to down
4444
vim.keymap.set('n', '<c-k>', '<cmd>TmuxNavigateUp<cr>', { desc = 'Move to up pane in tumx' })
4545
vim.keymap.set('n', '<c-l>', '<cmd>TmuxNavigateRight<cr>', { desc = 'Move to right pane in tumx' })
4646
vim.keymap.set('n', '<c-\\>', '<cmd>TmuxNavigatePrevious<cr>', { desc = 'Move to last pane in tumx' })
47+
48+
vim.keymap.set('n', '<leader>dt', function()
49+
require('dap').toggle_breakpoint()
50+
end, {
51+
desc = 'Toggle Breakpoint',
52+
nowait = true,
53+
remap = false,
54+
})
55+
vim.keymap.set('n', '<leader>dc', function()
56+
require('dap').continue()
57+
end, {
58+
desc = 'Continue',
59+
nowait = true,
60+
remap = false,
61+
})
62+
vim.keymap.set('n', '<leader>di', function()
63+
require('dap').step_into()
64+
end, {
65+
desc = 'Step Into',
66+
nowait = true,
67+
remap = false,
68+
})
69+
vim.keymap.set('n', '<leader>do', function()
70+
require('dap').step_over()
71+
end, {
72+
desc = 'Step Over',
73+
nowait = true,
74+
remap = false,
75+
})
76+
vim.keymap.set('n', '<leader>du', function()
77+
require('dap').step_out()
78+
end, {
79+
desc = 'Step Out',
80+
nowait = true,
81+
remap = false,
82+
})
83+
vim.keymap.set('n', '<leader>dr', function()
84+
require('dap').repl.open()
85+
end, {
86+
desc = 'Open REPL',
87+
nowait = true,
88+
remap = false,
89+
})
90+
vim.keymap.set('n', '<leader>dl', function()
91+
require('dap').run_last()
92+
end, {
93+
desc = 'Run Last',
94+
nowait = true,
95+
remap = false,
96+
})
97+
vim.keymap.set('n', '<leader>dq', function()
98+
require('dap').terminate()
99+
require('dapui').close()
100+
require('nvim-dap-virtual-text').toggle()
101+
end, {
102+
desc = 'Terminate',
103+
nowait = true,
104+
remap = false,
105+
})
106+
vim.keymap.set('n', '<leader>db', function()
107+
require('dap').list_breakpoints()
108+
end, {
109+
desc = 'List Breakpoints',
110+
nowait = true,
111+
remap = false,
112+
})
113+
vim.keymap.set('n', '<leader>de', function()
114+
require('dap').set_exception_breakpoints { 'all' }
115+
end, {
116+
desc = 'Set Exception Breakpoints',
117+
nowait = true,
118+
remap = false,
119+
})

0 commit comments

Comments
 (0)