diff --git a/nvimrc b/nvimrc index 7a9e5ff..30c9bdb 100644 --- a/nvimrc +++ b/nvimrc @@ -276,6 +276,13 @@ packadd! vim-rhubarb " https://github.com/tpope/vim-rhubarb.git packadd! editorconfig-vim " https://github.com/editorconfig/editorconfig-vim.git packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git +" nvim-dap +packadd! nvim-dap " https://github.com/mfussenegger/nvim-dap.git +packadd! nvim-dap-go " https://github.com/leoluz/nvim-dap-go.git +packadd! nvim-dap-ruby " https://github.com/suketa/nvim-dap-ruby.git + +lua require "debugger" + " formatter.nvim: packadd! formatter.nvim " https://github.com/mhartington/formatter.nvim.git diff --git a/vim/lua/debugger.lua b/vim/lua/debugger.lua new file mode 100644 index 0000000..319fd0e --- /dev/null +++ b/vim/lua/debugger.lua @@ -0,0 +1,112 @@ +-- require("dap").set_log_level("DEBUG") + +-- go install github.com/go-delve/delve/cmd/dlv@latest +require("dap-go").setup({}) +require("dap-ruby").setup() + +local prefix = "D" + +local configs = { + { + "Continue", + "dc", + function() + require("dap").continue() + end, + }, + { + "Next", + "dn", + function() + require("dap").step_over() + end, + }, + { + "StepInto", + "di", + function() + require("dap").step_into() + end, + }, + { + "StepOut", + "du", + function() + require("dap").step_out() + end, + }, + { + "ToggleBreakpoint", + "dt", + function() + require("dap").toggle_breakpoint() + end, + }, + { + "Breakpoint", + "db", + function() + require("dap").set_breakpoint() + end, + }, + { + "Logpoint", + "dl", + function() + require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) + end, + }, + { + "Repl", + "dr", + function() + require("dap").repl.open() + end, + }, + { + "RunLast", + "dl", + function() + require("dap").run_last() + end, + }, + { + "WidgetsHover", + "dh", + function() + require("dap.ui.widgets").hover() + end, + }, + { + "WidgetsPreview", + "dp", + function() + require("dap.ui.widgets").preview() + end, + }, + { + "Frames", + "df", + function() + local widgets = require("dap.ui.widgets") + widgets.centered_float(widgets.frames) + end, + }, + { + "Scopes", + "ds", + function() + local widgets = require("dap.ui.widgets") + widgets.centered_float(widgets.scopes) + end, + }, +} + +for _, v in pairs(configs) do + local name = v[1] + local keymap = v[2] + local fn = v[3] + + vim.api.nvim_create_user_command(prefix .. name, fn, {}) + vim.keymap.set("n", keymap, fn) +end