From 717682eda87a4b9a19720b01ef5b09c339e3412c Mon Sep 17 00:00:00 2001 From: manga_osyo Date: Thu, 14 Dec 2017 14:59:46 +0900 Subject: [PATCH] Improve get synID. --- autoload/brightest.vim | 24 +++++++++++++++++++++--- doc/brightest.jax | 4 +++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/autoload/brightest.vim b/autoload/brightest.vim index 5cc0260..49c33d4 100644 --- a/autoload/brightest.vim +++ b/autoload/brightest.vim @@ -20,12 +20,19 @@ let g:brightest#ignore_word_pattern = get(g:, "brightest#ignore_word_pattern", " function! s:context() - return { + let context = { \ "filetype" : &filetype, \ "line" : line("."), \ "col" : col("."), -\ "syntax_name" : synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name") +\ "syntax_name" : "", \ } + + " パフォーマンスを上げるために g:brightest#ignore_syntax_list が設定されている場合のみ + " シンタックス名を設定する + if !empty(g:brightest#ignore_syntax_list) + let context.syntax_name = synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name") + endif + return context endfunction @@ -280,7 +287,8 @@ endfunction let g:brightest#enable_clear_highlight_on_CursorMoved = get(g:, "brightest#enable_clear_highlight_on_CursorMoved", 1) -function! brightest#on_CursorMoved() + +function! s:on_CursorMoved() let s:is_CursorMoved = 1 let mode = mode() @@ -299,6 +307,16 @@ function! brightest#on_CursorMoved() endif endfunction +function! brightest#on_CursorMoved() + try + call s:on_CursorMoved() + catch /.*/ + echohl Error | echo "Error: Brightest CursorMoved " . v:exception | echohl NONE + endtry +endfunction + + + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/doc/brightest.jax b/doc/brightest.jax index 6c2927b..3c5f634 100644 --- a/doc/brightest.jax +++ b/doc/brightest.jax @@ -127,7 +127,9 @@ b:brightest_highlight_in_cursorline *b:brightest_highlight_in_cursorline* g:brightest#ignore_syntax_list *g:brightest#ignore_syntax_list* ハイライトを行わないシンタックス名のリストです。 ここで設定したシンタックス上にカーソルがある場合はハイライトしません。 - NOTE:|g:brightest#pattern|を設定していない場合、カーソル上以外の単語がハイライトされるのでこの機能が正しく動作しない可能性があります。 + NOTE: |g:brightest#pattern|を設定していない場合、カーソル上以外の単語がハイライトされるのでこの機能が正しく動作しない可能性があります。 + NOTE: このオプションが設定されている場合パフォーマンスが遅くなる場合が + あります。 Default: > let g:brightest#ignore_syntax_list = [] <