diff --git a/lazy-lock.json b/lazy-lock.json index d2a2098..9e0f4b8 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -22,11 +22,14 @@ "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, "mason-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "f5425eb1d0d794f0305d5eeebddabb74614683ff" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mini.indentscope": { "branch": "main", "commit": "f0d7faa064c892b96997810afcddfadc3f2a15b3" }, "neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" }, "neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" }, - "neotest-python": { "branch": "master", "commit": "2e83d2bc00acbcc1fd529dbf0a0e677cabfe6b50" }, + "neotest-golang": { "branch": "main", "commit": "2498842b3542daa4323836b392b173b922a90fd9" }, + "neotest-plenary": { "branch": "master", "commit": "dcaf5ed67a9e28a246e9783319e5aa6c9ea1c584" }, + "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "noice.nvim": { "branch": "main", "commit": "8f1d9966762e62fa8788e5fb1a5f6a86784221d9" }, "none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" }, "none-ls.nvim": { "branch": "main", "commit": "cc0a3c45047e3daf85d07c1571d65476cfce6480" }, @@ -34,7 +37,10 @@ "nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" }, "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, - "nvim-dap-python": { "branch": "master", "commit": "ae0225d0d4a46e18e6057ab3701ef87bbbd6aaad" }, + "nvim-dap": { "branch": "master", "commit": "5ba8ceace596360321cf33fa4b56d9d46e057ce9" }, + "nvim-dap-go": { "branch": "main", "commit": "a0c5a2b991d7e9304a9a032cf177e22a4b0acda1" }, + "nvim-dap-ui": { "branch": "master", "commit": "f7d75cca202b52a60c520ec7b1ec3414d6e77b0f" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "d7c695ea39542f6da94ee4d66176f5d660ab0a77" }, "nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" }, "nvim-material-icon": { "branch": "main", "commit": "2f1d6333bbec2e787774193c9fc7b447b878069a" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, diff --git a/lua/custom/default.lua b/lua/custom/default.lua index 5b7cac2..1360ca1 100644 --- a/lua/custom/default.lua +++ b/lua/custom/default.lua @@ -150,13 +150,16 @@ pcode.nvim_dap = false -- not support for windows os (auto config mason-nvim-dap pcode.nvim_dap_javascript = false pcode.nvim_dap_php = false pcode.nvim_dap_python = false +pcode.nvim_dap_go = true -- https://github.com/olimorris/neotest-phpunit pcode.phpunit = false -- https://github.com/nvim-neotest/neotest-python -- https://docs.pytest.org/en/7.1.x/getting-started.html -pcode.pytest = true +pcode.pytest = false -- https://github.com/nvim-neotest/neotest-jest pcode.jest = false pcode.jest_command = "npm test -- " pcode.jest_config = "jest.config.mjs" +-- https://github.com/fredrikaverpil/neotest-golang +pcode.gotest = true diff --git a/lua/plugins/dap_go.lua b/lua/plugins/dap_go.lua new file mode 100644 index 0000000..58bd1a9 --- /dev/null +++ b/lua/plugins/dap_go.lua @@ -0,0 +1,56 @@ +local M = {} +if pcode.nvim_dap_go then + M = { + { + "rcarriga/nvim-dap-ui", + lazy = true, + event = "BufRead", + dependencies = { + { "mfussenegger/nvim-dap", lazy = true }, + { "nvim-neotest/nvim-nio", lazy = true }, + { + "theHamsta/nvim-dap-virtual-text", + opts = { + virt_text_win_col = 80, + }, + }, + }, + config = function() + require("user.dapui") + end, + keys = { + { "d", "", desc = "  Debug" }, + { "dt", "lua require'dap'.toggle_breakpoint()", desc = "Toggle Breakpoint" }, + { "db", "lua require'dap'.step_back()", desc = "Step Back" }, + { "dc", "lua require'dap'.continue()", desc = "Continue" }, + { "dC", "lua require'dap'.run_to_cursor()", desc = "Run To Cursor" }, + { "dd", "lua require'dap'.disconnect()", desc = "Disconnect" }, + { "dg", "lua require'dap'.session()", desc = "Get Session" }, + { "di", "lua require'dap'.step_into()", desc = "Step Into" }, + { "do", "lua require'dap'.step_over()", desc = "Step Over" }, + { "du", "lua require'dap'.step_out()", desc = "Step Out" }, + { "dp", "lua require'dap'.pause()", desc = "Pause" }, + { "dr", "lua require'dap'.repl.toggle()", desc = "Toggle Repl" }, + { "ds", "lua require'dap'.continue()", desc = "Start" }, + { "dq", "lua require'dap'.close()", desc = "Quit" }, + { "dU", "lua require'dapui'.toggle({reset = true})", desc = "Toggle UI" }, + }, + }, + { + "jay-babu/mason-nvim-dap.nvim", + lazy = true, + event = "BufRead", + dependencies = { "williamboman/mason.nvim", "mfussenegger/nvim-dap" }, + config = function() + require("mason-nvim-dap").setup({ + automatic_installation = true, + automatic_setup = true, + handlers = {}, + ensure_installed = { "delve" }, + }) + end, + }, + } +end + +return M diff --git a/lua/plugins/test_go.lua b/lua/plugins/test_go.lua new file mode 100644 index 0000000..b183c79 --- /dev/null +++ b/lua/plugins/test_go.lua @@ -0,0 +1,129 @@ +-- 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 diff --git a/lua/plugins/test_py.lua b/lua/plugins/test_py.lua index 14d71bd..03bafe4 100644 --- a/lua/plugins/test_py.lua +++ b/lua/plugins/test_py.lua @@ -24,18 +24,18 @@ if pcode.pytest then }, }) end, - -- stylua: ignore - keys = { - { "T","",desc="  Test"}, - { "Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, - { "Tr", function() require("neotest").run.run() end, desc = "Run Nearest" }, - { "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" }, - }, + -- stylua: ignore + keys = { + { "T","",desc="  Test"}, + { "Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, + { "Tr", function() require("neotest").run.run() end, desc = "Run Nearest" }, + { "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" }, + }, } end