vim-signify/plugin/signify.vim

77 lines
2.1 KiB
VimL
Raw Normal View History

2013-09-30 04:19:31 -04:00
" vim: et sw=2 sts=2
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
2014-10-04 09:55:49 -04:00
" Init: values {{{1
2013-03-05 13:48:21 -05:00
let g:loaded_signify = 1
let g:signify_locked = 0
2013-03-05 13:48:21 -05:00
2013-04-02 10:18:01 -04:00
" Init: autocmds {{{1
augroup signify
autocmd!
2013-03-13 14:23:47 -04:00
2014-10-24 05:39:05 -04:00
autocmd BufRead,BufWritePost * call sy#start()
autocmd BufDelete * call sy#stop()
2013-04-03 04:31:37 -04:00
autocmd QuickFixCmdPre *vimgrep* let g:signify_locked = 1
autocmd QuickFixCmdPost *vimgrep* let g:signify_locked = 0
if get(g:, 'signify_update_on_bufenter')
2014-10-04 09:55:49 -04:00
autocmd BufEnter * nested call s:save()
endif
2013-04-03 04:31:37 -04:00
if get(g:, 'signify_cursorhold_normal')
2014-10-04 09:55:49 -04:00
autocmd CursorHold * nested call s:save()
endif
2013-04-03 04:31:37 -04:00
if get(g:, 'signify_cursorhold_insert')
2014-10-04 09:55:49 -04:00
autocmd CursorHoldI * nested call s:save()
2013-04-03 01:32:51 -04:00
endif
if get(g:, 'signify_update_on_focusgained') && !has('gui_win32')
autocmd FocusGained * call SignifyRefresh
2013-03-13 14:06:52 -04:00
endif
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
command! -nargs=0 -bar SignifyDebug call sy#debug#list_active_buffers()
command! -nargs=0 -bar SignifyRefresh call sy#util#refresh_windows()
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
" Init: mappings {{{1
" hunk jumping
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>"
if empty(maparg(']c', 'n'))
nmap ]c <plug>(signify-next-hunk)
endif
if empty(maparg('[c', 'n'))
nmap [c <plug>(signify-prev-hunk)
endif
2013-04-02 10:18:01 -04:00
" hunk text object
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
" Function: save {{{1
2014-10-04 09:55:49 -04:00
function! s:save()
if exists('b:sy') && b:sy.active && &modified
write
endif
endfunction