Skip to content

Commit

Permalink
feat: dap for jest
Browse files Browse the repository at this point in the history
...but it ain't workin
  • Loading branch information
willruggiano committed Aug 2, 2023
1 parent f4602be commit 2d39bdc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/bombadil/plugin/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ vim.opt.hlsearch = true
vim.opt.ignorecase = true
vim.opt.inccommand = "split"
vim.opt.incsearch = true
vim.opt.laststatus = 0
vim.opt.laststatus = 2
vim.opt.linebreak = false
vim.opt.listchars = { space = "." }
vim.opt.modelines = 1
Expand Down
48 changes: 42 additions & 6 deletions plugins/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,42 @@ return function()
},
}

dap.configurations.typescript = {
{
type = "pwa-node",
request = "launch",
name = "Debug Jest test",
runtimeExecutable = "node",
runtimeArgs = function()
local args = {
"./node_modules/.bin/jest",
"--runInBand",
}

local file = vim.api.nvim_buf_get_name(0)
local configs = vim.fs.find(function(name, _)
return name:match "jest%.config%.[%a]+$"
end, {
upward = true,
stop = vim.fn.getcwd(),
path = vim.fs.dirname(file),
})

if #configs == 0 then
error "No jest config file found"
end

local config = configs[1]
if #configs > 1 then
error "More than one jest config file found"
end

return vim.list_extend(args, { "--config", config, file })
end,
rootPath = "${workspaceFolder}",
},
}

dap.adapters.cppdbg = {
type = "executable",
command = "lldb-vscode",
Expand Down Expand Up @@ -99,12 +135,12 @@ return function()
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
-- dap.listeners.before.event_terminated["dapui_config"] = function()
-- dapui.close()
-- end
-- dap.listeners.before.event_exited["dapui_config"] = function()
-- dapui.close()
-- end

local nnoremaps = require("bombadil.lib.keymap").nnoremaps
local prefix = "<space>d"
Expand Down

0 comments on commit 2d39bdc

Please sign in to comment.