Use <amatch> in detection autocommands

This commit is contained in:
Tim Pope 2018-07-28 19:41:00 -04:00
parent 4643363b08
commit da066426fd

View File

@ -66,6 +66,10 @@ function! FugitiveExtractGitDir(path) abort
else else
let path = fnamemodify(path, ':p:h:s?/$??') let path = fnamemodify(path, ':p:h:s?/$??')
endif endif
let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '')
if len(pre) && exists('*' . pre . 'Real')
let path = s:shellslash({pre}Real(path))
endif
let root = resolve(path) let root = resolve(path)
if root !=# path if root !=# path
silent! exe haslocaldir() ? 'lcd .' : 'cd .' silent! exe haslocaldir() ? 'lcd .' : 'cd .'
@ -179,8 +183,8 @@ endfunction
augroup fugitive augroup fugitive
autocmd! autocmd!
autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('%:p')) autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('<amatch>:p'))
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', @%), ':p')) autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('<amatch>')), ':p'))
autocmd User NERDTreeInit,NERDTreeNewRoot autocmd User NERDTreeInit,NERDTreeNewRoot
\ if exists('b:NERDTree.root.path.str') | \ if exists('b:NERDTree.root.path.str') |
\ call FugitiveDetect(b:NERDTree.root.path.str()) | \ call FugitiveDetect(b:NERDTree.root.path.str()) |