Put hl group linking into a function
This commit is contained in:
parent
abdd63063c
commit
16359f44f2
@ -45,14 +45,6 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
highlight link SignifyLineAdd DiffAdd
|
|
||||||
highlight link SignifyLineChange DiffChange
|
|
||||||
highlight link SignifyLineDelete DiffDelete
|
|
||||||
|
|
||||||
highlight link SignifySignAdd DiffAdd
|
|
||||||
highlight link SignifySignChange DiffChange
|
|
||||||
highlight link SignifySignDelete DiffDelete
|
|
||||||
|
|
||||||
sign define SignifyPlaceholder text=. texthl=SignifySignChange linehl=NONE
|
sign define SignifyPlaceholder text=. texthl=SignifySignChange linehl=NONE
|
||||||
|
|
||||||
" Init: autocmds {{{1
|
" Init: autocmds {{{1
|
||||||
@ -61,6 +53,7 @@ augroup signify
|
|||||||
|
|
||||||
autocmd BufRead,BufEnter * let s:path = resolve(expand('<afile>:p'))
|
autocmd BufRead,BufEnter * let s:path = resolve(expand('<afile>:p'))
|
||||||
autocmd BufRead,BufWritePost * call s:start(s:path)
|
autocmd BufRead,BufWritePost * call s:start(s:path)
|
||||||
|
autocmd Colorscheme,BufEnter * call s:highlight_setup()
|
||||||
|
|
||||||
if get(g:, 'signify_update_on_bufenter')
|
if get(g:, 'signify_update_on_bufenter')
|
||||||
autocmd BufEnter * nested
|
autocmd BufEnter * nested
|
||||||
@ -96,8 +89,8 @@ augroup signify
|
|||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Init: commands {{{1
|
" Init: commands {{{1
|
||||||
com! -nargs=0 -bar SignifyToggle call s:toggle_signify()
|
com! -nargs=0 -bar SignifyToggle call s:toggle()
|
||||||
com! -nargs=0 -bar SignifyToggleHighlight call s:line_highlighting_toggle()
|
com! -nargs=0 -bar SignifyToggleHighlight call s:highlight_line_toggle()
|
||||||
com! -nargs=0 -bar -count SignifyJumpToNextHunk call s:jump_to_next_hunk(<count>)
|
com! -nargs=0 -bar -count SignifyJumpToNextHunk call s:jump_to_next_hunk(<count>)
|
||||||
com! -nargs=0 -bar -count SignifyJumpToPrevHunk call s:jump_to_prev_hunk(<count>)
|
com! -nargs=0 -bar -count SignifyJumpToPrevHunk call s:jump_to_prev_hunk(<count>)
|
||||||
|
|
||||||
@ -126,26 +119,6 @@ else
|
|||||||
nnoremap <silent> <leader>gt :SignifyToggle<cr>
|
nnoremap <silent> <leader>gt :SignifyToggle<cr>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Function: s:toggle_signify {{{1
|
|
||||||
function! s:toggle_signify() abort
|
|
||||||
if empty(s:path)
|
|
||||||
echomsg 'signify: I cannot sy empty buffers!'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if has_key(s:sy, s:path)
|
|
||||||
if s:sy[s:path].active
|
|
||||||
call s:stop(s:path)
|
|
||||||
let s:sy[s:path].active = 0
|
|
||||||
else
|
|
||||||
let s:sy[s:path].active = 1
|
|
||||||
call s:start(s:path)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
call s:start(s:path)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:start {{{1
|
" Function: s:start {{{1
|
||||||
function! s:start(path) abort
|
function! s:start(path) abort
|
||||||
if !filereadable(a:path)
|
if !filereadable(a:path)
|
||||||
@ -180,9 +153,9 @@ function! s:start(path) abort
|
|||||||
|
|
||||||
if !exists('s:line_highlight')
|
if !exists('s:line_highlight')
|
||||||
if get(g:, 'signify_line_highlight')
|
if get(g:, 'signify_line_highlight')
|
||||||
call s:line_highlighting_enable()
|
call s:highlight_line_enable()
|
||||||
else
|
else
|
||||||
call s:line_highlighting_disable()
|
call s:highlight_line_disable()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -219,6 +192,26 @@ function! s:stop(path) abort
|
|||||||
augroup END
|
augroup END
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: s:toggle {{{1
|
||||||
|
function! s:toggle() abort
|
||||||
|
if empty(s:path)
|
||||||
|
echomsg 'signify: I cannot sy empty buffers!'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if has_key(s:sy, s:path)
|
||||||
|
if s:sy[s:path].active
|
||||||
|
call s:stop(s:path)
|
||||||
|
let s:sy[s:path].active = 0
|
||||||
|
else
|
||||||
|
let s:sy[s:path].active = 1
|
||||||
|
call s:start(s:path)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
call s:start(s:path)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Function: s:sign_get_others {{{1
|
" Function: s:sign_get_others {{{1
|
||||||
function! s:sign_get_others(path) abort
|
function! s:sign_get_others(path) abort
|
||||||
redir => signlist
|
redir => signlist
|
||||||
@ -430,9 +423,18 @@ function! s:repo_process_diff(path, diff) abort
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: s:highlight_setup {{{1
|
||||||
|
function! s:highlight_setup() abort
|
||||||
|
highlight link SignifyLineAdd DiffAdd
|
||||||
|
highlight link SignifyLineChange DiffChange
|
||||||
|
highlight link SignifyLineDelete DiffDelete
|
||||||
|
highlight link SignifySignAdd DiffAdd
|
||||||
|
highlight link SignifySignChange DiffChange
|
||||||
|
highlight link SignifySignDelete DiffDelete
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Function: s:line_highlighting_enable {{{1
|
" Function: s:highlight_line_enable {{{1
|
||||||
function! s:line_highlighting_enable() abort
|
function! s:highlight_line_enable() abort
|
||||||
execute 'sign define SignifyAdd text='. s:sign_add ' texthl=SignifySignAdd linehl=SignifyLineAdd'
|
execute 'sign define SignifyAdd text='. s:sign_add ' texthl=SignifySignAdd linehl=SignifyLineAdd'
|
||||||
execute 'sign define SignifyChange text='. s:sign_change ' texthl=SignifySignChange linehl=SignifyLineChange'
|
execute 'sign define SignifyChange text='. s:sign_change ' texthl=SignifySignChange linehl=SignifyLineChange'
|
||||||
execute 'sign define SignifyChangeDelete text='. s:sign_change_delete .' texthl=SignifySignChange linehl=SignifyLineChange'
|
execute 'sign define SignifyChangeDelete text='. s:sign_change_delete .' texthl=SignifySignChange linehl=SignifyLineChange'
|
||||||
@ -451,8 +453,8 @@ function! s:line_highlighting_enable() abort
|
|||||||
let s:line_highlight = 1
|
let s:line_highlight = 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:line_highlighting_disable {{{1
|
" Function: s:highlight_line_disable {{{1
|
||||||
function! s:line_highlighting_disable() abort
|
function! s:highlight_line_disable() abort
|
||||||
execute 'sign define SignifyAdd text='. s:sign_add ' texthl=SignifySignAdd linehl=none'
|
execute 'sign define SignifyAdd text='. s:sign_add ' texthl=SignifySignAdd linehl=none'
|
||||||
execute 'sign define SignifyChange text='. s:sign_change ' texthl=SignifySignChange linehl=none'
|
execute 'sign define SignifyChange text='. s:sign_change ' texthl=SignifySignChange linehl=none'
|
||||||
execute 'sign define SignifyChangeDelete text='. s:sign_change_delete .' texthl=SignifySignChange linehl=none'
|
execute 'sign define SignifyChangeDelete text='. s:sign_change_delete .' texthl=SignifySignChange linehl=none'
|
||||||
@ -471,17 +473,17 @@ function! s:line_highlighting_disable() abort
|
|||||||
let s:line_highlight = 0
|
let s:line_highlight = 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:line_highlighting_toggle {{{1
|
" Function: s:highlight_line_toggle {{{1
|
||||||
function! s:line_highlighting_toggle() abort
|
function! s:highlight_line_toggle() abort
|
||||||
if !has_key(s:sy, s:path)
|
if !has_key(s:sy, s:path)
|
||||||
echomsg 'signify: I cannot detect any changes!'
|
echomsg 'signify: I cannot detect any changes!'
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if s:line_highlight
|
if s:line_highlight
|
||||||
call s:line_highlighting_disable()
|
call s:highlight_line_disable()
|
||||||
else
|
else
|
||||||
call s:line_highlighting_enable()
|
call s:highlight_line_enable()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:start(s:path)
|
call s:start(s:path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user