2013-09-30 04:19:31 -04:00
|
|
|
" vim: et sw=2 sts=2
|
|
|
|
|
2013-08-19 11:36:16 -04:00
|
|
|
scriptencoding utf-8
|
2013-03-07 07:12:01 -05:00
|
|
|
|
2014-10-04 09:55:49 -04:00
|
|
|
if exists('g:loaded_signify') || !has('signs') || &compatible
|
2013-03-05 13:48:21 -05:00
|
|
|
finish
|
|
|
|
endif
|
2013-11-25 17:33:31 -05:00
|
|
|
|
2014-10-04 09:55:49 -04:00
|
|
|
" Init: values {{{1
|
2017-02-25 16:06:54 -05:00
|
|
|
let g:loaded_signify = 1
|
|
|
|
let g:signify_locked = 0
|
2017-02-20 10:40:57 -05:00
|
|
|
let s:has_doau_modeline = v:version > 703 || v:version == 703 && has('patch442')
|
|
|
|
|
2013-04-02 10:18:01 -04:00
|
|
|
" Init: autocmds {{{1
|
2013-03-12 07:25:22 -04:00
|
|
|
augroup signify
|
|
|
|
autocmd!
|
2013-03-13 14:23:47 -04:00
|
|
|
|
2013-11-25 17:33:31 -05:00
|
|
|
autocmd QuickFixCmdPre *vimgrep* let g:signify_locked = 1
|
|
|
|
autocmd QuickFixCmdPost *vimgrep* let g:signify_locked = 0
|
|
|
|
|
2017-03-02 10:46:38 -05:00
|
|
|
autocmd CmdwinEnter * let g:signify_cmdwin_active = 1
|
|
|
|
autocmd CmdwinLeave * let g:signify_cmdwin_active = 0
|
|
|
|
|
2017-02-25 16:06:54 -05:00
|
|
|
autocmd BufWritePost * call sy#start()
|
2017-02-20 10:05:55 -05:00
|
|
|
|
2017-02-25 16:06:54 -05:00
|
|
|
if get(g:, 'signify_realtime') && has('patch-7.4.1967')
|
|
|
|
autocmd WinEnter * call sy#start()
|
|
|
|
if get(g:, 'signify_update_on_bufenter')
|
|
|
|
autocmd BufEnter * nested call s:save()
|
|
|
|
else
|
2017-02-24 12:16:14 -05:00
|
|
|
autocmd BufEnter * call sy#start()
|
|
|
|
endif
|
2017-02-25 16:06:54 -05:00
|
|
|
if get(g:, 'signify_cursorhold_normal', 1)
|
|
|
|
autocmd CursorHold * nested call s:save()
|
|
|
|
endif
|
|
|
|
if get(g:, 'signify_cursorhold_insert', 1)
|
|
|
|
autocmd CursorHoldI * nested call s:save()
|
|
|
|
endif
|
|
|
|
if get(g:, 'signify_update_on_focusgained', 1)
|
|
|
|
autocmd FocusGained * SignifyRefresh
|
|
|
|
endif
|
2017-02-18 11:28:49 -05:00
|
|
|
else
|
2017-02-20 10:05:55 -05:00
|
|
|
autocmd BufRead * call sy#start()
|
2017-02-25 16:06:54 -05:00
|
|
|
if get(g:, 'signify_update_on_bufenter')
|
|
|
|
autocmd BufEnter * nested call s:save()
|
|
|
|
endif
|
|
|
|
if get(g:, 'signify_cursorhold_normal')
|
|
|
|
autocmd CursorHold * nested call s:save()
|
|
|
|
endif
|
|
|
|
if get(g:, 'signify_cursorhold_insert')
|
|
|
|
autocmd CursorHoldI * nested call s:save()
|
|
|
|
endif
|
|
|
|
if get(g:, 'signify_update_on_focusgained')
|
|
|
|
autocmd FocusGained * SignifyRefresh
|
|
|
|
endif
|
2013-03-13 14:06:52 -04:00
|
|
|
endif
|
2017-02-21 11:10:48 -05:00
|
|
|
|
2017-02-26 08:00:28 -05:00
|
|
|
if has('gui_running') && has('win32') && argc()
|
2017-02-21 11:10:48 -05:00
|
|
|
" Fix 'no signs at start' race.
|
|
|
|
autocmd GUIEnter * redraw
|
|
|
|
endif
|
2013-03-12 07:25:22 -04:00
|
|
|
augroup END
|
2013-03-05 13:48:21 -05:00
|
|
|
|
2013-04-02 10:18:01 -04:00
|
|
|
" Init: commands {{{1
|
2013-03-05 13:48:21 -05:00
|
|
|
|
2017-01-17 18:14:36 -05:00
|
|
|
command! -nargs=0 -bar SignifyList call sy#debug#list_active_buffers()
|
|
|
|
command! -nargs=0 -bar SignifyDebug call sy#repo#debug_detection()
|
2015-12-08 18:31:59 -05:00
|
|
|
command! -nargs=0 -bar -bang SignifyFold call sy#fold#dispatch(<bang>1)
|
2018-11-02 16:12:02 -04:00
|
|
|
command! -nargs=0 -bar -bang SignifyDiff call sy#repo#diffmode(<bang>1)
|
2015-12-08 18:31:59 -05:00
|
|
|
command! -nargs=0 -bar SignifyRefresh call sy#util#refresh_windows()
|
2016-01-06 18:00:21 -05:00
|
|
|
command! -nargs=0 -bar SignifyEnable call sy#enable()
|
|
|
|
command! -nargs=0 -bar SignifyDisable call sy#disable()
|
2015-12-08 18:31:59 -05:00
|
|
|
command! -nargs=0 -bar SignifyToggle call sy#toggle()
|
|
|
|
command! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle()
|
2014-10-05 19:32:10 -04:00
|
|
|
|
2014-11-05 08:16:44 -05:00
|
|
|
" Init: mappings {{{1
|
2018-03-26 14:40:44 -04:00
|
|
|
let s:cpoptions = &cpoptions
|
|
|
|
set cpoptions+=B
|
2013-07-21 07:45:09 -04:00
|
|
|
|
2014-10-28 12:32:08 -04:00
|
|
|
" hunk jumping
|
2014-11-05 08:16:44 -05:00
|
|
|
nnoremap <silent> <expr> <plug>(signify-next-hunk) &diff
|
|
|
|
\ ? ']c'
|
|
|
|
\ : ":\<c-u>call sy#jump#next_hunk(v:count1)\<cr>"
|
|
|
|
nnoremap <silent> <expr> <plug>(signify-prev-hunk) &diff
|
|
|
|
\ ? '[c'
|
|
|
|
\ : ":\<c-u>call sy#jump#prev_hunk(v:count1)\<cr>"
|
2014-10-28 12:32:08 -04:00
|
|
|
|
2018-08-01 16:15:18 -04:00
|
|
|
if empty(maparg(']c', 'n')) && !hasmapto('<plug>(signify-next-hunk)', 'n')
|
2014-10-28 12:32:08 -04:00
|
|
|
nmap ]c <plug>(signify-next-hunk)
|
2018-08-01 16:15:18 -04:00
|
|
|
if empty(maparg(']C', 'n')) && !hasmapto('9999]c', 'n')
|
|
|
|
nmap ]C 9999]c
|
|
|
|
endif
|
2014-10-28 12:32:08 -04:00
|
|
|
endif
|
2018-08-01 16:15:18 -04:00
|
|
|
if empty(maparg('[c', 'n')) && !hasmapto('<plug>(signify-prev-hunk)', 'n')
|
2014-10-28 12:32:08 -04:00
|
|
|
nmap [c <plug>(signify-prev-hunk)
|
2018-08-01 16:15:18 -04:00
|
|
|
if empty(maparg('[C', 'n')) && !hasmapto('9999[c', 'n')
|
|
|
|
nmap [C 9999[c
|
|
|
|
end
|
2014-10-28 12:32:08 -04:00
|
|
|
endif
|
2013-04-02 10:18:01 -04:00
|
|
|
|
2014-10-28 12:32:08 -04:00
|
|
|
" hunk text object
|
2014-11-05 08:16:44 -05:00
|
|
|
onoremap <silent> <plug>(signify-motion-inner-pending) :<c-u>call sy#util#hunk_text_object(0)<cr>
|
|
|
|
xnoremap <silent> <plug>(signify-motion-inner-visual) :<c-u>call sy#util#hunk_text_object(0)<cr>
|
|
|
|
onoremap <silent> <plug>(signify-motion-outer-pending) :<c-u>call sy#util#hunk_text_object(1)<cr>
|
|
|
|
xnoremap <silent> <plug>(signify-motion-outer-visual) :<c-u>call sy#util#hunk_text_object(1)<cr>
|
2014-10-04 09:55:49 -04:00
|
|
|
|
2018-03-26 14:40:44 -04:00
|
|
|
let &cpoptions = s:cpoptions
|
|
|
|
unlet s:cpoptions
|
|
|
|
|
2014-10-04 09:55:49 -04:00
|
|
|
" Function: save {{{1
|
2014-11-05 08:16:44 -05:00
|
|
|
|
2014-10-04 09:55:49 -04:00
|
|
|
function! s:save()
|
2018-01-27 21:43:20 -05:00
|
|
|
if exists('b:sy') && b:sy.active && &modified && &modifiable && ! &readonly
|
2014-10-04 09:55:49 -04:00
|
|
|
write
|
|
|
|
endif
|
|
|
|
endfunction
|
2017-02-20 10:40:57 -05:00
|
|
|
|
|
|
|
if exists('#User#SignifySetup')
|
|
|
|
execute 'doautocmd' (s:has_doau_modeline ? '<nomodeline>' : '') 'User SignifySetup'
|
|
|
|
endif
|