From 18c31a9373198a45397e2d6afa091390707c5e5c Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Fri, 28 Jun 2024 21:07:23 +0200 Subject: [PATCH] fix: options not returned (#63) --- lua/neotest-golang/init.lua | 1 + lua/neotest-golang/options.lua | 57 +++++++++++++--------------------- 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/lua/neotest-golang/init.lua b/lua/neotest-golang/init.lua index 706a73fb..88335583 100644 --- a/lua/neotest-golang/init.lua +++ b/lua/neotest-golang/init.lua @@ -179,6 +179,7 @@ end setmetatable(M.Adapter, { __call = function(_, opts) M.Adapter.options = options.setup(opts) + return M.Adapter end, }) diff --git a/lua/neotest-golang/options.lua b/lua/neotest-golang/options.lua index d9e6e059..9e8f7f21 100644 --- a/lua/neotest-golang/options.lua +++ b/lua/neotest-golang/options.lua @@ -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