From 4e2abc80df65fd18d0ec782a8fa31bc8793f3982 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sat, 29 May 2021 13:10:26 +0530 Subject: [PATCH] nvim: after/ftplugin: gitrebase: Add vim-interactive-rebase-reverse The plugin is a pretty small ftplugin. Just add it to our ftplugin. This also fixes the issue where this plugin did not take affect when using interactive rebase from within fugitive. --- .../.config/nvim/after/ftplugin/gitrebase.vim | 21 +++++++++++++++++++ nvim/.config/nvim/lua/plugins.lua | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/after/ftplugin/gitrebase.vim b/nvim/.config/nvim/after/ftplugin/gitrebase.vim index d58b4ad..1934cec 100644 --- a/nvim/.config/nvim/after/ftplugin/gitrebase.vim +++ b/nvim/.config/nvim/after/ftplugin/gitrebase.vim @@ -1,3 +1,24 @@ +" Taken from https://github.com/salcode/vim-interactive-rebase-reverse +" Reverse the order of all lines that do NOT: +" - Begin with # +" - nor are a blank link +function! s:Reverse() + global!/\(^#\)\|\(^$\)/m0 +endfunction + +" Reverse the order of all commits in the git interactive rebase screen, +" when this filetype (gitrebase) is loaded. +call s:Reverse() + +" Set an autocmd to run when the Buffer is written +augroup fe_interactive_rebase_reverse + autocmd! + " Before saving (un)reverse the order of all commits. + autocmd BufWritePre call s:Reverse() + " After saving reverse the order of the commits again. + autocmd BufWritePost call s:Reverse() +augroup END + " See https://github.com/neovim/neovim/blob/master/runtime/ftplugin/gitrebase.vim nmap p :Pick nmap s :Squash diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index ae03a45..ee3f266 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -43,7 +43,6 @@ local init = function () } use 'tpope/vim-fugitive' use 'rhysd/git-messenger.vim' - use 'salcode/vim-interactive-rebase-reverse' use 'whiteinge/diffconflicts' use 'sindrets/diffview.nvim' -- Boost vim command line mode