155 lines
5.4 KiB
Lua
155 lines
5.4 KiB
Lua
return {
|
|
{
|
|
'mfussenegger/nvim-dap',
|
|
config = function()
|
|
local dap = require("dap")
|
|
dap.adapters.gdb = {
|
|
type = "executable",
|
|
command = "gdb",
|
|
args = {
|
|
"-i",
|
|
"dap"
|
|
}
|
|
}
|
|
dap.adapters.python = function(cb, config)
|
|
if config.request == 'attach' then
|
|
local port = (config.connect or config).port
|
|
local host = (config.connect or config).host or '127.0.0.1'
|
|
cb({
|
|
type = 'server',
|
|
port = assert(port, '`connect.port` is required for a python `attach` configuration'),
|
|
host = host,
|
|
options = {
|
|
source_filetype = 'python'
|
|
}
|
|
})
|
|
else
|
|
cb({
|
|
type = 'executable',
|
|
command = 'python',
|
|
args = {
|
|
'-m',
|
|
'debugpy.adapter'
|
|
},
|
|
options = {
|
|
source_filetype = 'python'
|
|
}
|
|
})
|
|
end
|
|
end
|
|
dap.configurations.c = {
|
|
{
|
|
name = "Launch",
|
|
type = "gdb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopAtBeginningOfMainSubprogram = false
|
|
}
|
|
}
|
|
dap.configurations.cpp = {
|
|
{
|
|
name = "Launch",
|
|
type = "gdb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopAtBeginningOfMainSubprogram = false
|
|
}
|
|
}
|
|
dap.configurations.python = {
|
|
{
|
|
type = 'python',
|
|
request = 'launch',
|
|
name = "Launch file",
|
|
|
|
program = "${file}",
|
|
pythonPath = function()
|
|
local cwd = vim.fn.getcwd()
|
|
if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
|
|
return cwd .. '/venv/bin/python'
|
|
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
|
|
return cwd .. '/.venv/bin/python'
|
|
else
|
|
return '/usr/bin/python'
|
|
end
|
|
end
|
|
}
|
|
}
|
|
|
|
vim.keymap.set("n", "<leader>db", "<cmd>DapToggleBreakpoint<cr>", {
|
|
desc = "Toggle breakpoint"
|
|
})
|
|
vim.keymap.set("n", "<leader>dc", "<cmd>DapContinue<cr>", {
|
|
desc = "Continue"
|
|
})
|
|
vim.keymap.set("n", "<leader>dt", "<cmd>DapTerminate<cr>", {
|
|
desc = "Terminate"
|
|
})
|
|
vim.keymap.set("n", "<leader>di", "<cmd>DapStepInto<cr>", {
|
|
desc = "Step into"
|
|
})
|
|
vim.keymap.set("n", "<leader>dn", "<cmd>DapStepOver<cr>", {
|
|
desc = "Step over"
|
|
})
|
|
vim.keymap.set("n", "<leader>do", "<cmd>DapStepOut<cr>", {
|
|
desc = "Step out"
|
|
})
|
|
vim.keymap.set("n", '<Leader>dh', function() require('dap.ui.widgets').hover() end, {
|
|
desc = "Hover"
|
|
})
|
|
end
|
|
},
|
|
{
|
|
"rcarriga/nvim-dap-ui",
|
|
dependencies = {
|
|
"mfussenegger/nvim-dap",
|
|
"nvim-neotest/nvim-nio"
|
|
},
|
|
config = function()
|
|
require("dapui").setup({
|
|
controls = {
|
|
enabled = false
|
|
},
|
|
layouts = {
|
|
{
|
|
elements = {
|
|
{
|
|
id = "scopes",
|
|
size = 0.33
|
|
},
|
|
{
|
|
id = "breakpoints",
|
|
size = 0.33
|
|
},
|
|
{
|
|
id = "stacks",
|
|
size = 0.33
|
|
}
|
|
},
|
|
position = "left",
|
|
size = 60
|
|
},
|
|
{
|
|
elements = {
|
|
{
|
|
id = "repl",
|
|
size = 1
|
|
}
|
|
},
|
|
position = "bottom",
|
|
size = 15
|
|
}
|
|
}
|
|
})
|
|
vim.keymap.set("n", "<leader>du", function() require("dapui").toggle() end, {
|
|
desc = " Toggle UI"
|
|
})
|
|
end
|
|
}
|
|
}
|