From d41bb862432ad50934b3243f0a27c5308cb3491d Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 4 Apr 2013 11:14:07 +0200 Subject: [PATCH] new option: g:signify_line_highlight You can enable line highlighting per default now. --- README.md | 2 ++ doc/signify.txt | 5 ++++ plugin/signify.vim | 64 +++++++++++++++++++++++++++++----------------- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 114388d..dd9cc12 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,8 @@ let g:signify_sign_overwrite = 1 let g:signify_update_on_bufenter = 1 +let g:signify_line_highlight = 1 + let g:signify_sign_add = '+' let g:signify_sign_delete = '-' let g:signify_sign_change = '*' diff --git a/doc/signify.txt b/doc/signify.txt index c6a0435..fd6ff27 100644 --- a/doc/signify.txt +++ b/doc/signify.txt @@ -135,6 +135,11 @@ NOTE: Disable this if you're working in huge repositories and experience delays. + let g:signify_line_highlight = 1 + +Enable line highlighting in addation to using signs. + + let g:signify_sign_add = '+' let g:signify_sign_change = '*' let g:signify_sign_change_delete = '!_' diff --git a/plugin/signify.vim b/plugin/signify.vim index 54ad6df..93ecb5b 100644 --- a/plugin/signify.vim +++ b/plugin/signify.vim @@ -10,7 +10,6 @@ let g:loaded_signify = 1 " Init: values {{{1 let s:sy = {} " the main data structure -let s:line_highlight = 0 " disable line highlighting let s:other_signs_line_numbers = {} " overwrite non-signify signs by default @@ -100,7 +99,7 @@ augroup END " Init: commands {{{1 com! -nargs=0 -bar SignifyToggle call s:toggle_signify() -com! -nargs=0 -bar SignifyToggleHighlight call s:toggle_line_highlighting() +com! -nargs=0 -bar SignifyToggleHighlight call s:line_highlighting_toggle() com! -nargs=0 -bar -count SignifyJumpToNextHunk call s:jump_to_next_hunk() com! -nargs=0 -bar -count SignifyJumpToPrevHunk call s:jump_to_prev_hunk() @@ -172,6 +171,14 @@ function! s:start(path) abort let s:sy[a:path].last_jump_was_next = -1 endif + if !exists('s:line_highlight') + if get(g:, 'signify_line_highlight') + call s:line_highlighting_enable() + else + call s:line_highlighting_disable() + endif + endif + if !s:sign_overwrite call s:sign_get_others(a:path) endif @@ -467,34 +474,45 @@ function! s:toggle_signify() abort endif endfunction -" Function: s:toggle_line_highlighting {{{1 -function! s:toggle_line_highlighting() abort +" Function: s:line_highlighting_enable {{{1 +function! s:line_highlighting_enable() abort + let add = get(g:, 'signify_line_color_add', 'DiffAdd') + let delete = get(g:, 'signify_line_color_delete', 'DiffDelete') + let change = get(g:, 'signify_line_color_change', 'DiffChange') + + execute 'sign define SignifyAdd text=+ texthl=SignifyAdd linehl='. add + execute 'sign define SignifyChange text=! texthl=SignifyChange linehl='. change + execute 'sign define SignifyChangeDelete text=!_ texthl=SignifyChange linehl='. change + execute 'sign define SignifyDelete text=_ texthl=SignifyDelete linehl='. delete + execute 'sign define SignifyDeleteFirstLine text=‾ texthl=SignifyDelete linehl='. delete + + let s:line_highlight = 1 +endfunction + +" Function: s:line_highlighting_disable {{{1 +function! s:line_highlighting_disable() abort + sign define SignifyAdd text=+ texthl=SignifyAdd linehl=none + sign define SignifyChange text=! texthl=SignifyChange linehl=none + sign define SignifyChangeDelete text=!_ texthl=SignifyChange linehl=none + sign define SignifyDelete text=_ texthl=SignifyDelete linehl=none + sign define SignifyDeleteFirstLine text=‾ texthl=SignifyDelete linehl=none + + let s:line_highlight = 0 +endfunction + +" Function: s:line_highlighting_toggle {{{1 +function! s:line_highlighting_toggle() abort if !has_key(s:sy, s:path) echo 'signify: I cannot detect any changes!' return endif if s:line_highlight - sign define SignifyAdd text=+ texthl=SignifyAdd linehl=none - sign define SignifyChange text=! texthl=SignifyChange linehl=none - sign define SignifyChangeDelete text=!_ texthl=SignifyChange linehl=none - sign define SignifyDelete text=_ texthl=SignifyDelete linehl=none - sign define SignifyDeleteFirstLine text=‾ texthl=SignifyDelete linehl=none - - let s:line_highlight = 0 + call s:line_highlighting_disable() else - let add = get(g:, 'signify_line_color_add', 'DiffAdd') - let delete = get(g:, 'signify_line_color_delete', 'DiffDelete') - let change = get(g:, 'signify_line_color_change', 'DiffChange') - - execute 'sign define SignifyAdd text=+ texthl=SignifyAdd linehl='. add - execute 'sign define SignifyChange text=! texthl=SignifyChange linehl='. change - execute 'sign define SignifyChangeDelete text=!_ texthl=SignifyChange linehl='. change - execute 'sign define SignifyDelete text=_ texthl=SignifyDelete linehl='. delete - execute 'sign define SignifyDeleteFirstLine text=‾ texthl=SignifyDelete linehl='. delete - - let s:line_highlight = 1 + call s:line_highlighting_enable() endif + call s:start(s:path) endfunction @@ -560,7 +578,7 @@ function s:escape(path) abort return path endfunction -" Function: SignifyDebugListActiveBuffers() {{{1 +" Function: SignifyDebugListActiveBuffers {{{1 function! SignifyDebugListActiveBuffers() abort if empty(s:sy) echo 'No active buffers!'