Skip to content

An extension for nvim-dap that seamlessly integrates the Go debugger (Delve) with Bazel-built projects

License

Notifications You must be signed in to change notification settings

VanyaDNDZ/nvim-dap-bazel-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvim-dap-bazel-go

nvim-dap-bazel-go is an extension for nvim-dap that provides a seamless debugging experience for Go projects built with Bazel. It integrates with Delve to launch and debug Go applications and tests compiled by Bazel, handling source path mappings and test execution automatically.

Features

  • Automatically launches Delve for debugging Bazel-built Go binaries.
  • Debug individual tests with TreeSitter-based test detection.
  • Supports debugging Go applications and test files compiled by Bazel.
  • Automatic conversion of source paths for breakpoints using substitutePath.
  • Works with both MODULE.bazel and WORKSPACE Bazel workspaces.
  • Customizable Delve configurations.
  • Supports function breakpoints.

Requirements

  • Neovim 0.10+
  • nvim-dap
  • Delve (dlv must be installed and available in $PATH)
  • nvim-treesitter (for test detection)
  • Bazel (installed and available in $PATH)

Installation

Using LazyVim

Add the following to your LazyVim plugin configuration:

return {
  {
    "VanyaDNDZ/nvim-dap-bazel-go",
    config = function()
      require("dap-bazel-go").setup({
        -- Delve configurations:
        delve = {
          path = "dlv", -- Path to the Delve binary
          initialize_timeout_sec = 20,
          port = "${port}",
          args = {},
          detached = vim.fn.has("win32") == 0,
        },
      })
      -- Optionally define key mappings:
      local dbgo = require("dap-bazel-go")
      vim.keymap.set("n", "<leader>dt", dbgo.debug_test_at_cursor, { desc = "Debug test at cursor" })
      vim.keymap.set("n", "<leader>df", dbgo.debug_file_test, { desc = "Debug file test" })
      vim.keymap.set("n", "<leader>dl", dbgo.debug_last_test, { desc = "Re-run last test" })
      vim.keymap.set("n", "<leader>dfb", dbgo.set_function_breakpoint, { desc = "Set function breakpoint" })
    end,
    dependencies = {
      "mfussenegger/nvim-dap",
      "nvim-treesitter/nvim-treesitter",
    },
  },
}

Usage

Key Mappings

Acknowledgement

I would like to acknowledge nvim-dap-go for inspiration and NVIDIA/bluebazel for insights on Bazel query.

License

This plugin is licensed under the MIT License.

About

An extension for nvim-dap that seamlessly integrates the Go debugger (Delve) with Bazel-built projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages