Neovim + DebugAdapter.jl

Hi neovim users,

Similar to Neovim + LanguageServer.jl I thought I’d make a post about neovim and DebugAdapter.jl.

You might already know that neovim supports the Microsoft Debug Adapter Protocol (DAP) using mfussenegger/nvim-dap. Recently @davidanthoff merged support for DAP into DebugAdapter.jl. And now you can use it in neovim!

Here’s an example of the config in lua that I used to generate the video above:

return {
  {
    "mfussenegger/nvim-dap",
    dependencies = {
      "rcarriga/nvim-dap-ui",
      "theHamsta/nvim-dap-virtual-text",
      "nvim-neotest/nvim-nio",
      "kdheepak/nvim-dap-julia",
    },
    config = function()
      local dap = require("dap")
      local ui = require("dapui")

      require("dapui").setup()
      require("nvim-dap-julia").setup()

      vim.keymap.set("n", "<space>b", dap.toggle_breakpoint)
      vim.keymap.set("n", "<space>B", dap.run_to_cursor)

      vim.keymap.set("n", "<F1>", dap.continue)
      vim.keymap.set("n", "<F2>", dap.step_into)
      vim.keymap.set("n", "<F3>", dap.step_over)
      vim.keymap.set("n", "<F4>", dap.step_out)
      vim.keymap.set("n", "<F5>", dap.step_back)
      vim.keymap.set("n", "<F12>", dap.restart)

      dap.listeners.before.attach.dapui_config = function()
        ui.open()
      end
      dap.listeners.before.launch.dapui_config = function()
        ui.open()
      end
      dap.listeners.before.event_terminated.dapui_config = function()
        ui.close()
      end
      dap.listeners.before.event_exited.dapui_config = function()
        ui.close()
      end
    end,
  },
}

Check out how it works here:

6 Likes