Skip to content

Commit

Permalink
refactor: adapter options
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jun 15, 2024
1 parent e203f49 commit ee67773
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
27 changes: 2 additions & 25 deletions lua/neotest-golang/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,34 +145,11 @@ function M.Adapter.results(spec, result, tree)
)
end

--- Adapter options.
setmetatable(M.Adapter, {
__call = function(_, opts)
return M.Adapter.setup(opts)
return options.setup(opts)
end,
})

M.Adapter.setup = function(opts)
opts = opts or {}
if opts.args or opts.dap_go_args then
-- temporary warning
vim.notify(
"Please update your config, the arguments/opts have changed for neotest-golang.",
vim.log.levels.WARN
)
end
if opts.go_test_args then
if opts.go_test_args then
options._go_test_args = opts.go_test_args
end
if opts.dap_go_enabled then
options._dap_go_enabled = opts.dap_go_enabled
if opts.dap_go_opts then
options._dap_go_opts = opts.dap_go_opts
end
end
end

return M.Adapter
end

return M.Adapter
32 changes: 29 additions & 3 deletions lua/neotest-golang/options.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- These are the default options for neotest-golang. You can override them by
-- providing them as arguments to the Adapter function. See the README for mode
-- details and examples.
--- These are the default options for neotest-golang. You can override them by
--- providing them as arguments to the Adapter function. See the README for mode
--- details and examples.

local M = {}

Expand All @@ -22,4 +22,30 @@ M._dap_go_enabled = false
--- @type table
M._dap_go_opts = {}

--- Option setup function. This is what you call when setting up the adapter.
--- @param opts table
function M.setup(opts)
opts = opts or {}
if opts.args or opts.dap_go_args then
-- temporary warning
vim.notify(
"Please update your config, the arguments/opts have changed for neotest-golang.",
vim.log.levels.WARN
)
end
if opts.go_test_args then
if opts.go_test_args then
M._go_test_args = opts.go_test_args
end
if opts.dap_go_enabled then
M._dap_go_enabled = opts.dap_go_enabled
if opts.dap_go_opts then
M._dap_go_opts = opts.dap_go_opts
end
end
end

return M.Adapter
end

return M

0 comments on commit ee67773

Please sign in to comment.