I'm looking to set up nvim-dap and followed the instructions for implementing it with Python and JavaScript, which seem very straightforward, but I can't seem to get it working. Here are my plugins:
-- Debugger
use("mfussenegger/nvim-dap")
use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} }
use('theHamsta/nvim-dap-virtual-text')
-- Python
use ('mfussenegger/nvim-dap-python')
require('dap-python').setup('~/.virtualenvs/debugpy/bin/python')
-- JavaScript
use { "mxsdev/nvim-dap-vscode-js", requires = {"mfussenegger/nvim-dap"} }
use {
"microsoft/vscode-js-debug",
opt = true,
run = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out"
}
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] = {
{
{
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
As Instructed in the nvim-dap-python readme I also set up a dedicated virtual environment under ~/.virtualenvs
.
When I go to a Python or JS file and run :lua require('dap').continue()
, I get the response
No configuration found for 'python/javascript'. You need to add configs to 'dap.configurations.python/javascript
My understanding of the dap-python and dap-vscode-js plugins is that they configure it so you don't have to. I also tried adding an example configuration from :help dap-configuration, but it didn't seem to work.
When I source my packer.lua file I also get an error:
[packer.nvim] [ERROR 10:50:48] packer.lua:1022: Failure running setup function: "...ite/pack/packer
/start/nvim-dap-python/lua/dap-python.lua:96: nvim-dap is required to use dap-python"
I'm not sure what would cause this since nvim-dap is already installed.
Here's a link to my neovim-config repo: https://github.com/samcurteis/neovim-config/tree/main
Quick summary:
I tried setting up the plugins as per the instructions on nvim-dap, nvim-dap-ui, nvim-dap-python and dap-vscode-js. I also attempted to manually configure the dap.configuration without success. When I ran :lua require('dap').continue()
, I expected the debugger to launch but it doesn't.