Add g:brightest#enable_on_CursorHold option Ref #3.

This commit is contained in:
manga_osyo
2014-10-29 21:02:39 +09:00
parent afc1f0380f
commit 6f0c14e169
3 changed files with 37 additions and 2 deletions

View File

@@ -214,6 +214,27 @@ function! brightest#define_cursorline_highlight_group(group)
endfunction 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 let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo

View File

@@ -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#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* ハイライトグループ *brightest-highlight_group*
@@ -221,7 +228,7 @@ A. |g:brightest#highlight| の "group" に |BrightestUnderline|、もしくは
Q. ハイライトの背景を 'cursorline' と同じにしたい Q. ハイライトの背景を 'cursorline' と同じにしたい
A. g:brightest#highlight_in_cursorline| の "group" に A. g:brightest#highlight_in_cursorline| の "group" に
|BrightestCursorLineBg| を設定することでカーソル行のハイライトの背景が |BrightestCursorLineBg| を設定することでカーソル行のハイライトの背景が
'cursorline' と同じになります。 '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
<
============================================================================== ==============================================================================

View File

@@ -36,7 +36,9 @@ endfunction
augroup brightest augroup brightest
autocmd! 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 BufLeave,WinLeave,InsertEnter * call brightest#hl_clear()
autocmd ColorScheme * call s:init_hl() autocmd ColorScheme * call s:init_hl()
augroup END augroup END