diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2013-09-12 17:33:47 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2013-09-12 17:33:47 +0200 | 
| commit | 3bd65161236bf5344619861fbe18b30f5bfd1a23 (patch) | |
| tree | 7ecdb8efb1f3ef4a290d82e4000d2ff52943308e /ftplugin | |
| parent | 5bc380150aee647d26a5a538ed855e9e82dcc7f7 (diff) | |
| download | vim-polyglot-3bd65161236bf5344619861fbe18b30f5bfd1a23.tar.gz vim-polyglot-3bd65161236bf5344619861fbe18b30f5bfd1a23.zip | |
Add git support by tpope-git
Diffstat (limited to '')
| -rw-r--r-- | ftplugin/git.vim | 38 | ||||
| -rw-r--r-- | ftplugin/gitcommit.vim | 67 | ||||
| -rw-r--r-- | ftplugin/gitconfig.vim | 15 | ||||
| -rw-r--r-- | ftplugin/gitrebase.vim | 43 | ||||
| -rw-r--r-- | ftplugin/gitsendemail.vim | 6 | 
5 files changed, 169 insertions, 0 deletions
| diff --git a/ftplugin/git.vim b/ftplugin/git.vim new file mode 100644 index 00000000..c9bcd436 --- /dev/null +++ b/ftplugin/git.vim @@ -0,0 +1,38 @@ +" Vim filetype plugin +" Language:	generic git output +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) +  finish +endif +let b:did_ftplugin = 1 + +if !exists('b:git_dir') +  if expand('%:p') =~# '[\/]\.git[\/]modules[\/]' +    " Stay out of the way +  elseif expand('%:p') =~# '\.git\>' +    let b:git_dir = matchstr(expand('%:p'),'.*\.git\>') +  elseif $GIT_DIR != '' +    let b:git_dir = $GIT_DIR +  endif +  if (has('win32') || has('win64')) && exists('b:git_dir') +    let b:git_dir = substitute(b:git_dir,'\\','/','g') +  endif +endif + +if exists('*shellescape') && exists('b:git_dir') && b:git_dir != '' +  if b:git_dir =~# '/\.git$' " Not a bare repository +    let &l:path = escape(fnamemodify(b:git_dir,':h'),'\, ').','.&l:path +  endif +  let &l:path = escape(b:git_dir,'\, ').','.&l:path +  let &l:keywordprg = 'git --git-dir='.shellescape(b:git_dir).' show' +else +  setlocal keywordprg=git\ show +endif +if has('gui_running') +  let &l:keywordprg = substitute(&l:keywordprg,'^git\>','git --no-pager','') +endif + +setlocal includeexpr=substitute(v:fname,'^[^/]\\+/','','') +let b:undo_ftplugin = "setl keywordprg< path< includeexpr<" diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim new file mode 100644 index 00000000..26d63514 --- /dev/null +++ b/ftplugin/gitcommit.vim @@ -0,0 +1,67 @@ +" Vim filetype plugin +" Language:	git commit file +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2012 April 7 + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) +  finish +endif + +runtime! ftplugin/git.vim +let b:did_ftplugin = 1 + +setlocal nomodeline tabstop=8 formatoptions-=croq formatoptions+=tl + +let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions<' + +if &textwidth == 0 +  " make sure that log messages play nice with git-log on standard terminals +  setlocal textwidth=72 +  let b:undo_ftplugin .= "|setl tw<" +endif + +if exists("g:no_gitcommit_commands") || v:version < 700 +  finish +endif + +if !exists("b:git_dir") +  let b:git_dir = expand("%:p:h") +endif + +command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) + +function! s:diffcomplete(A,L,P) +  let args = "" +  if a:P <= match(a:L." -- "," -- ")+3 +    let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n" +  end +  if exists("b:git_dir") && a:A !~ '^-' +    let tree = fnamemodify(b:git_dir,':h') +    if strpart(getcwd(),0,strlen(tree)) == tree +      let args = args."\n".system("git diff --cached --name-only") +    endif +  endif +  return args +endfunction + +function! s:gitdiffcached(bang,gitdir,...) +  let tree = fnamemodify(a:gitdir,':h') +  let name = tempname() +  let git = "git" +  if strpart(getcwd(),0,strlen(tree)) != tree +    let git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"') +  endif +  if a:0 +    let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'")) +  else +    let extra = "-p --stat=".&columns +  endif +  call system(git." diff --cached --no-color --no-ext-diff ".extra." > ".(exists("*shellescape") ? shellescape(name) : name)) +  exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name) +  wincmd P +  let b:git_dir = a:gitdir +  command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) +  nnoremap <buffer> <silent> q :q<CR> +  setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git +endfunction diff --git a/ftplugin/gitconfig.vim b/ftplugin/gitconfig.vim new file mode 100644 index 00000000..833b8b14 --- /dev/null +++ b/ftplugin/gitconfig.vim @@ -0,0 +1,15 @@ +" Vim filetype plugin +" Language:	git config file +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2009 Dec 24 + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) +  finish +endif +let b:did_ftplugin = 1 + +setlocal formatoptions-=t formatoptions+=croql +setlocal comments=:#,:; commentstring=;\ %s + +let b:undo_ftplugin = "setl fo< com< cms<" diff --git a/ftplugin/gitrebase.vim b/ftplugin/gitrebase.vim new file mode 100644 index 00000000..0200ba1a --- /dev/null +++ b/ftplugin/gitrebase.vim @@ -0,0 +1,43 @@ +" Vim filetype plugin +" Language:	git rebase --interactive +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 May 21 + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) +  finish +endif + +runtime! ftplugin/git.vim +let b:did_ftplugin = 1 + +setlocal comments=:# commentstring=#\ %s formatoptions-=t +if !exists("b:undo_ftplugin") +  let b:undo_ftplugin = "" +endif +let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo<" + +function! s:choose(word) +  s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e +endfunction + +function! s:cycle() +  call s:choose(get({'s':'edit','p':'squash','e':'reword','r':'fixup'},getline('.')[0],'pick')) +endfunction + +command! -buffer -bar Pick   :call s:choose('pick') +command! -buffer -bar Squash :call s:choose('squash') +command! -buffer -bar Edit   :call s:choose('edit') +command! -buffer -bar Reword :call s:choose('reword') +command! -buffer -bar Fixup  :call s:choose('fixup') +command! -buffer -bar Cycle  :call s:cycle() +" The above are more useful when they are mapped; for example: +"nnoremap <buffer> <silent> S :Cycle<CR> + +if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps") +  finish +endif + +nnoremap <buffer> <expr> K col('.') < 7 && expand('<Lt>cword>') =~ '\X' && getline('.') =~ '^\w\+\s\+\x\+\>' ? 'wK' : 'K' + +let b:undo_ftplugin = b:undo_ftplugin . "|nunmap <buffer> K" diff --git a/ftplugin/gitsendemail.vim b/ftplugin/gitsendemail.vim new file mode 100644 index 00000000..8fb436e1 --- /dev/null +++ b/ftplugin/gitsendemail.vim @@ -0,0 +1,6 @@ +" Vim filetype plugin +" Language:	git send-email message +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2009 Dec 24 + +runtime! ftplugin/mail.vim | 
