From 2d39bdc5cbaf9443ee3d7608f303b54d9de73741 Mon Sep 17 00:00:00 2001 From: Will Ruggiano Date: Wed, 2 Aug 2023 15:01:49 -0600 Subject: [PATCH] feat: dap for jest ...but it ain't workin --- plugins/bombadil/plugin/options.lua | 2 +- plugins/dap.lua | 48 +++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/plugins/bombadil/plugin/options.lua b/plugins/bombadil/plugin/options.lua index 02b2ad7..733cf2c 100644 --- a/plugins/bombadil/plugin/options.lua +++ b/plugins/bombadil/plugin/options.lua @@ -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 diff --git a/plugins/dap.lua b/plugins/dap.lua index 21f8712..6e33be0 100644 --- a/plugins/dap.lua +++ b/plugins/dap.lua @@ -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", @@ -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 = "d"