Skip to content

Commit

Permalink
fix: options not returned (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jun 28, 2024
1 parent f822930 commit 18c31a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 36 deletions.
1 change: 1 addition & 0 deletions lua/neotest-golang/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ end
setmetatable(M.Adapter, {
__call = function(_, opts)
M.Adapter.options = options.setup(opts)
return M.Adapter
end,
})

Expand Down
57 changes: 21 additions & 36 deletions lua/neotest-golang/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,32 @@
--- providing them as arguments to the Adapter function. See the README for mode
--- details and examples.

local Opts = {}

--- Create a new options object.
function Opts:new(opts)
self.go_test_args = opts.go_test_args
or {
"-v",
"-race",
"-count=1",
}
self.dap_go_enabled = opts.dap_go_enabled or false
self.dap_go_opts = opts.dap_go_opts or {}
self.warn_test_name_dupes = opts.warn_test_name_dupes or true
self.warn_test_not_executed = opts.warn_test_not_executed or true
self.dev_notifications = opts.dev_notifications or false
end

--- A convenience function to get the current options.
function Opts:get()
return {
go_test_args = self.go_test_args,
dap_go_enabled = self.dap_go_enabled,
dap_go_opts = self.dap_go_opts,
warn_test_name_dupes = self.warn_test_name_dupes,
warn_test_not_executed = self.warn_test_not_executed,
dev_notifications = self.dev_notifications,
}
end

local M = {}

--- Set up the adapter.
function M.setup(opts)
opts = opts or {}
Opts:new(opts)
return Opts:get()
local opts = {
go_test_args = {
"-v",
"-race",
"-count=1",
},
dap_go_enabled = false,
dap_go_opts = {},
warn_test_name_dupes = true,
warn_test_not_executed = true,
dev_notifications = false,
}

function M.setup(user_opts)
if type(user_opts) == "table" and not vim.tbl_isempty(user_opts) then
for k, v in pairs(user_opts) do
opts[k] = v
end
else
end
end

--- Get the adapter configuration.
function M.get()
return Opts:get()
return opts
end

return M

0 comments on commit 18c31a9

Please sign in to comment.