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 <buffer> <silent> s -
    xmap <buffer> <silent> s -

    " I hit this by accident.
    nunmap <buffer> X
This commit is contained in:
David Briscoe 2019-01-30 21:07:48 -08:00 committed by Tim Pope
parent d27dbc40d4
commit 3304c14c63

View File

@ -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 <buffer> <silent> q :<C-U>bdelete<CR>
nnoremap <buffer> <silent> g? :help fugitive-:Gstatus<CR>
nnoremap <buffer> <silent> <F1> :help fugitive-:Gstatus<CR>
set filetype=fugitive
for [lnum, section] in [[staged_end, 'Staged'], [unstaged_end, 'Unstaged']]
while len(getline(lnum))