110 lines
3.3 KiB
Lua
110 lines
3.3 KiB
Lua
dap = require('dap')
|
|
local opts = { noremap = true, silent = false }
|
|
-- vim.keymap.set('n', '<F5>', dap.continue(), opts)
|
|
vim.keymap.set('n', '<F5>', ":lua require('dap').continue()<CR>", opts)
|
|
vim.keymap.set('n', '<F9>', ":lua require('dap').toggle_breakpoint()<CR>", opts)
|
|
vim.keymap.set('n', '<F10>', ":lua require('dap').step_over()<CR>", opts)
|
|
vim.keymap.set('n', '<F11>', ":lua require('dap').step_into()<CR>", opts)
|
|
vim.keymap.set('n', '<S-F11>', ":lua require('dap').step_out()<CR>", opts)
|
|
|
|
local initDir = vim.api.nvim_list_runtime_paths()[1]
|
|
|
|
-- PYTHON
|
|
dap.adapters.python = {
|
|
type = 'executable';
|
|
command = initDir .. '/venv_debugpy/Scripts/python';
|
|
args = { '-m', 'debugpy.adapter' };
|
|
options = {
|
|
detached = true;
|
|
};
|
|
}
|
|
|
|
local dap, dapui = require("dap"), require("dapui")
|
|
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
|
|
|
|
local function getVenvSuffix()
|
|
if vim.loop.os_uname().sysname == 'Linux' then
|
|
return 'bin/python'
|
|
elseif vim.loop.os_uname().sysname == 'Windows_NT' then
|
|
return 'Scripts/python.exe'
|
|
end
|
|
end
|
|
|
|
local function getPythonEnv()
|
|
local venv = os.getenv("VIRTUAL_ENV")
|
|
if venv ~= nil then
|
|
return string.format("%s\\bin\\python.exe", venv)
|
|
end
|
|
|
|
local cwd = vim.fn.getcwd()
|
|
if vim.fn.executable(cwd .. '/venv/' .. getVenvSuffix()) == 1 then
|
|
return cwd .. '/venv/' .. getVenvSuffix()
|
|
elseif vim.fn.executable(cwd .. '/.venv/' .. getVenvSuffix()) == 1 then
|
|
return cwd .. '/.venv/' .. getVenvSuffix()
|
|
else
|
|
if vim.loop.os_uname().sysname == 'Linux' then
|
|
return '/usr/bin/python'
|
|
elseif vim.loop.os_uname().sysname == 'Windows_NT' then
|
|
return os.getenv('SCOOP') .. '/apps/python/current/python.exe'
|
|
end
|
|
end
|
|
end
|
|
|
|
dap.configurations.python = {
|
|
{
|
|
type = 'python';
|
|
request = 'launch';
|
|
name = "Launch file with venv";
|
|
justMyCode = false;
|
|
program = "${file}";
|
|
pythonPath = function()
|
|
return getPythonEnv()
|
|
end;
|
|
},
|
|
}
|
|
|
|
-- require('dap-python').setup('C:\\Users\\oli\\AppData\\Local\\nvim\\venv_debugpy\\Scripts\\python')
|
|
-- table.insert(require('dap').configurations.python, {
|
|
-- -- type = 'python',
|
|
-- -- request = 'launch',
|
|
-- -- name = 'My custom launch configuration',
|
|
-- -- program = '${file}',
|
|
-- justMyCode = false
|
|
-- -- ... more options, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings
|
|
-- })
|
|
-- require('dap-python').setup('C:/Users/oli/AppData/Local/nvim-data/mason/packages/debugpy/venv/Scripts/python.exe')
|
|
|
|
-- CPP
|
|
dap.adapters.codelldb = {
|
|
type = 'server',
|
|
port = "${port}",
|
|
executable = {
|
|
-- CHANGE THIS to your path!
|
|
command = '/absolute/path/to/codelldb/extension/adapter/codelldb',
|
|
args = { '--port', '${port}' },
|
|
|
|
-- On windows you may have to uncomment this:
|
|
-- detached = false,
|
|
}
|
|
}
|
|
|
|
|
|
-- EXTENSIONS
|
|
|
|
require("nvim-dap-virtual-text").setup()
|
|
require('telescope').load_extension('dap')
|
|
-- require("cmp").setup.filetype({ "dap-repl", "dapui_watches" }, {
|
|
-- sources = {
|
|
-- { name = "dap" },
|
|
-- },
|
|
-- })
|
|
require("dapui").setup()
|