mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-22 08:53:31 +02:00
enc:add config dap golang & test golang
This commit is contained in:
parent
bb58e61e35
commit
f2cd687048
5 changed files with 209 additions and 15 deletions
|
@ -22,11 +22,14 @@
|
||||||
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
|
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" },
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" },
|
||||||
"mason-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" },
|
"mason-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" },
|
||||||
|
"mason-nvim-dap.nvim": { "branch": "main", "commit": "f5425eb1d0d794f0305d5eeebddabb74614683ff" },
|
||||||
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
|
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
|
||||||
"mini.indentscope": { "branch": "main", "commit": "f0d7faa064c892b96997810afcddfadc3f2a15b3" },
|
"mini.indentscope": { "branch": "main", "commit": "f0d7faa064c892b96997810afcddfadc3f2a15b3" },
|
||||||
"neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" },
|
"neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" },
|
||||||
"neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" },
|
"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" },
|
"noice.nvim": { "branch": "main", "commit": "8f1d9966762e62fa8788e5fb1a5f6a86784221d9" },
|
||||||
"none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" },
|
"none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" },
|
||||||
"none-ls.nvim": { "branch": "main", "commit": "cc0a3c45047e3daf85d07c1571d65476cfce6480" },
|
"none-ls.nvim": { "branch": "main", "commit": "cc0a3c45047e3daf85d07c1571d65476cfce6480" },
|
||||||
|
@ -34,7 +37,10 @@
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
|
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
|
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
|
||||||
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
|
"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-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" },
|
||||||
"nvim-material-icon": { "branch": "main", "commit": "2f1d6333bbec2e787774193c9fc7b447b878069a" },
|
"nvim-material-icon": { "branch": "main", "commit": "2f1d6333bbec2e787774193c9fc7b447b878069a" },
|
||||||
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
|
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
|
||||||
|
|
|
@ -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_javascript = false
|
||||||
pcode.nvim_dap_php = false
|
pcode.nvim_dap_php = false
|
||||||
pcode.nvim_dap_python = false
|
pcode.nvim_dap_python = false
|
||||||
|
pcode.nvim_dap_go = true
|
||||||
|
|
||||||
-- https://github.com/olimorris/neotest-phpunit
|
-- https://github.com/olimorris/neotest-phpunit
|
||||||
pcode.phpunit = false
|
pcode.phpunit = false
|
||||||
-- https://github.com/nvim-neotest/neotest-python
|
-- https://github.com/nvim-neotest/neotest-python
|
||||||
-- https://docs.pytest.org/en/7.1.x/getting-started.html
|
-- https://docs.pytest.org/en/7.1.x/getting-started.html
|
||||||
pcode.pytest = true
|
pcode.pytest = false
|
||||||
-- https://github.com/nvim-neotest/neotest-jest
|
-- https://github.com/nvim-neotest/neotest-jest
|
||||||
pcode.jest = false
|
pcode.jest = false
|
||||||
pcode.jest_command = "npm test -- "
|
pcode.jest_command = "npm test -- "
|
||||||
pcode.jest_config = "jest.config.mjs"
|
pcode.jest_config = "jest.config.mjs"
|
||||||
|
-- https://github.com/fredrikaverpil/neotest-golang
|
||||||
|
pcode.gotest = true
|
||||||
|
|
56
lua/plugins/dap_go.lua
Normal file
56
lua/plugins/dap_go.lua
Normal file
|
@ -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 = {
|
||||||
|
{ "<leader>d", "", desc = " Debug" },
|
||||||
|
{ "<leader>dt", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", desc = "Toggle Breakpoint" },
|
||||||
|
{ "<leader>db", "<cmd>lua require'dap'.step_back()<cr>", desc = "Step Back" },
|
||||||
|
{ "<leader>dc", "<cmd>lua require'dap'.continue()<cr>", desc = "Continue" },
|
||||||
|
{ "<leader>dC", "<cmd>lua require'dap'.run_to_cursor()<cr>", desc = "Run To Cursor" },
|
||||||
|
{ "<leader>dd", "<cmd>lua require'dap'.disconnect()<cr>", desc = "Disconnect" },
|
||||||
|
{ "<leader>dg", "<cmd>lua require'dap'.session()<cr>", desc = "Get Session" },
|
||||||
|
{ "<leader>di", "<cmd>lua require'dap'.step_into()<cr>", desc = "Step Into" },
|
||||||
|
{ "<leader>do", "<cmd>lua require'dap'.step_over()<cr>", desc = "Step Over" },
|
||||||
|
{ "<leader>du", "<cmd>lua require'dap'.step_out()<cr>", desc = "Step Out" },
|
||||||
|
{ "<leader>dp", "<cmd>lua require'dap'.pause()<cr>", desc = "Pause" },
|
||||||
|
{ "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>", desc = "Toggle Repl" },
|
||||||
|
{ "<leader>ds", "<cmd>lua require'dap'.continue()<cr>", desc = "Start" },
|
||||||
|
{ "<leader>dq", "<cmd>lua require'dap'.close()<cr>", desc = "Quit" },
|
||||||
|
{ "<leader>dU", "<cmd>lua require'dapui'.toggle({reset = true})<cr>", 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
|
129
lua/plugins/test_go.lua
Normal file
129
lua/plugins/test_go.lua
Normal file
|
@ -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 = {
|
||||||
|
-- { "<leader>T","",desc=" Test"},
|
||||||
|
-- { "<leader>Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
|
||||||
|
-- { "<leader>TT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
|
||||||
|
-- { "<leader>Tl", function() require("neotest").run.run_last() end, desc = "Run Last" },
|
||||||
|
-- { "<Leader>Ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
|
||||||
|
-- { "<leader>To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
|
||||||
|
-- { "<Leader>TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
|
||||||
|
-- { "<Leader>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 = {
|
||||||
|
{ "<leader>T","",desc=" Test"},
|
||||||
|
{ "<leader>Ta", function() require("neotest").run.attach() end, desc = "[t]est [a]ttach" },
|
||||||
|
{ "<leader>Tf", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "[t]est run [f]ile" },
|
||||||
|
{ "<leader>TA", function() require("neotest").run.run(vim.uv.cwd()) end, desc = "[t]est [A]ll files" },
|
||||||
|
{ "<leader>TS", function() require("neotest").run.run({ suite = true }) end, desc = "[t]est [S]uite" },
|
||||||
|
{ "<leader>Tn", function() require("neotest").run.run() end, desc = "[t]est [n]earest" },
|
||||||
|
{ "<leader>Tl", function() require("neotest").run.run_last() end, desc = "[t]est [l]ast" },
|
||||||
|
{ "<leader>Ts", function() require("neotest").summary.toggle() end, desc = "[t]est [s]ummary" },
|
||||||
|
{ "<leader>To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "[t]est [o]utput" },
|
||||||
|
{ "<leader>TO", function() require("neotest").output_panel.toggle() end, desc = "[t]est [O]utput panel" },
|
||||||
|
{ "<leader>Tt", function() require("neotest").run.stop() end, desc = "[t]est [t]erminate" },
|
||||||
|
{ "<leader>Td", function() require("neotest").run.run({ suite = false, strategy = "dap" }) end, desc = "Debug nearest test" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
Add table
Add a link
Reference in a new issue