From 8604e18578123f819a96d09ade9111f563d4b1e0 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Fri, 7 Mar 2025 12:56:00 +1030 Subject: [PATCH] fix: revert oil keymap --- .config/nvim/lua/core/remaps.lua | 4 - .config/nvim/lua/plugins/fugitive.lua | 104 ++++++++++++++------------ .config/nvim/lua/plugins/oil.lua | 2 +- 3 files changed, 58 insertions(+), 52 deletions(-) diff --git a/.config/nvim/lua/core/remaps.lua b/.config/nvim/lua/core/remaps.lua index 95afadf..1145622 100644 --- a/.config/nvim/lua/core/remaps.lua +++ b/.config/nvim/lua/core/remaps.lua @@ -43,10 +43,6 @@ vim.keymap.set("n", "N", "Nzzzv", { desc = "Previous search result" }) vim.keymap.set("n", "N", "cprevzz", { desc = "Previous item in quickfix list" }) vim.keymap.set("n", "n", "cnextzz", { desc = "Next item in quickfix list" }) --- Increment/decrement -vim.keymap.set("n", "+", "") -vim.keymap.set("n", "-", "") - -- Resize window vim.keymap.set("n", "", "5<") vim.keymap.set("n", "", "5>") diff --git a/.config/nvim/lua/plugins/fugitive.lua b/.config/nvim/lua/plugins/fugitive.lua index 539e9c4..182e9c3 100644 --- a/.config/nvim/lua/plugins/fugitive.lua +++ b/.config/nvim/lua/plugins/fugitive.lua @@ -1,49 +1,59 @@ return { - "tpope/vim-fugitive", - event = "VeryLazy", - dependencies = { - "shumphrey/fugitive-gitlab.vim", - }, - config = function() - vim.opt.diffopt = vim.opt.diffopt + "vertical" - vim.opt.display = vim.opt.display + "lastline" - - local fugitive_augroup = vim.api.nvim_create_augroup("fugitive_mappings", { clear = true }) - - local function set_fugitive_mappings() - local opts = { noremap = true, silent = true } - - vim.api.nvim_buf_set_keymap(0, "n", "gp", "Git push", opts) - vim.api.nvim_buf_set_keymap(0, "n", "gP", "Git pull", opts) - vim.api.nvim_buf_set_keymap(0, "n", "gc", "Git commit", opts) - end - - -- Create an autocmd to trigger the function when entering a Fugitive buffer - vim.api.nvim_create_autocmd("FileType", { - group = fugitive_augroup, - pattern = "fugitive", - callback = set_fugitive_mappings, - }) - - local opts = { noremap = true, silent = true } - - vim.keymap.set("n", "gg", function () - vim.cmd("Git") - end, opts) - - vim.keymap.set("v", "gl", function() - local startPos = vim.fn.getpos("v") - local endPos = vim.fn.getpos(".") - - local startLine = math.min(startPos[2], endPos[2]) - local endLine = math.max(startPos[2], endPos[2]) - - if startLine == 0 or endLine == 0 then - vim.notify(vim.inspect(vim.fn.getpos("'<")) .. " to " .. vim.inspect(vim.fn.getpos("'>"))) - return - end - - vim.cmd(string.format("Git log -L %d,%d:%s", startLine, endLine, vim.fn.expand("%:."))) - end, opts) - end, + { + "tpope/vim-fugitive", + event = "VeryLazy", + dependencies = { + "shumphrey/fugitive-gitlab.vim", + }, + config = function() + vim.opt.diffopt = vim.opt.diffopt + "vertical" + vim.opt.display = vim.opt.display + "lastline" + + local fugitive_augroup = vim.api.nvim_create_augroup("fugitive_mappings", { clear = true }) + + local function set_fugitive_mappings() + local opts = { noremap = true, silent = true } + + vim.api.nvim_buf_set_keymap(0, "n", "gp", "Git push", opts) + vim.api.nvim_buf_set_keymap(0, "n", "gP", "Git pull", opts) + vim.api.nvim_buf_set_keymap(0, "n", "gc", "Git commit", opts) + end + + -- Create an autocmd to trigger the function when entering a Fugitive buffer + vim.api.nvim_create_autocmd("FileType", { + group = fugitive_augroup, + pattern = "fugitive", + callback = set_fugitive_mappings, + }) + + local opts = { noremap = true, silent = true } + + vim.keymap.set("n", "gg", function () + vim.cmd("Git") + end, opts) + + vim.keymap.set("v", "gl", function() + local startPos = vim.fn.getpos("v") + local endPos = vim.fn.getpos(".") + + local startLine = math.min(startPos[2], endPos[2]) + local endLine = math.max(startPos[2], endPos[2]) + + if startLine == 0 or endLine == 0 then + vim.notify(vim.inspect(vim.fn.getpos("'<")) .. " to " .. vim.inspect(vim.fn.getpos("'>"))) + return + end + + vim.cmd(string.format("Git log -L %d,%d:%s", startLine, endLine, vim.fn.expand("%:."))) + end, opts) + end, + }, + { + "rbong/vim-flog", + lazy = true, + cmd = { "Flog", "Flogsplit", "Floggit" }, + dependencies = { + "tpope/vim-fugitive", + }, + }, } diff --git a/.config/nvim/lua/plugins/oil.lua b/.config/nvim/lua/plugins/oil.lua index 32afdff..130cc82 100644 --- a/.config/nvim/lua/plugins/oil.lua +++ b/.config/nvim/lua/plugins/oil.lua @@ -82,7 +82,7 @@ return { }, }) - vim.keymap.set("n", "_", function() + vim.keymap.set("n", "-", function() vim.cmd("Oil") end, { desc = "Open parent directory" }) end,