diff --git a/autoload/brightest.vim b/autoload/brightest.vim index 5162dc1..b737415 100644 --- a/autoload/brightest.vim +++ b/autoload/brightest.vim @@ -214,6 +214,27 @@ function! brightest#define_cursorline_highlight_group(group) endfunction +function! s:is_enable() + return g:brightest_enable && get(b:, "brightest_enable", 1) +endfunction + +let g:brightest#enable_on_CursorHold = get(g:, "brightest#enable_cursorhold", 0) + +function! brightest#on_CursorHold() + if s:is_enable() && g:brightest#enable_on_CursorHold + call brightest#highlighting() + endif +endfunction + +function! brightest#on_CursorMoved() + if g:brightest#enable_on_CursorHold + call brightest#hl_clear() + endif + if s:is_enable() && !g:brightest#enable_on_CursorHold + call brightest#highlighting() + endif +endfunction + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/doc/brightest.jax b/doc/brightest.jax index 88e8b85..a595c80 100644 --- a/doc/brightest.jax +++ b/doc/brightest.jax @@ -150,6 +150,13 @@ b:brightest_ignore_word_pattern *b:brightest_ignore_word_pattern* g:brightest#ignore_word_pattern のバッファローカル版です。 g:brightest#ignore_word_pattern よりも優先して使用されます。 +g:brightest#enable_on_CursorHold *g:brightest#enable_on_CursorHold* + 1 が設定されている場合 |CursorMoved| ではなくて |CursorHold| + 時にハイライトを行うようになります。 + カーソル移動が遅く感じる場合はこの変数に 1 を設定してください。 +Default: > + let g:brightest#enable_on_CursorHold = 0 +< ============================================================================== ハイライトグループ *brightest-highlight_group* @@ -221,7 +228,7 @@ A. |g:brightest#highlight| の "group" に |BrightestUnderline|、もしくは Q. ハイライトの背景を 'cursorline' と同じにしたい -A. g:brightest#highlight_in_cursorline| の "group" に +A. g:brightest#highlight_in_cursorline| の "group" に |BrightestCursorLineBg| を設定することでカーソル行のハイライトの背景が 'cursorline' と同じになります。 > @@ -231,7 +238,12 @@ A. g:brightest#highlight_in_cursorline| の "group" に \} < +Q. カーソル移動が重いので CursorHold 時にハイライトしたい +A. g:brightest#enable_on_CursorHold に 1 を設定します。 +> + let g:brightest#enable_on_CursorHold = 1 +< ============================================================================== diff --git a/plugin/brightest.vim b/plugin/brightest.vim index 3f45748..fa30009 100644 --- a/plugin/brightest.vim +++ b/plugin/brightest.vim @@ -36,7 +36,9 @@ endfunction augroup brightest autocmd! - autocmd CursorMoved * call s:highlight() +" autocmd CursorMoved * call s:highlight() + autocmd CursorMoved * call brightest#on_CursorMoved() + autocmd CursorHold * call brightest#on_CursorHold() autocmd BufLeave,WinLeave,InsertEnter * call brightest#hl_clear() autocmd ColorScheme * call s:init_hl() augroup END