From 95aea6b533e71e478d61d18fac71cca116c56a4d Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 22 May 2022 22:47:23 +0100 Subject: Add all the plugins I currently use --- start/signify/plugin/signify.vim | 120 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 start/signify/plugin/signify.vim (limited to 'start/signify/plugin') diff --git a/start/signify/plugin/signify.vim b/start/signify/plugin/signify.vim new file mode 100644 index 0000000..3a13442 --- /dev/null +++ b/start/signify/plugin/signify.vim @@ -0,0 +1,120 @@ +" vim: et sw=2 sts=2 + +scriptencoding utf-8 + +if exists('g:loaded_signify') || !has('signs') || &compatible + finish +endif + +" Init: values {{{1 +let g:loaded_signify = 1 +let g:signify_locked = 0 +let s:has_doau_modeline = v:version > 703 || v:version == 703 && has('patch442') + +" Init: autocmds {{{1 +augroup signify + autocmd! + + autocmd QuickFixCmdPre *vimgrep* let g:signify_locked = 1 + autocmd QuickFixCmdPost *vimgrep* let g:signify_locked = 0 + + autocmd CmdwinEnter * let g:signify_cmdwin_active = 1 + autocmd CmdwinLeave * let g:signify_cmdwin_active = 0 + + autocmd BufWritePost * call sy#start() + + 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 + autocmd BufEnter * call sy#start() + endif + 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 + else + autocmd BufRead * call sy#start() + 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 + endif + + if has('gui_running') && has('win32') && argc() + " Fix 'no signs at start' race. + autocmd GUIEnter * redraw + endif +augroup END + +" Init: commands {{{1 + +command! -nargs=0 -bar SignifyList call sy#debug#list_active_buffers() +command! -nargs=0 -bar SignifyDebug call sy#repo#debug_detection() +command! -nargs=0 -bar -bang SignifyFold call sy#fold#dispatch(1) +command! -nargs=0 -bar -bang SignifyDiff call sy#repo#diffmode(1) +command! -nargs=0 -bar SignifyRefresh call sy#util#refresh_windows() +command! -nargs=0 -bar SignifyEnable call sy#enable() +command! -nargs=0 -bar SignifyDisable call sy#disable() +command! -nargs=0 -bar SignifyToggle call sy#toggle() +command! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle() + +" Init: mappings {{{1 +let s:cpoptions = &cpoptions +set cpoptions+=B + +" hunk jumping +nnoremap (signify-next-hunk) &diff + \ ? ']c' + \ : ":\call sy#jump#next_hunk(v:count1)\" +nnoremap (signify-prev-hunk) &diff + \ ? '[c' + \ : ":\call sy#jump#prev_hunk(v:count1)\" + +if empty(maparg(']c', 'n')) && !hasmapto('(signify-next-hunk)', 'n') + nmap ]c (signify-next-hunk) + if empty(maparg(']C', 'n')) && !hasmapto('9999]c', 'n') + nmap ]C 9999]c + endif +endif +if empty(maparg('[c', 'n')) && !hasmapto('(signify-prev-hunk)', 'n') + nmap [c (signify-prev-hunk) + if empty(maparg('[C', 'n')) && !hasmapto('9999[c', 'n') + nmap [C 9999[c + end +endif + +" hunk text object +onoremap (signify-motion-inner-pending) :call sy#util#hunk_text_object(0) +xnoremap (signify-motion-inner-visual) :call sy#util#hunk_text_object(0) +onoremap (signify-motion-outer-pending) :call sy#util#hunk_text_object(1) +xnoremap (signify-motion-outer-visual) :call sy#util#hunk_text_object(1) + +let &cpoptions = s:cpoptions +unlet s:cpoptions + +" Function: save {{{1 + +function! s:save() + if exists('b:sy') && b:sy.active && &modified && &modifiable && ! &readonly + write + endif +endfunction + +if exists('#User#SignifySetup') + execute 'doautocmd' (s:has_doau_modeline ? '' : '') 'User SignifySetup' +endif -- cgit v1.2.3