2013-04-02 03:36:42 -04:00
|
|
|
" Plugin: https://github.com/mhinz/vim-signify
|
|
|
|
" Description: show a diff from a version control system via the signcolumn
|
|
|
|
" Maintainer: Marco Hinz <http://github.com/mhinz>
|
2013-07-04 07:06:08 -04:00
|
|
|
" Version: 1.9
|
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
|
|
|
|
let g:loaded_signify = 1
|
|
|
|
|
2013-04-02 10:18:01 -04:00
|
|
|
" Init: values {{{1
|
2013-07-17 06:30:58 -04:00
|
|
|
let g:sy = {}
|
2013-03-13 09:30:42 -04: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-07-17 06:30:58 -04:00
|
|
|
autocmd VimEnter * call sy#highlight#setup()
|
|
|
|
autocmd BufRead,BufEnter * let g:sy_path = resolve(expand('<afile>:p'))
|
|
|
|
autocmd BufRead,BufWritePost * call sy#start(g:sy_path)
|
2013-07-08 05:25:12 -04:00
|
|
|
|
|
|
|
autocmd BufDelete *
|
|
|
|
\ let path = resolve(expand('<afile>:p')) |
|
2013-07-17 06:30:58 -04:00
|
|
|
\ call sy#stop(path) |
|
|
|
|
\ if has_key(g:sy, path) |
|
|
|
|
\ call remove(g:sy, path) |
|
2013-07-08 05:25:12 -04:00
|
|
|
\ endif
|
2013-04-03 04:31:37 -04:00
|
|
|
|
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-07-17 06:30:58 -04:00
|
|
|
\ if has_key(g:sy, g:sy_path) && g:sy[g:sy_path].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-07-17 06:30:58 -04:00
|
|
|
\ if has_key(g:sy, g:sy_path) && g:sy[g:sy_path].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-07-17 06:30:58 -04:00
|
|
|
\ if has_key(g:sy, g:sy_path) && g:sy[g:sy_path].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-03-13 14:23:47 -04:00
|
|
|
if !has('gui_win32')
|
2013-07-17 06:30:58 -04:00
|
|
|
autocmd FocusGained * call sy#start(g:sy_path)
|
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-17 06:30:58 -04:00
|
|
|
com! -nargs=0 -bar SignifyToggle call sy#toggle()
|
|
|
|
com! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle()
|
|
|
|
com! -nargs=0 -bar -count SignifyJumpToNextHunk call sy#jump#next_hunk(<count>)
|
|
|
|
com! -nargs=0 -bar -count SignifyJumpToPrevHunk call sy#jump#prev_hunk(<count>)
|
|
|
|
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
|
|
|
|
if exists('g:signify_mapping_next_hunk')
|
|
|
|
execute 'nnoremap <silent> '. g:signify_mapping_next_hunk .' :<c-u>execute v:count ."SignifyJumpToNextHunk"<cr>'
|
|
|
|
else
|
|
|
|
nnoremap <silent> <leader>gj :<c-u>execute v:count .'SignifyJumpToNextHunk'<cr>
|
|
|
|
endif
|
|
|
|
|
|
|
|
if exists('g:signify_mapping_prev_hunk')
|
|
|
|
execute 'nnoremap <silent> '. g:signify_mapping_prev_hunk .' :<c-u>execute v:count ."SignifyJumpToPrevHunk"<cr>'
|
|
|
|
else
|
|
|
|
nnoremap <silent> <leader>gk :<c-u>execute v:count .'SignifyJumpToPrevHunk'<cr>
|
|
|
|
endif
|
|
|
|
|
|
|
|
if exists('g:signify_mapping_toggle_highlight')
|
|
|
|
execute 'nnoremap <silent> '. g:signify_mapping_toggle_highlight .' :SignifyToggleHighlight<cr>'
|
|
|
|
else
|
|
|
|
nnoremap <silent> <leader>gh :SignifyToggleHighlight<cr>
|
|
|
|
endif
|
|
|
|
|
|
|
|
if exists('g:signify_mapping_toggle')
|
|
|
|
execute 'nnoremap <silent> '. g:signify_mapping_toggle .' :SignifyToggle<cr>'
|
|
|
|
else
|
|
|
|
nnoremap <silent> <leader>gt :SignifyToggle<cr>
|
|
|
|
endif
|
|
|
|
|
2013-07-17 06:44:21 -04:00
|
|
|
" vim: et sw=2 sts=2
|