diff --git a/lazy-lock.json b/lazy-lock.json index ee7cdcb..f5652fc 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -23,11 +23,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-phpunit": { "branch": "main", "commit": "baae8dfa0a3aaacd9f0bb6845d6348f5bcdc48bb" }, + "neotest-golang": { "branch": "main", "commit": "7d0c75265cbd4567f4a41795c263913c354c7a91" }, + "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": "f1b438ab1709cf9d8875843559d20265013ac755" }, @@ -36,7 +39,9 @@ "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, "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" }, @@ -61,7 +66,6 @@ "vim-startuptime": { "branch": "master", "commit": "97a88e688482a09c3c4b777d07b509b328a5ec29" }, "vim-visual-multi": { "branch": "master", "commit": "b84a6d42c1c10678928b0bf8327f378c8bc8af5a" }, "virt-column.nvim": { "branch": "master", "commit": "b62b4ef0774d19452d4ed18e473e824c7a756f2f" }, - "vscode-php-debug": { "branch": "main", "commit": "3025d1f01b5b7725e7c1c213d63f3de45f0534b3" }, "which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" }, "yanky.nvim": { "branch": "main", "commit": "9268018e92d02650a94e39dd5f5903c542f7ea11" } } \ No newline at end of file diff --git a/lua/custom/default.lua b/lua/custom/default.lua index 2dd1d11..fbc341d 100644 --- a/lua/custom/default.lua +++ b/lua/custom/default.lua @@ -149,13 +149,10 @@ pcode.rest_client = true -- https://github.com/mfussenegger/nvim-dap pcode.nvim_dap = false -- not support for windows os (auto config mason-nvim-dap) pcode.nvim_dap_python = false -pcode.nvim_dap_go = false -- https://github.com/nvim-neotest/neotest-python -- https://docs.pytest.org/en/7.1.x/getting-started.html pcode.pytest = false --- https://github.com/fredrikaverpil/neotest-golang -pcode.gotest = false pcode.active_rust_config = false pcode.active_javascript_config = { @@ -163,4 +160,5 @@ pcode.active_javascript_config = { jest_command = "npm test -- ", jest_config = "jest.config.mjs", } -pcode.active_php_config = true +pcode.active_php_config = false +pcode.active_golang_config = true diff --git a/lua/plugins/dap_go.lua b/lua/plugins/dap_go.lua deleted file mode 100644 index 58bd1a9..0000000 --- a/lua/plugins/dap_go.lua +++ /dev/null @@ -1,56 +0,0 @@ -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/gocfg.lua b/lua/plugins/gocfg.lua new file mode 100644 index 0000000..245f4ac --- /dev/null +++ b/lua/plugins/gocfg.lua @@ -0,0 +1,140 @@ +-- rujukan +-- https://github.com/fredrikaverpil/neotest-golang +local M = {} +if pcode.active_golang_config 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" }, + }, + }, + { + "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 deleted file mode 100644 index b183c79..0000000 --- a/lua/plugins/test_go.lua +++ /dev/null @@ -1,129 +0,0 @@ --- 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/themes/_globalvar.lua b/lua/plugins/themes/_globalvar.lua index ebefa7e..7b47687 100644 --- a/lua/plugins/themes/_globalvar.lua +++ b/lua/plugins/themes/_globalvar.lua @@ -40,7 +40,9 @@ if pcode.active_javascript_config.status then for _, ts in pairs(lst_ts) do table.insert(pcode.treesitter_ensure_installed, ts) end - table.insert(pcode.mason_ensure_installed, "tsserver") + for _, lsp in pairs({ "html", "cssls", "emmet_ls", "eslint", "jsonls", "tsserver" }) do + table.insert(pcode.mason_ensure_installed, lsp) + end end -- run if php config true if pcode.active_php_config then @@ -52,4 +54,14 @@ if pcode.active_php_config then table.insert(pcode.null_ls_ensure_installed, "phpcbf") table.insert(pcode.null_ls_ensure_installed, "phpcs") end +-- run if golang config true +if pcode.active_golang_config then + local lst_ts = { "go", "gomod", "gosum", "gotmpl", "gowork" } + for _, ts in pairs(lst_ts) do + table.insert(pcode.treesitter_ensure_installed, ts) + end + table.insert(pcode.mason_ensure_installed, "gopls") + table.insert(pcode.null_ls_ensure_installed, "ast_grep") + table.insert(pcode.null_ls_ensure_installed, "gofumpt") +end return {}