mfussenegger / nvim-dap

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

Breakpoint rejected sign "R" appears even though debugger paused #1205

Closed morhaham2 closed 1 month ago

morhaham2 commented 7 months ago

Debug adapter definition and debug configuration

return {
  {
    "rcarriga/nvim-dap-ui",
    dependencies = {
      "mfussenegger/nvim-dap",
      "nvim-neotest/nvim-nio",
      "folke/neodev.nvim",
    },
    config = function()
      local dap, dapui = require("dap"), require("dapui")
      dap.listeners.before.attach.dapui_config = function()
        dapui.open()
      end
      dap.listeners.before.launch.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
      vim.fn.sign_define(
        "DapBreakpoint",
        { text = "🛑", texthl = "", linehl = "", numhl = "" }
      )
      require("neodev").setup({
        library = { plugins = { "nvim-dap-ui" }, types = true },
      })
      require("dapui").setup()
    end,
  },
  {
    "mfussenegger/nvim-dap",
    config = function()
      local dap = require("dap")

      -- Go
      dap.adapters.go = {
        type = "executable",
        command = "node",
        args = {
          os.getenv("HOME") .. "/dap/vscode-go/extension/dist/debugAdapter.js",
        },
      }
      dap.configurations.go = {
        {
          type = "go",
          name = "Debug",
          request = "launch",
          showLog = false,
          program = "${file}",
          dlvToolPath = vim.fn.exepath("dlv"),
        },
      }

      -- Nodejs
      require("dap").adapters["pwa-node"] = {
        type = "server",
        host = "localhost",
        port = "${port}",
        executable = {
          command = "node",
          args = { "/Users/morh/dap/js-debug/src/dapDebugServer.js", "${port}" },
        },
      }
      require("dap").configurations.typescript = {
        {
          type = "pwa-node",
          request = "attach",
          -- sourceMaps = true,
          outDir = "dist",
          -- restart = true,
          name = "Launch file",
          program = "${file}",
          cwd = "${workspaceFolder}",
        },
      }

      -- keymaps
      vim.keymap.set("n", "<F5>", function()
        require("dap").continue()
      end, { desc = "Continue" })
      vim.keymap.set("n", "<F6>", function()
        require("dap").disconnect()
      end, { desc = "Continue" })
      vim.keymap.set("n", "<F2>", function()
        require("dap").step_over()
      end)
      vim.keymap.set("n", "<F3>", function()
        require("dap").step_into()
      end)
      vim.keymap.set("n", "<F4>", function()
        require("dap").step_out()
      end)
      vim.keymap.set("n", "<Leader>b", function()
        require("dap").toggle_breakpoint()
      end, { desc = "Toggle breakpoint" })
      vim.keymap.set("n", "<Leader>B", function()
        require("dap").set_breakpoint()
      end)
      vim.keymap.set("n", "<Leader>lp", function()
        require("dap").set_breakpoint(
          nil,
          nil,
          vim.fn.input("Log point message: ")
        )
      end)
      vim.keymap.set("n", "<Leader>dr", function()
        require("dap").repl.open()
      end)
      vim.keymap.set("n", "<Leader>dl", function()
        require("dap").run_last()
      end)
      vim.keymap.set({ "n", "v" }, "<Leader>dh", function()
        require("dap.ui.widgets").hover()
      end)
      vim.keymap.set({ "n", "v" }, "<Leader>dp", function()
        require("dap.ui.widgets").preview()
      end)
      vim.keymap.set("n", "<Leader>df", function()
        local widgets = require("dap.ui.widgets")
        widgets.centered_float(widgets.frames)
      end)
      vim.keymap.set("n", "<Leader>ds", function()
        local widgets = require("dap.ui.widgets")
        widgets.centered_float(widgets.scopes)
      end)
    end,
  },
  {
    "folke/neodev.nvim",
    opts = {},
  },
}

Debug adapter version

js-debug-dap-v1.89.0

Steps to Reproduce

  1. In a typescript run tsc && node --inspect-brk ./dist/main.js
  2. continue until debugger stops at the first breakpoint

Expected Result

The debugger stops at the right breakpoint and the sign afterwards should not be "R"

Actual Result

The column sign is "R"

image
mfussenegger commented 7 months ago

Can you show the logs? If a B turns into a R is mostly up to the debug adapter, so not sure there's much to be done here on the client side.

mfussenegger commented 1 month ago

Closing due to lack of feedback