diff --git a/README.md b/README.md index 2e979010..f8ad86fd 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,6 @@ You can run `:checkhealth neotest-golang` to review common issues. | Argument | Default value | Description | | ------------------------ | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `go_test_args` | `{ "-v", "-race", "-count=1" }` | Arguments to pass into `go test`. | -| `dap_go_enabled` | `false` | Leverage [leoluz/nvim-dap-go](https://github.com/leoluz/nvim-dap-go) for debugging tests. | | `dap_go_opts` | `{}` | Options to pass into `require("dap-go").setup()`. | | `testify_enabled` | `false` | Enable support for [testify](https://github.com/stretchr/testify) suites. See [here](https://github.com/fredrikaverpil/neotest-golang#testify-suites) for more info. | | `warn_test_name_dupes` | `true` | Warn about duplicate test names within the same Go package. | @@ -113,17 +112,42 @@ See `go help test`, `go help testflag`, `go help build` for possible arguments. To debug tests, make sure you depend on [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap), [rcarriga/nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui) and -[leoluz/nvim-dap-go](https://github.com/leoluz/nvim-dap-go). +[leoluz/nvim-dap-go](https://github.com/leoluz/nvim-dap-go). For example, make +the following changes to your lua setup: -Then set `dap_go_enabled` to `true`: - -```lua -local config = { dap_go_enabled = true } -- Specify configuration -require("neotest").setup({ - adapters = { - require("neotest-golang")(config), -- Apply configuration +```diff +return { ++ { ++ "rcarriga/nvim-dap-ui", ++ dependencies = { ++ "mfussenegger/nvim-dap", ++ "nvim-neotest/nvim-nio", ++ }, ++ }, + { + "nvim-neotest/neotest", + dependencies = { + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter", +- "fredrikaverpil/neotest-golang", -- Installation ++ { ++ "fredrikaverpil/neotest-golang", -- Installation ++ dependencies = { ++ "leoluz/nvim-dap-go", ++ }, ++ }, + }, + config = function() + require("neotest").setup({ + adapters = { + require("neotest-golang"), -- Registration + }, + }) + end, }, -}) +} ``` Finally, set a keymap, like: @@ -185,7 +209,6 @@ return { "-race", "-coverprofile=" .. vim.fn.getcwd() .. "/coverage.out", }, - dap_go_enabled = true, } end, config = function(_, opts) diff --git a/lua/neotest-golang/options.lua b/lua/neotest-golang/options.lua index 5d382720..8482a765 100644 --- a/lua/neotest-golang/options.lua +++ b/lua/neotest-golang/options.lua @@ -8,7 +8,6 @@ local M = {} local opts = { go_test_args = { "-v", "-race", "-count=1" }, - dap_go_enabled = false, dap_go_opts = {}, testify_enabled = false, warn_test_name_dupes = true, diff --git a/lua/neotest-golang/runspec/test.lua b/lua/neotest-golang/runspec/test.lua index 31d5bdd4..eecfd4b1 100644 --- a/lua/neotest-golang/runspec/test.lua +++ b/lua/neotest-golang/runspec/test.lua @@ -58,10 +58,9 @@ function M.build(pos, strategy) end function M.assert_dap_prerequisites() - local dap_go_enabled = options.get().dap_go_enabled local dap_go_found = pcall(require, "dap-go") - if not dap_go_enabled or not dap_go_found then - local msg = "You must set {dap_go_enabled=true} and have leoluz/nvim-dap-go installed to use DAP strategy. " + if not dap_go_found then + local msg = "You must have leoluz/nvim-dap-go installed to use DAP strategy. " .. "See the neotest-golang README for more information." logger.error(msg) error(msg) diff --git a/tests/unit/options_spec.lua b/tests/unit/options_spec.lua index 96f5aa7d..8b669990 100644 --- a/tests/unit/options_spec.lua +++ b/tests/unit/options_spec.lua @@ -9,7 +9,6 @@ describe("Options are set up", function() "-race", "-count=1", }, - dap_go_enabled = false, dap_go_opts = {}, testify_enabled = false, warn_test_name_dupes = true, @@ -32,7 +31,6 @@ describe("Options are set up", function() "-count=1", "-parallel=1", -- non-default }, - dap_go_enabled = false, dap_go_opts = {}, testify_enabled = false, warn_test_name_dupes = true,