Skip to content

Commit fda02d0

Browse files
tpopechrisbra
authored andcommitted
runtime(gitcommit): Updates to ftplugin and syntax
1 parent 757714c commit fda02d0

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

runtime/ftplugin/gitcommit.vim

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim filetype plugin
22
" Language: git commit file
33
" Maintainer: Tim Pope <[email protected]>
4-
" Last Change: 2022 Jan 05
4+
" Last Change: 2023 Dec 28
55

66
" Only do this when not done yet for this buffer
77
if (exists("b:did_ftplugin"))
@@ -12,7 +12,7 @@ let b:did_ftplugin = 1
1212

1313
setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72
1414
setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q formatoptions+=n
15-
setlocal formatlistpat+=\\\|^\\s*[-*+]\\s\\+
15+
setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}]\\s\\+\\\|^\\s*[-*+]\\s\\+
1616
setlocal include=^+++
1717
setlocal includeexpr=substitute(v:fname,'^[bi]/','','')
1818

@@ -42,6 +42,11 @@ function! s:diffcomplete(A, L, P) abort
4242
return args
4343
endfunction
4444

45+
function! s:setupdiff() abort
46+
command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0, <f-args>)
47+
setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git
48+
endfunction
49+
4550
function! s:gitdiffcached(bang, ...) abort
4651
let name = tempname()
4752
if a:0
@@ -50,8 +55,6 @@ function! s:gitdiffcached(bang, ...) abort
5055
let extra = "-p --stat=".&columns
5156
endif
5257
call system("git diff --cached --no-color --no-ext-diff ".extra." > ".shellescape(name))
53-
exe "pedit " . fnameescape(name)
54-
wincmd P
55-
command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0, <f-args>)
56-
setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git
58+
exe 'pedit +call\ s:setupdiff()' fnameescape(name)
59+
silent! wincmd P
5760
endfunction

runtime/syntax/gitcommit.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Language: git commit file
33
" Maintainer: Tim Pope <[email protected]>
44
" Filenames: *.git/COMMIT_EDITMSG
5-
" Last Change: 2022 Jan 05
5+
" Last Change: 2023 Dec 28
66

77
if exists("b:current_syntax")
88
finish
@@ -21,7 +21,11 @@ endif
2121
syn include @gitcommitDiff syntax/diff.vim
2222
syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|@@\@!\|[^[:alnum:]\ +-]\S\@!\)\@=/ fold contains=@gitcommitDiff
2323

24-
syn match gitcommitSummary "^.*\%<51v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
24+
if get(g:, 'gitcommit_summary_length') < 0
25+
syn match gitcommitSummary "^.*$" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
26+
elseif get(g:, 'gitcommit_summary_length', 1) > 0
27+
exe 'syn match gitcommitSummary "^.*\%<' . (get(g:, 'gitcommit_summary_length', 50) + 1) . 'v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell'
28+
endif
2529
syn match gitcommitOverflow ".*" contained contains=@Spell
2630
syn match gitcommitBlank "^.\+" contained contains=@Spell
2731
syn match gitcommitFirstLine "\%^.*" nextgroup=gitcommitBlank,gitcommitComment skipnl

0 commit comments

Comments
 (0)