parent
de297820bc
commit
bd0956eee6
@ -48,3 +48,30 @@ function! sy#util#refresh_windows() abort
|
|||||||
windo if exists('b:sy') | call sy#start() | endif
|
windo if exists('b:sy') | call sy#start() | endif
|
||||||
execute winnr .'wincmd w'
|
execute winnr .'wincmd w'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: #hunk_text_object {{{1
|
||||||
|
function! sy#util#hunk_text_object(emptylines) abort
|
||||||
|
if !exists('b:sy')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let lnum = line('.')
|
||||||
|
let hunks = filter(copy(b:sy.hunks), 'v:val.start <= lnum && v:val.end >= lnum')
|
||||||
|
|
||||||
|
if empty(hunks)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
execute hunks[0].start
|
||||||
|
normal! V
|
||||||
|
|
||||||
|
if a:emptylines
|
||||||
|
let lnum = hunks[0].end
|
||||||
|
while getline(lnum+1) =~ '^$'
|
||||||
|
let lnum += 1
|
||||||
|
endwhile
|
||||||
|
execute lnum
|
||||||
|
else
|
||||||
|
execute hunks[0].end
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
123
doc/signify.txt
123
doc/signify.txt
@ -33,9 +33,8 @@ TOC *signify-contents*
|
|||||||
OPTIONS ........................ |signify-options|
|
OPTIONS ........................ |signify-options|
|
||||||
COMMANDS ....................... |signify-commands|
|
COMMANDS ....................... |signify-commands|
|
||||||
MAPPINGS ....................... |signify-mappings|
|
MAPPINGS ....................... |signify-mappings|
|
||||||
FUNCTIONS ...................... |signify-functions|
|
|
||||||
OBJECTS ........................ |signify-objects|
|
|
||||||
COLORS ......................... |signify-colors|
|
COLORS ......................... |signify-colors|
|
||||||
|
EXAMPLE ........................ |signify-example|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
INTRO *signify-intro*
|
INTRO *signify-intro*
|
||||||
@ -90,10 +89,6 @@ All available options:~
|
|||||||
|
|
||||||
|g:signify_vcs_list|
|
|g:signify_vcs_list|
|
||||||
|g:signify_disable_by_default|
|
|g:signify_disable_by_default|
|
||||||
|g:signify_mapping_next_hunk|
|
|
||||||
|g:signify_mapping_prev_hunk|
|
|
||||||
|g:signify_mapping_toggle_highlight|
|
|
||||||
|g:signify_mapping_toggle|
|
|
||||||
|g:signify_skip_filetype|
|
|g:signify_skip_filetype|
|
||||||
|g:signify_skip_filename|
|
|g:signify_skip_filename|
|
||||||
|g:signify_update_on_bufenter|
|
|g:signify_update_on_bufenter|
|
||||||
@ -152,40 +147,8 @@ VCS will be tested for.
|
|||||||
>
|
>
|
||||||
let g:signify_disable_by_default = 0
|
let g:signify_disable_by_default = 0
|
||||||
<
|
<
|
||||||
Don't run Sy by default. You can toggle it anytime via :SignifyToggle.
|
This loads Sy, but it won't look for changes. You can toggle it anytime via
|
||||||
|
:SignifyToggle.
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*g:signify_mapping_next_hunk*
|
|
||||||
*g:signify_mapping_prev_hunk*
|
|
||||||
>
|
|
||||||
let g:signify_mapping_next_hunk = '<leader>gj'
|
|
||||||
let g:signify_mapping_prev_hunk = '<leader>gk'
|
|
||||||
<
|
|
||||||
Mapping for jumping to the start of the next or previous hunk.
|
|
||||||
|
|
||||||
Alternatively, you can also map it yourself:
|
|
||||||
>
|
|
||||||
nmap <leader>gj <plug>(signify-next-hunk)
|
|
||||||
nmap <leader>gk <plug>(signify-prev-hunk)
|
|
||||||
<
|
|
||||||
There is no difference between both variants.
|
|
||||||
|
|
||||||
NOTE: Analog to Vim's diff mode, you can also use |]c| and |[c| for jumping
|
|
||||||
between hunks.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*g:signify_mapping_toggle_highlight*
|
|
||||||
>
|
|
||||||
let g:signify_mapping_toggle_highlight = '<leader>gh'
|
|
||||||
<
|
|
||||||
Mapping for toggling line highlighting for lines containing changes.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*g:signify_mapping_toggle*
|
|
||||||
>
|
|
||||||
let g:signify_mapping_toggle = '<leader>gt'
|
|
||||||
<
|
|
||||||
Mapping for toggling the plugin for the current buffer only.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*g:signify_skip_filetype*
|
*g:signify_skip_filetype*
|
||||||
@ -294,55 +257,61 @@ Default: Does not exist.
|
|||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
COMMAND *signify-commands*
|
COMMAND *signify-commands*
|
||||||
MAPPINGS *signify-mappings*
|
*signify-:SignifyToggle*
|
||||||
>
|
>
|
||||||
:SignifyToggle
|
:SignifyToggle
|
||||||
<
|
<
|
||||||
Toggle the plugin for the current buffer only.
|
Toggle the plugin for the current buffer only.
|
||||||
Default mapping: <leader>gt
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
*signify-:SignifyToggleHighlight*
|
||||||
>
|
>
|
||||||
:SignifyToggleHighlight
|
:SignifyToggleHighlight
|
||||||
<
|
<
|
||||||
Toggle line highlighting for lines containing changes.
|
Toggle line highlighting for lines containing changes.
|
||||||
Default mapping: <leader>gh
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
FUNCTIONS *signify-functions*
|
|
||||||
|
|
||||||
Signify exposes some functions which you can use to customize its behavior.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*signify-#refresh_windows()*
|
*signify-:SignifyRefresh*
|
||||||
|
|
||||||
This function updates signs for all windows. For example, to update signs when
|
|
||||||
Vim loses focus, you use:
|
|
||||||
>
|
>
|
||||||
autocmd FocusLost * call sy#util#refresh_windows()
|
:SignifyRefresh
|
||||||
<
|
<
|
||||||
|
Refresh signs in all windows.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*signify-:SignifyDebug*
|
||||||
|
>
|
||||||
|
:SignifyDebug
|
||||||
|
<
|
||||||
|
Outputs debug info for all managed buffers.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
OBJECTS *signify-objects*
|
MAPPINGS *signify-mappings*
|
||||||
|
|
||||||
Sy also provides text objects that operate on the current hunk:
|
There are no default mappings, except for ]c / [c, but there are additional
|
||||||
|
plug mappings available that you can put into your vimrc.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Hunk jumping:~
|
||||||
>
|
>
|
||||||
ic
|
nmap <leader>gj <plug>(signify-next-hunk)
|
||||||
>
|
nmap <leader>gk <plug>(signify-prev-hunk)
|
||||||
Operate on all the lines of the current hunk.
|
|
||||||
>
|
|
||||||
ac
|
|
||||||
<
|
<
|
||||||
Does the same as ic and also removes all trailing empty lines.
|
NOTE: Analog to Vim's diff mode, you can also use |]c| and |[c| for
|
||||||
|
jumping between hunks.
|
||||||
|
|
||||||
NOTE: Don't be surprised that this also works with "deleted lines".
|
------------------------------------------------------------------------------
|
||||||
|
Hunk text object:~
|
||||||
Map hunk text objects like this:
|
|
||||||
>
|
>
|
||||||
omap ic <plug>(signify-motion-inner-pending)
|
omap ic <plug>(signify-motion-inner-pending)
|
||||||
xmap ic <plug>(signify-motion-inner-visual)
|
xmap ic <plug>(signify-motion-inner-visual)
|
||||||
omap ac <plug>(signify-motion-outer-pending)
|
omap ac <plug>(signify-motion-outer-pending)
|
||||||
xmap ac <plug>(signify-motion-outer-visual)
|
xmap ac <plug>(signify-motion-outer-visual)
|
||||||
<
|
<
|
||||||
|
"ic" operates on all lines of the current hunk. "ac" does the same, but also
|
||||||
|
removes all trailing empty lines.
|
||||||
|
|
||||||
|
NOTE: Don't be surprised that this also works with "deleted lines".
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
COLORS *signify-colors*
|
COLORS *signify-colors*
|
||||||
|
|
||||||
@ -384,5 +353,31 @@ For Unix people there is a small script, showcolors.bash, in the repo that
|
|||||||
shows all 256 colors available to the terminal. That makes picking the right
|
shows all 256 colors available to the terminal. That makes picking the right
|
||||||
numbers much easier.
|
numbers much easier.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
EXAMPLE *signify-example*
|
||||||
|
|
||||||
|
An example configuration for Sy:
|
||||||
|
>
|
||||||
|
let g:signify_vcs_list = [ 'git', 'hg' ]
|
||||||
|
let g:signify_cursorhold_insert = 1
|
||||||
|
let g:signify_cursorhold_normal = 1
|
||||||
|
let g:signify_update_on_bufenter = 0
|
||||||
|
let g:signify_update_on_focusgained = 1
|
||||||
|
|
||||||
|
nnoremap <leader>gt SignifyToggle
|
||||||
|
nnoremap <leader>gh SignifyToggleHighlight
|
||||||
|
nnoremap <leader>gr SignifyRefresh
|
||||||
|
nnoremap <leader>gd SignifyDebug
|
||||||
|
|
||||||
|
" hunk jumping
|
||||||
|
nmap <leader>gj <plug>(signify-next-hunk)
|
||||||
|
nmap <leader>gk <plug>(signify-prev-hunk)
|
||||||
|
|
||||||
|
" hunk text object
|
||||||
|
omap ic <plug>(signify-motion-inner-pending)
|
||||||
|
xmap ic <plug>(signify-motion-inner-visual)
|
||||||
|
omap ac <plug>(signify-motion-outer-pending)
|
||||||
|
xmap ac <plug>(signify-motion-outer-visual)
|
||||||
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
vim: tw=78
|
vim: tw=78
|
||||||
|
@ -7,10 +7,12 @@ if exists('g:loaded_signify') || !has('signs') || &compatible
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Init: values {{{1
|
" Init: values {{{1
|
||||||
|
|
||||||
let g:loaded_signify = 1
|
let g:loaded_signify = 1
|
||||||
let g:signify_locked = 0
|
let g:signify_locked = 0
|
||||||
|
|
||||||
" Init: autocmds {{{1
|
" Init: autocmds {{{1
|
||||||
|
|
||||||
augroup signify
|
augroup signify
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
@ -31,33 +33,26 @@ augroup signify
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if get(g:, 'signify_update_on_focusgained') && !has('gui_win32')
|
if get(g:, 'signify_update_on_focusgained') && !has('gui_win32')
|
||||||
autocmd FocusGained * call sy#util#refresh_windows()
|
autocmd FocusGained * call SignifyRefresh
|
||||||
endif
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Init: commands {{{1
|
" Init: commands {{{1
|
||||||
com! -nargs=0 -bar SignifyToggle call sy#toggle()
|
|
||||||
com! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle()
|
command! -nargs=0 -bar SignifyDebug call sy#debug#list_active_buffers()
|
||||||
com! -nargs=0 -bar SyDebug 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()
|
||||||
|
|
||||||
" Init: mappings {{{1
|
" Init: mappings {{{1
|
||||||
nnoremap <silent> <plug>(signify-toggle) :<c-u>call sy#toggle()<cr>
|
|
||||||
nnoremap <silent> <plug>(signify-toggle-highlight) :<c-u>call sy#highlight#line_toggle()<cr>
|
|
||||||
|
|
||||||
if exists('g:signify_mapping_toggle')
|
|
||||||
execute 'nmap '. g:signify_mapping_toggle .' <plug>(signify-toggle)'
|
|
||||||
elseif !hasmapto('<plug>(signify-toggle)') && empty(maparg('<leader>gt', 'n'))
|
|
||||||
nmap <leader>gt <plug>(signify-toggle)
|
|
||||||
endif
|
|
||||||
if exists('g:signify_mapping_toggle_highlight')
|
|
||||||
execute 'nmap '. g:signify_mapping_toggle_highlight .' <plug>(signify-toggle-highlight)'
|
|
||||||
elseif !hasmapto('<plug>(signify-toggle-highlight)') && empty(maparg('<leader>gh', 'n'))
|
|
||||||
nmap <leader>gh <plug>(signify-toggle-highlight)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" hunk jumping
|
" 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-next-hunk) &diff
|
||||||
nnoremap <silent> <expr> <plug>(signify-prev-hunk) &diff ? '[c' : ":\<c-u>call sy#jump#prev_hunk(v:count1)\<cr>"
|
\ ? ']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'))
|
if empty(maparg(']c', 'n'))
|
||||||
nmap ]c <plug>(signify-next-hunk)
|
nmap ]c <plug>(signify-next-hunk)
|
||||||
@ -65,66 +60,17 @@ endif
|
|||||||
if empty(maparg('[c', 'n'))
|
if empty(maparg('[c', 'n'))
|
||||||
nmap [c <plug>(signify-prev-hunk)
|
nmap [c <plug>(signify-prev-hunk)
|
||||||
endif
|
endif
|
||||||
if exists('g:signify_mapping_next_hunk')
|
|
||||||
execute 'nmap '. g:signify_mapping_next_hunk .' <plug>(signify-next-hunk)'
|
|
||||||
elseif !hasmapto('<plug>(signify-next-hunk)') && empty(maparg('<leader>gj', 'n'))
|
|
||||||
nmap <leader>gj <plug>(signify-next-hunk)
|
|
||||||
endif
|
|
||||||
if exists('g:signify_mapping_prev_hunk')
|
|
||||||
execute 'nmap '. g:signify_mapping_prev_hunk .' <plug>(signify-prev-hunk)'
|
|
||||||
elseif !hasmapto('<plug>(signify-prev-hunk)') && empty(maparg('<leader>gk', 'n'))
|
|
||||||
nmap <leader>gk <plug>(signify-prev-hunk)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" hunk text object
|
" hunk text object
|
||||||
onoremap <silent> <plug>(signify-motion-inner-pending) :<c-u>call <sid>hunk_text_object(0)<cr>
|
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 <sid>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 <sid>hunk_text_object(1)<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 <sid>hunk_text_object(1)<cr>
|
xnoremap <silent> <plug>(signify-motion-outer-visual) :<c-u>call sy#util#hunk_text_object(1)<cr>
|
||||||
|
|
||||||
if !hasmapto('<plug>(signify-motion-inner-pending)') && empty(maparg('ic', 'o'))
|
|
||||||
omap ic <plug>(signify-motion-inner-pending)
|
|
||||||
endif
|
|
||||||
if !hasmapto('<plug>(signify-motion-inner-visual)') && empty(maparg('ic', 'v'))
|
|
||||||
xmap ic <plug>(signify-motion-inner-visual)
|
|
||||||
endif
|
|
||||||
if !hasmapto('<plug>(signify-motion-outer-pending)') && empty(maparg('ac', 'o'))
|
|
||||||
omap ac <plug>(signify-motion-outer-pending)
|
|
||||||
endif
|
|
||||||
if !hasmapto('<plug>(signify-motion-outer-visual)') && empty(maparg('ac', 'v'))
|
|
||||||
xmap ac <plug>(signify-motion-outer-visual)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Function: save {{{1
|
" Function: save {{{1
|
||||||
|
|
||||||
function! s:save()
|
function! s:save()
|
||||||
if exists('b:sy') && b:sy.active && &modified
|
if exists('b:sy') && b:sy.active && &modified
|
||||||
write
|
write
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: hunk_text_object {{{1
|
|
||||||
function! s:hunk_text_object(emptylines) abort
|
|
||||||
if !exists('b:sy')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let lnum = line('.')
|
|
||||||
let hunks = filter(copy(b:sy.hunks), 'v:val.start <= lnum && v:val.end >= lnum')
|
|
||||||
|
|
||||||
if empty(hunks)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
execute hunks[0].start
|
|
||||||
normal! V
|
|
||||||
|
|
||||||
if a:emptylines
|
|
||||||
let lnum = hunks[0].end
|
|
||||||
while getline(lnum+1) =~ '^$'
|
|
||||||
let lnum += 1
|
|
||||||
endwhile
|
|
||||||
execute lnum
|
|
||||||
else
|
|
||||||
execute hunks[0].end
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user