mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.67k stars 207 forks source link

No output for list_breakpoints and status functions #1351

Closed timsofteng closed 1 month ago

timsofteng commented 1 month ago

Debug adapter definition and debug configuration

local dap = require("dap")
require("dapui").setup()
dap.adapters["pwa-node"] = {
    type = "server",
    host = "localhost",
    port = "${port}",
    executable = {
        command = "node",
        args = {
            os.getenv("HOME") .. "/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js",
            "${port}",
        },
    },
}

require("dap").configurations.javascript = {
    {
        type = "pwa-node",
        request = "launch",
        name = "Launch file",
        program = "${file}",
        cwd = "${workspaceFolder}",
    },
}

dap.adapters.chrome = {
    type = "executable",
    command = "node",
    -- command = "chrome-debug-adapter",
    args = { os.getenv("HOME") .. "/.local/share/nvim/mason/packages/chrome-debug-adapter/out/src/chromeDebug.js" }, -- TODO adjust
}

dap.configurations.typescriptreact = {
    {
        type = "chrome",
        request = "attach",
        program = "${file}",
        cwd = vim.fn.getcwd(),
        sourceMaps = true,
        protocol = "inspector",
        port = 9222,
        webRoot = "${workspaceFolder}",
    },
}

dap.configurations.javascriptreact = {
    {
        type = "chrome",
        request = "attach",
        program = "${file}",
        cwd = vim.fn.getcwd(),
        sourceMaps = true,
        protocol = "inspector",
        port = 9222,
        webRoot = "${workspaceFolder}",
    },
}

Debug adapter version

js-debug-adapter 1.94.0

Steps to Reproduce

  1. Create file test.js with this simple code
    
    let count = 0;

function logMessage() { if (count < 10) { count++; console.log("count", count); setTimeout(logMessage, 1000); } }

logMessage();



2. Set breakpoint into line `setTimeout(logMessage, 1000); `.
2. Run `:<cmd>lua require'dap'.continue()<cr>`.
3. Run `:<cmd>lua require'dap'.status()<cr>` or `:<cmd>lua require'dap'.list_breakpoints()<cr>`.
There is no output .

### Expected Result

Status command should return status.
List command should open qf window with breakpoints.

### Actual Result

Both commands do nothing.
mfussenegger commented 1 month ago

Please read the functions docs.

status() returns a string, so you'd have to print it or something. The intention behind it is to include it in the statusline

list_breakpoints() adds the breakpoints to the quickfix list, but it doesn't open it automatically.