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
|
|
|
|
2013-03-08 01:16:33 -05:00
|
|
|
if exists('g:loaded_signify') || !has('signs') || &cp
|
2013-03-05 13:48:21 -05:00
|
|
|
finish
|
|
|
|
endif
|
2013-11-25 17:33:31 -05:00
|
|
|
|
2013-03-05 13:48:21 -05:00
|
|
|
let g:loaded_signify = 1
|
2013-11-25 17:33:31 -05:00
|
|
|
let g:signify_locked = 0
|
2013-03-05 13:48:21 -05:00
|
|
|
|
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-12-27 08:45:44 -05:00
|
|
|
autocmd VimEnter * call sy#highlight#setup()
|
|
|
|
autocmd BufRead,BufEnter,SessionLoadPost * let b:sy_path = resolve(expand('<afile>:p'))
|
|
|
|
autocmd BufRead,BufWritePost * call sy#start(b:sy_path)
|
|
|
|
autocmd BufDelete * call sy#stop(expand('<abuf>'))
|
2013-04-03 04:31:37 -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
|
|
|
|
|
2013-06-06 06:39:24 -04:00
|
|
|
if get(g:, 'signify_update_on_bufenter')
|
2013-06-06 12:02:57 -04:00
|
|
|
autocmd BufEnter * nested
|
2013-11-21 20:57:43 -05:00
|
|
|
\ if exists('b:sy') && b:sy.active && &modified |
|
2013-06-06 12:02:57 -04:00
|
|
|
\ write |
|
|
|
|
\ endif
|
2013-03-12 07:25:22 -04:00
|
|
|
endif
|
2013-03-13 14:23:47 -04:00
|
|
|
|
2013-04-03 04:31:37 -04:00
|
|
|
if get(g:, 'signify_cursorhold_normal')
|
2013-04-14 06:26:35 -04:00
|
|
|
autocmd CursorHold * nested
|
2013-11-21 20:57:43 -05:00
|
|
|
\ if exists('b:sy') && b:sy.active && &modified |
|
2013-04-14 06:26:35 -04:00
|
|
|
\ write |
|
2013-04-14 03:58:59 -04:00
|
|
|
\ endif
|
2013-03-12 07:25:22 -04:00
|
|
|
endif
|
2013-03-13 14:23:47 -04:00
|
|
|
|
2013-04-03 04:31:37 -04:00
|
|
|
if get(g:, 'signify_cursorhold_insert')
|
2013-04-14 06:26:35 -04:00
|
|
|
autocmd CursorHoldI * nested
|
2013-11-21 20:57:43 -05:00
|
|
|
\ if exists('b:sy') && b:sy.active && &modified |
|
2013-04-14 06:26:35 -04:00
|
|
|
\ write |
|
2013-04-14 03:58:59 -04:00
|
|
|
\ endif
|
2013-04-03 01:32:51 -04:00
|
|
|
endif
|
|
|
|
|
2013-08-13 02:09:02 -04:00
|
|
|
if get(g:, 'signify_update_on_focusgained') && !has('gui_win32')
|
2013-11-21 20:57:43 -05:00
|
|
|
autocmd FocusGained * if exists('b:sy') | call sy#start(b:sy.path) | endif
|
2013-03-13 14:06:52 -04:00
|
|
|
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-07-21 18:21:34 -04:00
|
|
|
com! -nargs=0 -bar SignifyToggle call sy#toggle()
|
|
|
|
com! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle()
|
|
|
|
com! -nargs=0 -bar SyDebug call sy#debug#list_active_buffers()
|
2013-03-05 13:48:21 -05:00
|
|
|
|
2013-04-02 10:18:01 -04:00
|
|
|
" Init: mappings {{{1
|
2013-07-21 18:21:34 -04: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>"
|
|
|
|
nnoremap <silent> <plug>(signify-toggle-highlight) :<c-u>call sy#highlight#line_toggle()<cr>
|
|
|
|
nnoremap <silent> <plug>(signify-toggle) :<c-u>call sy#toggle()<cr>
|
2013-07-21 07:45:09 -04:00
|
|
|
|
2013-04-02 10:18:01 -04:00
|
|
|
if exists('g:signify_mapping_next_hunk')
|
2013-07-21 18:21:34 -04:00
|
|
|
execute 'nmap '. g:signify_mapping_next_hunk .' <plug>(signify-next-hunk)'
|
2013-09-06 11:22:04 -04:00
|
|
|
elseif !hasmapto('<plug>(signify-next-hunk)') && empty(maparg('<leader>gj', 'n'))
|
2013-07-21 18:21:34 -04:00
|
|
|
nmap <leader>gj <plug>(signify-next-hunk)
|
2013-04-02 10:18:01 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
if exists('g:signify_mapping_prev_hunk')
|
2013-07-21 18:21:34 -04:00
|
|
|
execute 'nmap '. g:signify_mapping_prev_hunk .' <plug>(signify-prev-hunk)'
|
2013-09-06 11:22:04 -04:00
|
|
|
elseif !hasmapto('<plug>(signify-prev-hunk)') && empty(maparg('<leader>gk', 'n'))
|
2013-07-21 18:21:34 -04:00
|
|
|
nmap <leader>gk <plug>(signify-prev-hunk)
|
2013-04-02 10:18:01 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
if exists('g:signify_mapping_toggle_highlight')
|
2013-07-21 18:21:34 -04:00
|
|
|
execute 'nmap '. g:signify_mapping_toggle_highlight .' <plug>(signify-toggle-highlight)'
|
2013-09-06 11:22:04 -04:00
|
|
|
elseif !hasmapto('<plug>(signify-toggle-highlight)') && empty(maparg('<leader>gh', 'n'))
|
2013-07-21 18:21:34 -04:00
|
|
|
nmap <leader>gh <plug>(signify-toggle-highlight)
|
2013-04-02 10:18:01 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
if exists('g:signify_mapping_toggle')
|
2013-07-21 18:21:34 -04:00
|
|
|
execute 'nmap '. g:signify_mapping_toggle .' <plug>(signify-toggle)'
|
2013-09-06 11:22:04 -04:00
|
|
|
elseif !hasmapto('<plug>(signify-toggle)') && empty(maparg('<leader>gt', 'n'))
|
2013-07-21 18:21:34 -04:00
|
|
|
nmap <leader>gt <plug>(signify-toggle)
|
|
|
|
endif
|
|
|
|
|
2013-09-06 11:22:04 -04:00
|
|
|
if empty(maparg(']c', 'n'))
|
2013-07-21 18:21:34 -04:00
|
|
|
nmap ]c <plug>(signify-next-hunk)
|
|
|
|
endif
|
|
|
|
|
2013-09-06 11:22:04 -04:00
|
|
|
if empty(maparg('[c', 'n'))
|
2013-07-21 18:21:34 -04:00
|
|
|
nmap [c <plug>(signify-prev-hunk)
|
2013-04-02 10:18:01 -04:00
|
|
|
endif
|