diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 8d8d55a..efcbe00 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -56,8 +56,25 @@ M.general = { -- [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, - ["y"] = {" :w! /tmp/vimtmp", "Save into a global tmp file"}, - ["p"] = {" :r! cat /tmp/vimtmp", "Restore from the global tmp file"}, + -- ["y"] = {" :w! /tmp/vimtmp", "Save into a global tmp file"}, + -- ["p"] = {" :r! cat /tmp/vimtmp", "Restore from the global tmp file"}, + + ["dgg"] = {":lua require('dap').continue() ", "Continue debu[g]ging"}, + ["dg"] = {":lua require('dapui').toggle() ", "Toggle DAP ui"}, + ["dgw"] = {":lua require('dapui').eval() ", "Open floating windows about current [w]ord"}, + ["dgb"] = {":lua require('dap').toggle_breakpoint() ", "Toggle [b]reakpoint"}, + ["dgf"] = {":lua require('dap-python').test_method() ", "Debug [f]unction"}, + ["dgo"] = {":lua require('dap').step_over() ", "DAP step [o]ver method"}, + ["dgt"] = {":lua require('dap').step_into() ", "DAP step in[t]o method"}, + ["dgp"] = {":lua require('dap').step_back() ", "DAP step back ([p]revious)"}, + ["dgs"] = { + function() + local widgets = require("dap.ui.widgets") + local sidebar = widgets.sidebar(widgets.scopes) + sidebar.open({widgth = '50%'}) + end, + "DAP Show debugged [s]copes", + }, -- new buffer -- ["b"] = { " enew ", "New buffer" }, @@ -80,6 +97,9 @@ M.general = { -- [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, ["<"] = { ""] = { ">gv", "Indent line" }, + + ["dgd"] = {":lua require('dap-python').debug_selection()", "DAP debug selection"}, + ["dgw"] = {":lua require('dap-python').eval()", "DAP eval selection"}, }, x = { @@ -437,6 +457,7 @@ M.telescope = { ["wl"] = { " Telescope workspaces ", "Find workspaces" }, + ["gm"] = { " lua require('custom.telescope').cpickers()", "Commonly used commands" }, -- git --- Commits ["gc"] = { " lua require('custom.telescope').my_git_commits()", "Custom Git commits" }, @@ -641,4 +662,16 @@ M.gitsigns = { }, } +local all_modes = { + -- Override all delete/yank/paste to use the registers M by default + ["y"] = { "\"my", "Yank", { remap=false } }, + ["p"] = { "\"mp", "Paste", { remap=false } }, + ["d"] = { "\"md", "Delete", { remap=false } }, + + ["y"] = { "\"+y", "Yank into system register", { remap=false } }, + ["p"] = { "\"+p", "Paste from system register", { remap=false } }, +} + +M.general[{"n", "v"}] = all_modes + return M diff --git a/lua/custom/commands.lua b/lua/custom/commands.lua new file mode 100644 index 0000000..7b96f53 --- /dev/null +++ b/lua/custom/commands.lua @@ -0,0 +1,5 @@ +local C = { + { "Replace {{X}} with {{ X }} in jinja template", "%s/{{\\(.[^ ]*\\)}}/{{ \\1 }}/g" }, +} + +return C diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua index 4005ac2..6233891 100644 --- a/lua/custom/telescope.lua +++ b/lua/custom/telescope.lua @@ -2,6 +2,11 @@ local previewers = require('telescope.previewers') local builtin = require('telescope.builtin') +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local actions = require("telescope.actions") +local action_state = require("telescope.actions.state") +local conf = require("telescope.config").values local E = {} @@ -59,4 +64,44 @@ E.project_files = function() end end +local custom_commands = require("custom.commands") + +E.cpickers = function(opts) + opts = opts or {} + pickers.new(opts, { + prompt_title = "Commands", + + finder = finders.new_table { + results = custom_commands, + entry_maker = function(entry) + return { + value = entry, + display = entry[1], + ordinal = entry[2], + } + end + }, + + previewer = previewers.new_buffer_previewer { + title = "Custom commands preview", + define_preview = function (self, entry, _) + vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, { + entry['ordinal'], + }) + end + }, + + attach_mappings = function(prompt_bufnr, _) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + vim.cmd(selection.ordinal) + end) + return true + end, + + sorter = conf.generic_sorter(opts), + }):find() +end + return E diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 73bcb33..4204da6 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -20,6 +20,46 @@ local default_plugins = { {"preservim/tagbar", lazy=false}, {"ludovicchabant/vim-gutentags", lazy=false}, {"emaniacs/vim-rest-console", lazy=false}, + {"git@github.com:mfussenegger/nvim-dap.git", lazy=false}, + { + "git@github.com:rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio" + }, + lazy=false, + }, + { + "git@github.com:mfussenegger/nvim-dap-python.git", + dependencies = { + "mfussenegger/nvim-dap", + "rcarriga/nvim-dap-ui", + }, + lazy=false, + init = function() + require("dap-python").setup("python") + -- Setup nvim-dap-ui also + require("dapui").setup() + end, + config = function(_, opts) + local dap = require('dap') + vim.api.nvim_set_hl(0, "dark-orange", { bg="#402c16"}) + vim.fn.sign_define('DapBreakpoint', {text='🛑', texthl='', linehl='', numhl=''}) + vim.fn.sign_define('DapStopped', {text='', texthl='', linehl='dark-orange', numhl=''}) + dap.defaults.fallback.terminal_win_cmd = 'tabnew' + dap.defaults.fallback.focus_terminal = true + end, + }, + { + "Weissle/persistent-breakpoints.nvim", + lazy=false, + config = function(_, opts) + require('persistent-breakpoints').setup{ + load_breakpoints_event = { "BufReadPost" } + } + end, + }, + {"nvim-telescope/telescope-dap.nvim", lazy=false}, {"harrisoncramer/gitlab.nvim", dependencies = { "MunifTanjim/nui.nvim",