Skip to content

Commit

Permalink
feat(dap): pass dap-go opts as function
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Sep 21, 2024
1 parent 3481ae8 commit b49ad85
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ consider setting up neotest and its adapters in a

## ⚙️ Configuration

| Argument | Default value | Description |
| ------------------------ | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `go_test_args` | `{ "-v", "-race", "-count=1" }` | Arguments to pass into `go test`. Note: [`-tags` usage](https://github.com/fredrikaverpil/neotest-golang#using-build-tags), [pass args as function](https://github.com/fredrikaverpil/neotest-golang#pass-arguments-as-function-instead-of-table). |
| `go_list_args` | `{}` | Arguments to pass into `go list`. Note: [`-tags` usage](https://github.com/fredrikaverpil/neotest-golang#using-build-tags), [pass args as function](https://github.com/fredrikaverpil/neotest-golang#pass-arguments-as-function-instead-of-table). |
| `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. |
| `warn_test_not_executed` | `true` | Warn if test was not executed. |
| Argument | Default value | Description |
| ------------------------ | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `go_test_args` | `{ "-v", "-race", "-count=1" }` | Arguments to pass into `go test`. Note: [`-tags` usage](https://github.com/fredrikaverpil/neotest-golang#using-build-tags), [pass args as function](https://github.com/fredrikaverpil/neotest-golang#pass-arguments-as-function-instead-of-table). |
| `go_list_args` | `{}` | Arguments to pass into `go list`. Note: [`-tags` usage](https://github.com/fredrikaverpil/neotest-golang#using-build-tags), [pass args as function](https://github.com/fredrikaverpil/neotest-golang#pass-arguments-as-function-instead-of-table). |
| `dap_go_opts` | `{}` | Options to pass into `require("dap-go").setup()`. Note: [`-tags` usage](https://github.com/fredrikaverpil/neotest-golang#using-build-tags), [pass args as function](https://github.com/fredrikaverpil/neotest-golang#pass-arguments-as-function-instead-of-table). |
| `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. |
| `warn_test_not_executed` | `true` | Warn if test was not executed. |

### Example configuration: custom `go test` arguments

Expand Down Expand Up @@ -574,6 +574,15 @@ return {
-- provide custom logic here..
return { "-tags=integration" }
end,
dap_go_opts = function()
-- provide custom logic here..
return {
delve = {
build_flags = { "-tags=integration" },
},
}
end,
},
}),
},
})
Expand Down
3 changes: 3 additions & 0 deletions lua/neotest-golang/features/dap/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ local M = {}
---@param cwd string
function M.setup_debugging(cwd)
local dap_go_opts = options.get().dap_go_opts or {}
if type(dap_go_opts) == "function" then
dap_go_opts = dap_go_opts()
end
local dap_go_opts_original = vim.deepcopy(dap_go_opts)
if dap_go_opts.delve == nil then
dap_go_opts.delve = {}
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/options_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ describe("Options are set up", function()
go_list_args = function()
return {}
end,
dap_go_opts = {},
dap_go_opts = function()
return {}
end,
testify_enabled = false,
warn_test_name_dupes = true,
warn_test_not_executed = true,
Expand Down

0 comments on commit b49ad85

Please sign in to comment.