diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-10-28 13:59:37 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-10-28 13:59:37 -0500 |
commit | 5ddd29dbac631f129574b744ed9d1ca16eacdefa (patch) | |
tree | 6c1783e4d7c01aff395c554f2e974c8c480ff87d /vim | |
parent | de0a67c3e6fef7e95e6ede964dca16266d83c03b (diff) | |
download | conf-5ddd29dbac631f129574b744ed9d1ca16eacdefa.tar.gz conf-5ddd29dbac631f129574b744ed9d1ca16eacdefa.zip |
updates for vim's git configuration
Diffstat (limited to 'vim')
-rw-r--r-- | vim/doc/ft-gitcommit-plugin.txt | 5 | ||||
-rw-r--r-- | vim/doc/tags | 1 | ||||
-rw-r--r-- | vim/ftdetect/git.vim | 18 | ||||
-rw-r--r-- | vim/ftplugin/git.vim | 37 | ||||
-rw-r--r-- | vim/syntax/git.vim | 67 | ||||
-rw-r--r-- | vim/syntax/gitcommit.vim | 73 |
6 files changed, 201 insertions, 0 deletions
diff --git a/vim/doc/ft-gitcommit-plugin.txt b/vim/doc/ft-gitcommit-plugin.txt new file mode 100644 index 0000000..0d89ae1 --- /dev/null +++ b/vim/doc/ft-gitcommit-plugin.txt @@ -0,0 +1,5 @@ +GIT COMMIT *ft-gitcommit-plugin* + +One command, :DiffGitCached, is provided to show a diff of the current commit +in the preview window. It is equivalent to calling "git diff --cached" plus +any arguments given to the command. diff --git a/vim/doc/tags b/vim/doc/tags index 7ff4edc..3acbc55 100644 --- a/vim/doc/tags +++ b/vim/doc/tags @@ -153,6 +153,7 @@ b:match_word matchit.txt /*b:match_word* b:match_words matchit.txt /*b:match_words* cs surround.txt /*cs* ds surround.txt /*ds* +ft-gitcommit-plugin ft-gitcommit-plugin.txt /*ft-gitcommit-plugin* fugitive fugitive.txt /*fugitive* fugitive-:Gblame fugitive.txt /*fugitive-:Gblame* fugitive-:Gcd fugitive.txt /*fugitive-:Gcd* diff --git a/vim/ftdetect/git.vim b/vim/ftdetect/git.vim new file mode 100644 index 0000000..727bf0c --- /dev/null +++ b/vim/ftdetect/git.vim @@ -0,0 +1,18 @@ +" Git +autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG set ft=gitcommit +autocmd BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules set ft=gitconfig +autocmd BufNewFile,BufRead git-rebase-todo set ft=gitrebase +autocmd BufNewFile,BufRead .msg.[0-9]* + \ if getline(1) =~ '^From.*# This line is ignored.$' | + \ set ft=gitsendemail | + \ endif +autocmd BufNewFile,BufRead *.git/** + \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' | + \ set ft=git | + \ endif + +" This logic really belongs in scripts.vim +autocmd BufNewFile,BufRead,StdinReadPost * + \ if getline(1) =~ '^\(commit\|tree\|object\) \x\{40\}\>\|^tag \S\+$' | + \ set ft=git | + \ endif diff --git a/vim/ftplugin/git.vim b/vim/ftplugin/git.vim new file mode 100644 index 0000000..6b12ace --- /dev/null +++ b/vim/ftplugin/git.vim @@ -0,0 +1,37 @@ +" Vim filetype plugin +" Language: generic git output +" Maintainer: Tim Pope <vimNOSPAM@tpope.info> +" Last Change: 2008 Jul 30 + +" 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\>' + 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/vim/syntax/git.vim b/vim/syntax/git.vim new file mode 100644 index 0000000..fd0644a --- /dev/null +++ b/vim/syntax/git.vim @@ -0,0 +1,67 @@ +" Vim syntax file +" Language: generic git output +" Maintainer: Tim Pope <vimNOSPAM@tpope.info> +" Last Change: 2008 Mar 21 + +if exists("b:current_syntax") + finish +endif + +syn case match +syn sync minlines=50 + +syn include @gitDiff syntax/diff.vim + +syn region gitHead start=/\%^/ end=/^$/ +syn region gitHead start=/\%(^commit \x\{40\}\%(\s*(.*)\)\=$\)\@=/ end=/^$/ + +" For git reflog and git show ...^{tree}, avoid sync issues +syn match gitHead /^\d\{6\} \%(\w\{4} \)\=\x\{40\}\%( [0-3]\)\=\t.*/ +syn match gitHead /^\x\{40\} \x\{40}\t.*/ + +syn region gitDiff start=/^\%(diff --git \)\@=/ end=/^\%(diff --git \|$\)\@=/ contains=@gitDiff fold +syn region gitDiff start=/^\%(@@ -\)\@=/ end=/^\%(diff --git \|$\)\@=/ contains=@gitDiff + +syn match gitKeyword /^\%(object\|type\|tag\|commit\|tree\|parent\|encoding\)\>/ contained containedin=gitHead nextgroup=gitHash,gitType skipwhite +syn match gitKeyword /^\%(tag\>\|ref:\)/ contained containedin=gitHead nextgroup=gitReference skipwhite +syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite +syn match gitMode /^\d\{6\}/ contained containedin=gitHead nextgroup=gitType,gitHash skipwhite +syn match gitIdentityKeyword /^\%(author\|committer\|tagger\)\>/ contained containedin=gitHead nextgroup=gitIdentity skipwhite +syn match gitIdentityHeader /^\%(Author\|Commit\|Tagger\):/ contained containedin=gitHead nextgroup=gitIdentity skipwhite +syn match gitDateHeader /^\%(AuthorDate\|CommitDate\|Date\):/ contained containedin=gitHead nextgroup=gitDate skipwhite +syn match gitIdentity /\S.\{-\} <[^>]*>/ contained nextgroup=gitDate skipwhite +syn region gitEmail matchgroup=gitEmailDelimiter start=/</ end=/>/ keepend oneline contained containedin=gitIdentity + +syn match gitReflogHeader /^Reflog:/ contained containedin=gitHead nextgroup=gitReflogMiddle skipwhite +syn match gitReflogHeader /^Reflog message:/ contained containedin=gitHead skipwhite +syn match gitReflogMiddle /\S\+@{\d\+} (/he=e-2 nextgroup=gitIdentity + +syn match gitDate /\<\u\l\l \u\l\l \d\=\d \d\d:\d\d:\d\d \d\d\d\d [+-]\d\d\d\d/ contained +syn match gitDate /-\=\d\+ [+-]\d\d\d\d\>/ contained +syn match gitDate /\<\d\+ \l\+ ago\>/ contained +syn match gitType /\<\%(tag\|commit\|tree\|blob\)\>/ contained nextgroup=gitHash skipwhite +syn match gitStage /\<\d\t\@=/ contained +syn match gitReference /\S\+\S\@!/ contained +syn match gitHash /\<\x\{40\}\>/ contained nextgroup=gitIdentity,gitStage skipwhite +syn match gitHash /^\<\x\{40\}\>/ containedin=gitHead contained nextgroup=gitHash skipwhite +syn match gitHashAbbrev /\<\x\{4,39\}\.\.\./he=e-3 contained nextgroup=gitHashAbbrev skipwhite +syn match gitHashAbbrev /\<\x\{40\}\>/ contained nextgroup=gitHashAbbrev skipwhite + +hi def link gitDateHeader gitIdentityHeader +hi def link gitIdentityHeader gitIdentityKeyword +hi def link gitIdentityKeyword Label +hi def link gitReflogHeader gitKeyword +hi def link gitKeyword Keyword +hi def link gitIdentity String +hi def link gitEmailDelimiter Delimiter +hi def link gitEmail Special +hi def link gitDate Number +hi def link gitMode Number +hi def link gitHashAbbrev gitHash +hi def link gitHash Identifier +hi def link gitReflogMiddle gitReference +hi def link gitReference Function +hi def link gitStage gitType +hi def link gitType Type + +let b:current_syntax = "git" diff --git a/vim/syntax/gitcommit.vim b/vim/syntax/gitcommit.vim new file mode 100644 index 0000000..18e9397 --- /dev/null +++ b/vim/syntax/gitcommit.vim @@ -0,0 +1,73 @@ +" Vim syntax file +" Language: git commit file +" Maintainer: Tim Pope <vimNOSPAM@tpope.info> +" Filenames: *.git/COMMIT_EDITMSG +" Last Change: 2008 Apr 09 + +if exists("b:current_syntax") + finish +endif + +syn case match +syn sync minlines=50 + +if has("spell") + syn spell toplevel +endif + +syn include @gitcommitDiff syntax/diff.vim +syn region gitcommitDiff start=/\%(^diff --git \)\@=/ end=/^$\|^#\@=/ contains=@gitcommitDiff + +syn match gitcommitFirstLine "\%^[^#].*" nextgroup=gitcommitBlank skipnl +syn match gitcommitSummary "^.\{0,50\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell +syn match gitcommitOverflow ".*" contained contains=@Spell +syn match gitcommitBlank "^[^#].*" contained contains=@Spell +syn match gitcommitComment "^#.*" +syn match gitcommitHead "^\%(# .*\n\)\+#$" contained transparent +syn match gitcommitOnBranch "\%(^# \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite +syn match gitcommitOnBranch "\%(^# \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite +syn match gitcommitBranch "[^ \t']\+" contained +syn match gitcommitNoBranch "\%(^# \)\@<=Not currently on any branch." contained containedin=gitcommitComment +syn match gitcommitHeader "\%(^# \)\@<=.*:$" contained containedin=gitcommitComment +syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^# \)\@<=Author:/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent + +syn region gitcommitUntracked start=/^# Untracked files:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUntrackedFile fold +syn match gitcommitUntrackedFile "\t\@<=.*" contained + +syn region gitcommitDiscarded start=/^# Changed but not updated:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitDiscardedType fold +syn region gitcommitSelected start=/^# Changes to be committed:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitSelectedType fold + +syn match gitcommitDiscardedType "\t\@<=[a-z][a-z ]*[a-z]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitDiscardedFile skipwhite +syn match gitcommitSelectedType "\t\@<=[a-z][a-z ]*[a-z]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite +syn match gitcommitDiscardedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow +syn match gitcommitSelectedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow +syn match gitcommitDiscardedArrow " -> " contained nextgroup=gitcommitDiscardedFile +syn match gitcommitSelectedArrow " -> " contained nextgroup=gitcommitSelectedFile + +syn match gitcommitWarning "\%^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl +syn match gitcommitWarning "^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl contained +syn match gitcommitWarning "^\%(no changes added to commit\|nothing \%(added \)\=to commit\)\>.*\%$" + +hi def link gitcommitSummary Keyword +hi def link gitcommitComment Comment +hi def link gitcommitUntracked gitcommitComment +hi def link gitcommitDiscarded gitcommitComment +hi def link gitcommitSelected gitcommitComment +hi def link gitcommitOnBranch Comment +hi def link gitcommitBranch Special +hi def link gitcommitNoBranch gitCommitBranch +hi def link gitcommitDiscardedType gitcommitType +hi def link gitcommitSelectedType gitcommitType +hi def link gitcommitType Type +hi def link gitcommitHeader PreProc +hi def link gitcommitUntrackedFile gitcommitFile +hi def link gitcommitDiscardedFile gitcommitFile +hi def link gitcommitSelectedFile gitcommitFile +hi def link gitcommitFile Constant +hi def link gitcommitDiscardedArrow gitcommitArrow +hi def link gitcommitSelectedArrow gitcommitArrow +hi def link gitcommitArrow gitcommitComment +"hi def link gitcommitOverflow Error +hi def link gitcommitBlank Error + +let b:current_syntax = "gitcommit" |