blob: 1bc330804932081c4e01f55db4ff3cfaaf93a5cd (
plain) (
tree)
|
|
set nocompatible " (Don't) Behave Vi-compatible as much as possible
set tabstop=4 " Number of spaces that <Tab> characters display
set softtabstop=4 " Number of spaces that <Tab> uses while editing
set shiftwidth=4 " Number of spaces to use for autoindent
set expandtab " Use spaces when <Tab> is inserted
set autoindent " Take indent for new line from previous line
" Readable diffs
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
" Auto format git commit trailers
command! Tso call InsTrailer('o', 'Signed-off-by: ' .. GitIdent())
command! TTso call InsTrailer('O', 'Signed-off-by: ' .. GitIdent())
command! Tco call InsTrailer('o', 'Co-authored-by: ' .. GitIdent())
command! TTco call InsTrailer('O', 'Co-authored-by: ' .. GitIdent())
command! Tack call InsTrailer('o', 'Acked-by: ' .. GitIdent())
command! TTack call InsTrailer('O', 'Acked-by: ' .. GitIdent())
command! Tres call InsTrailer('o', 'Reviewed-by: ' .. GitIdent())
command! TTres call InsTrailer('O', 'Reviewed-by: ' .. GitIdent())
command! Treq call InsTrailer('o', 'Reported-by: ' .. GitIdent())
command! TTreq call InsTrailer('O', 'Reported-by: ' .. GitIdent())
command! Tes call InsTrailer('o', 'Tested-by: ' .. GitIdent())
command! TTes call InsTrailer('O', 'Tested-by: ' .. GitIdent())
command! Tcc call InsTrailer('o', 'Cc: ' .. GitIdent())
command! TTcc call InsTrailer('O', 'Cc: ' .. GitIdent())
command! -nargs=1 Tln call InsTrailer('o', 'Link: ' .. '<args>')
command! -nargs=1 TTln call InsTrailer('O', 'Link: ' .. '<args>')
command! -nargs=1 Tfix call InsTrailer('o', 'Fixes: ' .. GitRef('<args>'))
command! -nargs=1 TTfix call InsTrailer('O', 'Fixes: ' .. GitRef('<args>'))
command! -nargs=1 Ref execute 'normal! a' .. GitRef('<args>')
function! GitIdent()
return system("printf '%s <%s>' " ..
\ "$(git config get user.name || echo noname) " ..
\ "$(git config get user.email || echo noemail)")
endfunction
function! GitRef(revision)
return system("git log -1 --pretty='format:%h (\"%s\")' " ..
\ a:revision .. " 2>/dev/null || printf norevision")
endfunction
function! InsTrailer(o, trailer)
let l:i = 'normal! ' .. a:o
" Current line neither blank nor another trailer
if getline('.') !~ '^$\|^[> ]*[A-Z][-a-z]*: \S.*$'
execute l:i
endif
execute l:i .. a:trailer
normal! 0
endfunction
|