1" Vim filetype plugin 2" Language: generic git output 3" Maintainer: Tim Pope <[email protected]> 4" Last Change: 2019 Dec 05 5 6" Only do this when not done yet for this buffer 7if (exists("b:did_ftplugin")) 8 finish 9endif 10let b:did_ftplugin = 1 11 12if !exists('b:git_dir') 13 if expand('%:p') =~# '[\/]\.git[\/]modules[\/]\|:[\/][\/]\|^\a\a\+:' 14 " Stay out of the way 15 elseif expand('%:p') =~# '[\/]\.git[\/]worktrees' 16 let b:git_dir = matchstr(expand('%:p'),'.*\.git[\/]worktrees[\/][^\/]\+\>') 17 elseif expand('%:p') =~# '\.git\>' 18 let b:git_dir = matchstr(expand('%:p'),'.*\.git\>') 19 elseif $GIT_DIR != '' 20 let b:git_dir = $GIT_DIR 21 endif 22 if (has('win32') || has('win64')) && exists('b:git_dir') 23 let b:git_dir = substitute(b:git_dir,'\\','/','g') 24 endif 25endif 26 27if exists('*shellescape') && exists('b:git_dir') && b:git_dir != '' 28 if b:git_dir =~# '/\.git$' " Not a bare repository 29 let &l:path = escape(fnamemodify(b:git_dir,':h'),'\, ').','.&l:path 30 endif 31 let &l:path = escape(b:git_dir,'\, ').','.&l:path 32 let &l:keywordprg = 'git --git-dir='.shellescape(b:git_dir).' show' 33else 34 setlocal keywordprg=git\ show 35endif 36if has('gui_running') 37 let &l:keywordprg = substitute(&l:keywordprg,'^git\>','git --no-pager','') 38endif 39 40setlocal includeexpr=substitute(v:fname,'^[^/]\\+/','','') 41let b:undo_ftplugin = "setl keywordprg< path< includeexpr<" 42