From 3304c14c639ca314f2e1d0c6b9fc275f2473e72a Mon Sep 17 00:00:00 2001 From: David Briscoe Date: Wed, 30 Jan 2019 21:07:48 -0800 Subject: [PATCH] Move filetype to after maps to allow user maps The easiest way for users to define their own maps in Gstatus buffers is using a ftplugin/fugitive.vim file with a `b:fugitive_type != 'index'` guard. Setting the filetype after defining the maps allows users to maniuplate "dangerous" maps and otherwise customize mappings. For example, in ~/.vim/after/ftplugin/fugitive.vim: if !exists('g:loaded_fugitive') || b:fugitive_type != 'index' finish endif " Use s to stage *and* unstage changes: shadows -. nmap s - xmap s - " I hit this by accident. nunmap X --- autoload/fugitive.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0b67db9..ecde485 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1521,7 +1521,6 @@ function! fugitive#BufReadStatus() abort set nomodified readonly noswapfile silent doautocmd BufReadPost - set filetype=fugitive setlocal nomodifiable if &bufhidden ==# '' setlocal bufhidden=delete @@ -1574,6 +1573,7 @@ function! fugitive#BufReadStatus() abort nnoremap q :bdelete nnoremap g? :help fugitive-:Gstatus nnoremap :help fugitive-:Gstatus + set filetype=fugitive for [lnum, section] in [[staged_end, 'Staged'], [unstaged_end, 'Unstaged']] while len(getline(lnum))