### Install and Configure nvim-dap-vscode-js with Packer Source: https://context7.com/mxsdev/nvim-dap-vscode-js/llms.txt This Lua code snippet demonstrates how to install the nvim-dap-vscode-js plugin and its dependencies (nvim-dap and vscode-js-debug) using packer.nvim. It also shows the setup for the debugger adapter and defines various debug configurations for JavaScript and TypeScript projects. ```lua -- In your packer configuration (lua/plugins.lua or similar) return require("packer").startup(function(use) -- DAP core plugin use { "mfussenegger/nvim-dap" } -- This adapter plugin use { "mxsdev/nvim-dap-vscode-js", requires = { "mfussenegger/nvim-dap" } } -- The Microsoft debugger (builds automatically) use { "microsoft/vscode-js-debug", opt = true, run = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out", } end) -- In your DAP configuration file (lua/config/dap.lua or similar) require("dap-vscode-js").setup({ debugger_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/vscode-js-debug", adapters = { "pwa-node", "pwa-chrome", "node-terminal" }, log_file_level = vim.log.levels.DEBUG, log_console_level = vim.log.levels.ERROR, }) -- Configure for JavaScript and TypeScript for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do require("dap").configurations[language] = { -- Launch current file { type = "pwa-node", request = "launch", name = "Launch Current File", program = "${file}", cwd = "${workspaceFolder}", }, -- Attach to running process { type = "pwa-node", request = "attach", name = "Attach to Process", processId = require("dap.utils").pick_process, cwd = "${workspaceFolder}", }, -- Debug Jest tests { type = "pwa-node", request = "launch", name = "Debug Jest Tests", runtimeExecutable = "node", runtimeArgs = { "./node_modules/jest/bin/jest.js", "--runInBand" }, rootPath = "${workspaceFolder}", cwd = "${workspaceFolder}", console = "integratedTerminal", internalConsoleOptions = "neverOpen", }, -- Debug in Chrome { type = "pwa-chrome", request = "launch", name = "Launch Chrome", url = "http://localhost:3000", webRoot = "${workspaceFolder}", }, } end -- Keymaps for debugging vim.keymap.set("n", "", function() require("dap").continue() end) vim.keymap.set("n", "", function() require("dap").step_over() end) vim.keymap.set("n", "", function() require("dap").step_into() end) vim.keymap.set("n", "", function() require("dap").step_out() end) vim.keymap.set("n", "b", function() require("dap").toggle_breakpoint() end) ``` -------------------------------- ### Setup nvim-dap-vscode-js Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/README.md This Lua snippet shows the basic setup for nvim-dap-vscode-js. It includes configuration options for the Node.js path, debugger path, and which adapters to register. It also demonstrates how to set up debug configurations for JavaScript and TypeScript. ```lua require("dap-vscode-js").setup({ -- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node" -- debugger_path = "(runtimedir)/site/pack/packer/opt/vscode-js-debug", -- Path to vscode-js-debug installation. -- debugger_cmd = { "js-debug-adapter" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`. adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' }, -- which adapters to register in nvim-dap -- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging -- log_file_level = false -- Logging level for output to file. Set to false to disable file logging. -- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output. }) for _, language in ipairs({ "typescript", "javascript" }) do require("dap").configurations[language] = { ... -- see below } end ``` -------------------------------- ### Install vscode-js-debug with Packer Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/README.md This snippet demonstrates how to install the vscode-js-debug dependency using Packer. It includes commands to install npm dependencies, build the debug server, and move the output to the 'out' directory. ```lua use { "microsoft/vscode-js-debug", opt = true, run = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out" } ``` -------------------------------- ### Manually Install vscode-js-debug Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/README.md This snippet provides the bash commands to manually clone, install dependencies, build, and prepare the vscode-js-debug for use with nvim-dap-vscode-js. It's an alternative to using a package manager. ```bash git clone https://github.com/microsoft/vscode-js-debug cd vscode-js-debug npm install --legacy-peer-deps npx gulp vsDebugServerBundle mv dist out ``` -------------------------------- ### Node.js Debug Configurations Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/README.md These Lua snippets define launch and attach configurations for debugging Node.js applications using the 'pwa-node' adapter. The 'Launch file' configuration starts a new Node.js process with the current file, while 'Attach' connects to an existing process. ```lua { { 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}", } } ``` -------------------------------- ### Install nvim-dap-vscode-js with Packer Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/README.md This snippet shows how to install the nvim-dap-vscode-js plugin using the Packer package manager for Neovim. It requires the 'mfussenegger/nvim-dap' plugin to be installed as well. ```lua use { "mxsdev/nvim-dap-vscode-js", requires = {"mfussenegger/nvim-dap"} } ``` -------------------------------- ### dapjs.setup() Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/doc/nvim-dap-vscode-js.txt Initializes and sets up the debugger adapter and/or configurations using the provided settings. ```APIDOC ## dapjs.setup() ### Description Setup adapter and/or configs for the dap-vscode-js plugin. ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua dapjs.setup({ node_path = "/path/to/node", debugger_path = "/path/to/vscode-js-debug", adapters = {"pwa-node"} }) ``` ### Response #### Success Response (200) N/A (Function Call) #### Response Example N/A (Function Call) ### Parameters - **settings** (Settings) - An object containing the configuration settings for the debugger. See the 'Plugin Configuration Settings' section for details. ``` -------------------------------- ### Initialize nvim-dap-vscode-js Adapter Source: https://context7.com/mxsdev/nvim-dap-vscode-js/llms.txt Initializes the nvim-dap-vscode-js plugin, configuring debug adapters and setting up session hooks. This function must be called before debugging features can be used. It accepts a settings table for customization. ```lua require("dap-vscode-js").setup({ adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' }, }) ``` ```lua require("dap-vscode-js").setup({ -- Path to Node.js executable (defaults to $NODE_PATH, then "node") node_path = "node", -- Path to vscode-js-debug installation debugger_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/vscode-js-debug", -- Custom command to launch debug server (overrides node_path and debugger_path) -- debugger_cmd = { "js-debug-adapter" }, -- Which adapters to register in nvim-dap adapters = { 'pwa-node', 'pwa-chrome' }, -- Log file path for debugging issues log_file_path = vim.fn.stdpath("cache") .. "/dap_vscode_js.log", -- Logging level for file output (false to disable, or vim.log.levels.DEBUG, etc.) log_file_level = vim.log.levels.DEBUG, -- Logging level for console output log_console_level = vim.log.levels.ERROR, }) ``` -------------------------------- ### Plugin Configuration Settings Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/doc/nvim-dap-vscode-js.txt This section details the available configuration options for the dap-vscode-js plugin. These settings allow customization of the debugger's behavior, including paths, commands, adapters, and logging. ```APIDOC ## Plugin Configuration Settings ### Description Configuration options for the dap-vscode-js plugin. ### Method N/A (Configuration) ### Endpoint N/A (Configuration) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "node_path": "/path/to/node", "debugger_path": "/path/to/vscode-js-debug", "debugger_cmd": ["node", "/path/to/vscode-js-debug/bin/debug.js"], "adapters": ["pwa-node", "pwa-chrome"], "log_file_path": "/tmp/dap_vscode_js.log", "log_file_level": 2, "log_console_level": 3 } ``` ### Response #### Success Response (200) N/A (Configuration) #### Response Example N/A (Configuration) ### Settings Fields - **node_path** (string) - Path of node executable. Defaults to $NODE_PATH, and then "node". - **debugger_path** (string) - Path to vscode-js-debug. Defaults to (runtimedir)/site/pack/packer/opt/vscode-js-debug. - **debugger_cmd** (string[]) - The command to use to launch the debug server. This option takes precedence over both `node_path` and `debugger_path`. - **adapters** (string[]) - List of adapters to configure. Options are 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost'. Defaults to all. See https://github.com/microsoft/vscode-js-debug/blob/main/OPTIONS.md for configuration options. - **log_file_path** (string) - Log file path. Defaults to (stdpath cache)/dap_vscode_js.log. - **log_file_level** (number) - Logging level for output to file. Set to false to disable file logging. Default is false. - **log_console_level** (number) - Logging level for output to console. Set to false to disable console output. Default is vim.log.levels.ERROR. ``` -------------------------------- ### Jest Debug Configuration Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/README.md This Lua snippet provides a debug configuration for running and debugging Jest tests with Node.js. It specifies the runtime executable, arguments to run Jest, and console options for integrated terminal output. ```lua { { type = "pwa-node", request = "launch", name = "Debug Jest Tests", -- trace = true, -- include debugger info runtimeExecutable = "node", runtimeArgs = { "./node_modules/jest/bin/jest.js", "--runInBand", }, rootPath = "${workspaceFolder}", cwd = "${workspaceFolder}", console = "integratedTerminal", internalConsoleOptions = "neverOpen", } } ``` -------------------------------- ### Configure Mocha Test Debugging for nvim-dap Source: https://context7.com/mxsdev/nvim-dap-vscode-js/llms.txt Sets up nvim-dap configurations for debugging Mocha test suites using the `pwa-node` adapter. This configuration specifies the runtime executable and arguments for the Mocha CLI, directing output to the integrated terminal. ```lua require("dap").configurations.javascript = { { type = "pwa-node", request = "launch", name = "Debug Mocha Tests", runtimeExecutable = "node", runtimeArgs = { "./node_modules/mocha/bin/mocha.js", }, rootPath = "${workspaceFolder}", cwd = "${workspaceFolder}", console = "integratedTerminal", internalConsoleOptions = "neverOpen", }, } ``` -------------------------------- ### Configure Node.js Debugging for nvim-dap Source: https://context7.com/mxsdev/nvim-dap-vscode-js/llms.txt Sets up nvim-dap configurations for debugging Node.js applications using the `pwa-node` adapter. Supports launching scripts and attaching to running processes. These configurations are applied to both JavaScript and TypeScript files. ```lua require("dap").configurations.javascript = { { type = "pwa-node", request = "launch", name = "Launch file", program = "${file}", cwd = "${workspaceFolder}", }, { type = "pwa-node", request = "attach", name = "Attach to Process", processId = require("dap.utils").pick_process, cwd = "${workspaceFolder}", }, } -- Apply same configurations for TypeScript require("dap").configurations.typescript = require("dap").configurations.javascript ``` -------------------------------- ### Mocha Debug Configuration Source: https://github.com/mxsdev/nvim-dap-vscode-js/blob/main/README.md This Lua snippet defines a debug configuration for running and debugging Mocha tests with Node.js. Similar to the Jest configuration, it sets the runtime executable, arguments for Mocha, and console options for integrated terminal output. ```lua { { type = "pwa-node", request = "launch", name = "Debug Mocha Tests", -- trace = true, -- include debugger info runtimeExecutable = "node", runtimeArgs = { "./node_modules/mocha/bin/mocha.js", }, rootPath = "${workspaceFolder}", cwd = "${workspaceFolder}", console = "integratedTerminal", internalConsoleOptions = "neverOpen", } } ``` -------------------------------- ### Configure Chrome Browser Debugging for nvim-dap Source: https://context7.com/mxsdev/nvim-dap-vscode-js/llms.txt Configures nvim-dap to debug web applications in Chrome using the `pwa-chrome` adapter. Supports launching Chrome to a specified URL or attaching to an existing Chrome instance. Note that breakpoint support might be partial. ```lua require("dap").configurations.javascript = { { type = "pwa-chrome", request = "launch", name = "Launch Chrome against localhost", url = "http://localhost:3000", webRoot = "${workspaceFolder}", }, { type = "pwa-chrome", request = "attach", name = "Attach to Chrome", port = 9222, webRoot = "${workspaceFolder}", }, } ``` -------------------------------- ### Configure Jest Test Debugging for nvim-dap Source: https://context7.com/mxsdev/nvim-dap-vscode-js/llms.txt Configures nvim-dap to debug Jest test suites using the `pwa-node` adapter. It runs Jest in band mode and directs output to the integrated terminal. Supports debugging all tests or a specific file. ```lua require("dap").configurations.javascript = { { type = "pwa-node", request = "launch", name = "Debug Jest Tests", runtimeExecutable = "node", runtimeArgs = { "./node_modules/jest/bin/jest.js", "--runInBand", }, rootPath = "${workspaceFolder}", cwd = "${workspaceFolder}", console = "integratedTerminal", internalConsoleOptions = "neverOpen", }, } -- For debugging a specific test file require("dap").configurations.javascript = { { type = "pwa-node", request = "launch", name = "Debug Current Jest Test File", runtimeExecutable = "node", runtimeArgs = { "./node_modules/jest/bin/jest.js", "--runInBand", "${file}", }, rootPath = "${workspaceFolder}", cwd = "${workspaceFolder}", console = "integratedTerminal", internalConsoleOptions = "neverOpen", }, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.