diff options
Diffstat (limited to 'nvim/lua/plugins/dap.lua')
| -rw-r--r-- | nvim/lua/plugins/dap.lua | 115 |
1 files changed, 110 insertions, 5 deletions
diff --git a/nvim/lua/plugins/dap.lua b/nvim/lua/plugins/dap.lua index 0d104d9..58cc7f9 100644 --- a/nvim/lua/plugins/dap.lua +++ b/nvim/lua/plugins/dap.lua @@ -1,3 +1,103 @@ +local default_config = { + delve = { + path = "dlv", + initialize_timeout_sec = 20, + port = "${port}", + args = {}, + build_flags = "", + -- Automatically handle the issue on delve Windows versions < 1.24.0 + -- where delve needs to be run in attched mode or it will fail (actually crashes). + detached = vim.fn.has("win32") == 0, + output_mode = "remote", + }, + tests = { + verbose = false, + }, +} + +local function setup_go_configuration(dap, configs) + local common_debug_configs = { + { + type = "go", + name = "Debug", + request = "launch", + program = "${file}", + buildFlags = configs.delve.build_flags, + outputMode = configs.delve.output_mode, + }, + { + type = "go", + name = "Debug (Arguments)", + request = "launch", + program = "${file}", + args = get_arguments, + buildFlags = configs.delve.build_flags, + outputMode = configs.delve.output_mode, + }, + { + type = "go", + name = "Debug (Arguments & Build Flags)", + request = "launch", + program = "${file}", + args = get_arguments, + buildFlags = get_build_flags, + outputMode = configs.delve.output_mode, + }, + { + type = "go", + name = "Debug Package", + request = "launch", + program = "${fileDirname}", + buildFlags = configs.delve.build_flags, + outputMode = configs.delve.output_mode, + }, + { + type = "go", + name = "Attach", + mode = "local", + request = "attach", + processId = filtered_pick_process, + buildFlags = configs.delve.build_flags, + }, + { + type = "go", + name = "Debug test", + request = "launch", + mode = "test", + program = "${file}", + buildFlags = configs.delve.build_flags, + outputMode = configs.delve.output_mode, + }, + { + type = "go", + name = "Debug test (go.mod)", + request = "launch", + mode = "test", + program = "./${relativeFileDirname}", + buildFlags = configs.delve.build_flags, + outputMode = configs.delve.output_mode, + }, + } + + if dap.configurations.go == nil then + dap.configurations.go = {} + end + + for _, config in ipairs(common_debug_configs) do + table.insert(dap.configurations.go, config) + end + + if configs == nil or configs.dap_configurations == nil then + return + end + + for _, config in ipairs(configs.dap_configurations) do + if config.type == "go" then + table.insert(dap.configurations.go, config) + end + end +end + return { "leoluz/nvim-dap-go", dependencies = { "mfussenegger/nvim-dap" }, @@ -13,6 +113,10 @@ return { args = { "dap", "-l", "127.0.0.1:${port}" }, }, } + + setup_go_configuration(dap, default_config) + + dap.defaults.fallback.terminal_win_cmd = "enew | set filetype=dap-terminal" dap.listeners.before.attach.dapui_config = function() dapui.open() end @@ -25,29 +129,30 @@ return { dap.listeners.before.event_exited.dapui_config = function() dapui.close() end + vim.api.nvim_set_hl(0, "DapBreakpoint", { ctermbg = 0, fg = "#993939", bg = "#31353f" }) vim.api.nvim_set_hl(0, "DapLogPoint", { ctermbg = 0, fg = "#61afef", bg = "#31353f" }) vim.api.nvim_set_hl(0, "DapStopped", { ctermbg = 0, fg = "#98c379", bg = "#31353f" }) vim.fn.sign_define( "DapBreakpoint", - { text = "🐞", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } + { text = "!", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } ) vim.fn.sign_define( "DapBreakpointCondition", - { text = "ﳁ", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } + { text = "?", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } ) vim.fn.sign_define( "DapBreakpointRejected", - { text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } + { text = "RJ", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } ) vim.fn.sign_define( "DapLogPoint", - { text = "", texthl = "DapLogPoint", linehl = "DapLogPoint", numhl = "DapLogPoint" } + { text = "i", texthl = "DapLogPoint", linehl = "DapLogPoint", numhl = "DapLogPoint" } ) vim.fn.sign_define( "DapStopped", - { text = "", texthl = "DapStopped", linehl = "DapStopped", numhl = "DapStopped" } + { text = "→", texthl = "DapStopped", linehl = "DapStopped", numhl = "DapStopped" } ) end, keys = { |
