nvim/lua/configs/dap.lua

116 lines
3.2 KiB
Lua

local dap = require("dap")
-- 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}",
-- },
-- }
--
-- dap.configurations.cpp = {
-- {
-- name = "Launch file",
-- type = "cppdbg",
-- request = "launch",
-- program = function()
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- end,
-- cwd = '${workspaceFolder}',
-- stopAtEntry = true,
-- }
-- }
dap.adapters.cppdbg = {
id = 'cppdbg',
type = 'executable',
command = '/nix/store/gwags66qlqr6qmblwp0v6crkb6ca2qr1-vscode-extension-ms-vscode-cpptools-1.22.2/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7',
cwd = "${workspaceFolder}",
}
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "-i", "dap" },
-- console = 'externalTerminal',
-- terminal_win_cmd = "tabnew",
}
dap.adapters.lldb = {
type = 'executable',
command = 'lldb-dap', -- adjust as needed, must be absolute path
name = 'lldb'
}
dap.adapters.debugpy = function(cb, config)
if config.request == 'attach' then
---@diagnostic disable-next-line: undefined-field
local port = (config.connect or config).port
---@diagnostic disable-next-line: undefined-field
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
function launchjs()
require('dap.ext.vscode').load_launchjs("dap_config.json", {
cppdbg = { 'c', 'cpp' },
lldb = { 'c', 'cpp' },
gdb = { 'c', 'cpp' },
debugpy = { 'python' }
})
end
dap.set_log_level("TRACE")
-- reload lualine module on event
local events = {
"continue",
"terminate",
"restart",
"disconnect",
"event_terminated",
"disconnect",
"event_exited",
"event_stopped",
"threads",
"event_continued",
}
function refresh_lualine_module()
require('lualine').refresh({
scope = 'all', -- scope of refresh all/tabpage/window
place = { 'statusline' }, -- lualine segment ro refresh.
})
end
for _, event in ipairs(events) do
dap.listeners.after[event]["lualine_refresh"] = refresh_lualine_module
end
-- require("telescope").load_extension("dap")
-- Interface Setup
vim.fn.sign_define('DapBreakpoint', { text='', texthl='red'})
vim.fn.sign_define('DapBreakpointCondition', { text='', texthl='blue'})
vim.fn.sign_define('DapBreakpointRejected', { text='', texthl='orange'})
vim.fn.sign_define('DapStopped', { text='󰁕', texthl='green'})
vim.fn.sign_define('DapLogPoint', { text='.>', texthl='yellow', linehl='DapBreakpoint', numhl='DapBreakpoint' })
vim.api.nvim_command 'autocmd FileType dap-float nnoremap <buffer><silent> q <cmd>close!<CR>'