aboutsummaryrefslogtreecommitdiffstats
path: root/projects/aodocs.vim
blob: fc67ab51a64534ddabd29ac6633482206c3a5803 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
augroup AODocs
	autocmd!

	autocmd BufRead $VIM_PROJECT_PATH_AODOCS_GO/ufo-client/client/*.go
		\ silent GoGuruScope github.com/Revevol-Apps/ufo-client/client

	autocmd BufRead,BufEnter $VIM_PROJECT_PATH_AODOCS/*.js
		\ setlocal expandtab tabstop=2 softtabstop=2 shiftwidth=2

	autocmd BufRead,BufEnter $VIM_PROJECT_PATH_AODOCS/*.json
		\ setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4

	autocmd BufNewFile,BufRead
		\ $VIM_PROJECT_PATH_AODOCS_GO/*/.git/{COMMIT_EDIT,MERGE_,TAG_EDIT}MSG
		\,$VIM_PROJECT_PATH_AODOCS/*/.git/{COMMIT_EDIT,MERGE_,TAG_EDIT}MSG
		\ call s:CommitWackoTextWidthMappings()
		\ | call s:CommitWackoTextWidth()
augroup END


" Enables a longer-than-72 character first line and 72 character wrapping on
" subsequent lines.
function! s:CommitWackoTextWidth()
	if line('.') == 1
		" Match "CO-123: "
		let matches = matchlist(getline('.'), '^\u\+-\d\+: ')

		if !empty(matches)
			let id_prefix_length = len(matches[0])
			execute 'setlocal textwidth=' . (72 + id_prefix_length)
		endif
	else
		setlocal textwidth=72
	endif
endfunction

function! s:CommitWackoTextWidthMappings()
	inoremap <buffer> <CR> <C-o>:call <SID>CommitWackoTextWidth()<CR><CR>
	nnoremap <buffer> o :call <SID>CommitWackoTextWidth()<CR>o
	nnoremap <buffer> O :call <SID>CommitWackoTextWidth()<CR>O
endfunction