Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: options not returned #63

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading