-- return { -- "nvim-neotest/neotest", -- dependencies = { -- "mfussenegger/nvim-dap-python", -- "antoinemadec/FixCursorHold.nvim", -- "nvim-neotest/nvim-nio", -- "nvim-neotest/neotest-go", -- }, -- config = function() -- local neotest_ns = vim.api.nvim_create_namespace("neotest") -- vim.diagnostic.config({ -- virtual_text = { -- format = function(diagnostic) -- local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "") -- return message -- end, -- }, -- }, neotest_ns) -- require("neotest").setup({ -- -- your neotest config here -- adapters = { -- require("neotest-go"), -- }, -- }) -- end, -- -- stylua: ignore -- -- test single test check -- -- https://freshman.tech/snippets/go/run-specific-test/ -- keys = { -- { "T","",desc="  Test"}, -- { "Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, -- { "TT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" }, -- { "Tl", function() require("neotest").run.run_last() end, desc = "Run Last" }, -- { "Ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" }, -- { "To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" }, -- { "TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" }, -- { "TS", function() require("neotest").run.stop() end, desc = "Stop" }, -- }, -- } -- rujukan -- https://github.com/fredrikaverpil/neotest-golang local M = {} if pcode.gotest then M = { "nvim-neotest/neotest", event = "VeryLazy", dependencies = { "nvim-lua/plenary.nvim", "antoinemadec/FixCursorHold.nvim", "nvim-treesitter/nvim-treesitter", "nvim-neotest/neotest-plenary", "nvim-neotest/neotest-vim-test", "nvim-neotest/nvim-nio", { "fredrikaverpil/neotest-golang", dependencies = { { "leoluz/nvim-dap-go", opts = {}, }, }, branch = "main", }, }, opts = function(_, opts) opts.adapters = opts.adapters or {} opts.adapters["neotest-golang"] = { go_test_args = { "-v", "-race", "-count=1", "-timeout=60s", "-coverprofile=" .. vim.fn.getcwd() .. "/coverage.out", }, dap_go_enabled = true, } end, config = function(_, opts) if opts.adapters then local adapters = {} for name, config in pairs(opts.adapters or {}) do if type(name) == "number" then if type(config) == "string" then config = require(config) end adapters[#adapters + 1] = config elseif config ~= false then local adapter = require(name) if type(config) == "table" and not vim.tbl_isempty(config) then local meta = getmetatable(adapter) if adapter.setup then adapter.setup(config) elseif meta and meta.__call then adapter(config) else error("Adapter " .. name .. " does not support setup") end end adapters[#adapters + 1] = adapter end end opts.adapters = adapters end require("neotest").setup(opts) end, -- stylua: ignore keys = { { "T","",desc="  Test"}, { "Ta", function() require("neotest").run.attach() end, desc = "[t]est [a]ttach" }, { "Tf", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "[t]est run [f]ile" }, { "TA", function() require("neotest").run.run(vim.uv.cwd()) end, desc = "[t]est [A]ll files" }, { "TS", function() require("neotest").run.run({ suite = true }) end, desc = "[t]est [S]uite" }, { "Tn", function() require("neotest").run.run() end, desc = "[t]est [n]earest" }, { "Tl", function() require("neotest").run.run_last() end, desc = "[t]est [l]ast" }, { "Ts", function() require("neotest").summary.toggle() end, desc = "[t]est [s]ummary" }, { "To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "[t]est [o]utput" }, { "TO", function() require("neotest").output_panel.toggle() end, desc = "[t]est [O]utput panel" }, { "Tt", function() require("neotest").run.stop() end, desc = "[t]est [t]erminate" }, { "Td", function() require("neotest").run.run({ suite = false, strategy = "dap" }) end, desc = "Debug nearest test" }, }, } end return M