blob: 63d4f338ed31d20c62953fa09e1fa511df09a959 [file] [log] [blame]
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00001" Vim filetype plugin
2" Language: generic git output
Bram Moolenaar5c736222010-01-06 20:54:52 +01003" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4" Last Change: 2009 Dec 24
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00005
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\>'
14 let b:git_dir = matchstr(expand('%:p'),'.*\.git\>')
15 elseif $GIT_DIR != ''
16 let b:git_dir = $GIT_DIR
17 endif
Bram Moolenaarc236c162008-07-13 17:41:49 +000018 if (has('win32') || has('win64')) && exists('b:git_dir')
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000019 let b:git_dir = substitute(b:git_dir,'\\','/','g')
20 endif
21endif
22
23if exists('*shellescape') && exists('b:git_dir') && b:git_dir != ''
24 if b:git_dir =~# '/\.git$' " Not a bare repository
Bram Moolenaare37d50a2008-08-06 17:06:04 +000025 let &l:path = escape(fnamemodify(b:git_dir,':h'),'\, ').','.&l:path
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000026 endif
27 let &l:path = escape(b:git_dir,'\, ').','.&l:path
28 let &l:keywordprg = 'git --git-dir='.shellescape(b:git_dir).' show'
29else
30 setlocal keywordprg=git\ show
31endif
Bram Moolenaar5c736222010-01-06 20:54:52 +010032if has('gui_running')
33 let &l:keywordprg = substitute(&l:keywordprg,'^git\>','git --no-pager','')
34endif
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000035
36setlocal includeexpr=substitute(v:fname,'^[^/]\\+/','','')
37let b:undo_ftplugin = "setl keywordprg< path< includeexpr<"