dotfiles/nvim/lua/dap_config.lua

83 lines
2.3 KiB
Lua
Raw Normal View History

2023-04-11 13:34:51 +02:00
vim.fn.sign_define('DapBreakpoint', { text = '🟥', texthl = '', linehl = '', numhl = '' })
vim.fn.sign_define('DapStopped', { text = '⭐️', texthl = '', linehl = '', numhl = '' })
2022-08-23 16:02:27 +02:00
local dap = require('dap')
2023-04-11 13:34:51 +02:00
local dapui = require("dapui")
2022-11-25 17:37:44 +01:00
2023-04-11 13:34:51 +02:00
local M = {}
2022-11-25 17:37:44 +01:00
2023-04-11 13:34:51 +02:00
--local DEBUGGER_PATH = {os.getenv('HOME')..'/.local/share/nvim/mason/packages/js-debug-adapter'}
local DEBUGGER_PATH = vim.fn.stdpath "data" .. "/site/pack/packer/opt/vscode-js-debug"
2022-11-25 17:37:44 +01:00
function M.setup()
2023-01-31 21:04:50 +01:00
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode',
name = 'lldb'
}
dap.configurations.cpp = {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
2023-04-11 13:34:51 +02:00
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
2023-01-31 21:04:50 +01:00
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {}
}
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
2022-11-25 17:37:44 +01:00
require('dap-vscode-js').setup {
node_path = "node",
debugger_path = DEBUGGER_PATH,
2023-04-11 13:34:51 +02:00
adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }
2022-11-25 17:37:44 +01:00
}
2023-04-11 13:34:51 +02:00
for _, language in ipairs { "typescript", "javascript" } do
dap.configurations[language] = { {
2022-11-25 17:37:44 +01:00
type = "pwa-node",
request = "launch",
name = "Launch File",
program = "${file}",
2023-04-11 13:34:51 +02:00
cwd = "${workspaceFolder}"
2022-11-25 17:37:44 +01:00
},
2023-04-11 13:34:51 +02:00
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = "${workspaceFolder}"
2022-11-25 17:37:44 +01:00
},
2023-04-11 13:34:51 +02:00
{
type = "pwa-node",
request = "launch",
name = "Debug Jest Tests",
runtimeExecutable = "node",
runtimeArgs = {
"./node_modules/jest/bin/jest.js",
"--runInBand",
},
rootPath = "${workspaceFolder}",
console = "integratedTerminal",
internalConsoleOptions = "neverOpen",
cwd = "${workspaceFolder}"
} }
2022-11-25 17:37:44 +01:00
end
end
2023-04-11 13:34:51 +02:00
require("dapui").setup()
2023-01-31 21:04:50 +01:00
M.setup()
2023-04-11 13:34:51 +02:00
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
2022-11-25 17:37:44 +01:00
return M