From 512c23876311ac5bda8f2a720b5e0763b1a79a72 Mon Sep 17 00:00:00 2001 From: ofrades Date: Wed, 31 May 2023 00:00:03 +0100 Subject: [PATCH] feat(dap): add jest and vitest config --- .../plugins/extras/lang/typescript.lua | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 4aeaf5f9..da2802e8 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -92,25 +92,49 @@ return { }, } end - for _, language in ipairs({ "typescript", "javascript" }) do - if not dap.configurations[language] then - dap.configurations[language] = { - { - type = "pwa-node", - request = "launch", - name = "Launch file", - program = "${file}", - cwd = "${workspaceFolder}", - }, - { - type = "pwa-node", - request = "attach", - name = "Attach", - processId = require("dap.utils").pick_process, - cwd = "${workspaceFolder}", - }, - } - end + for _, language in ipairs({ "typescript", "typescriptreact", "javascript", "javascriptreact" }) do + dap.configurations[language] = { + { + type = "pwa-node", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "attach", + name = "Attach", + processId = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "launch", + name = "Launch test file (pwa-node with jest)", + cwd = vim.fn.getcwd(), + runtimeArgs = { "${workspaceFolder}/node_modules/.bin/jest" }, + runtimeExecutable = "node", + args = { "${file}", "--coverage", "false" }, + rootPath = "${workspaceFolder}", + sourceMaps = true, + console = "integratedTerminal", + internalConsoleOptions = "neverOpen", + skipFiles = { "/**", "node_modules/**" }, + }, + { + type = "pwa-node", + request = "launch", + name = "Launch test file (pwa-node with vitest)", + cwd = vim.fn.getcwd(), + program = "${workspaceFolder}/node_modules/vitest/vitest.mjs", + args = { "--inspect-brk", "--threads", "false", "run", "${file}" }, + autoAttachChildProcesses = true, + smartStep = true, + console = "integratedTerminal", + skipFiles = { "/**", "node_modules/**" }, + }, + } end end, },