Improve get synID.

This commit is contained in:
manga_osyo
2017-12-14 14:59:46 +09:00
parent f30100d07e
commit 717682eda8
2 changed files with 24 additions and 4 deletions

View File

@@ -20,12 +20,19 @@ let g:brightest#ignore_word_pattern = get(g:, "brightest#ignore_word_pattern", "
function! s:context() function! s:context()
return { let context = {
\ "filetype" : &filetype, \ "filetype" : &filetype,
\ "line" : line("."), \ "line" : line("."),
\ "col" : col("."), \ "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 endfunction
@@ -280,7 +287,8 @@ endfunction
let g:brightest#enable_clear_highlight_on_CursorMoved = get(g:, "brightest#enable_clear_highlight_on_CursorMoved", 1) 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 s:is_CursorMoved = 1
let mode = mode() let mode = mode()
@@ -299,6 +307,16 @@ function! brightest#on_CursorMoved()
endif endif
endfunction 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 let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo

View File

@@ -127,7 +127,9 @@ b:brightest_highlight_in_cursorline *b:brightest_highlight_in_cursorline*
g:brightest#ignore_syntax_list *g:brightest#ignore_syntax_list* g:brightest#ignore_syntax_list *g:brightest#ignore_syntax_list*
ハイライトを行わないシンタックス名のリストです。 ハイライトを行わないシンタックス名のリストです。
ここで設定したシンタックス上にカーソルがある場合はハイライトしません。 ここで設定したシンタックス上にカーソルがある場合はハイライトしません。
NOTE:|g:brightest#pattern|を設定していない場合、カーソル上以外の単語がハイライトされるのでこの機能が正しく動作しない可能性があります。 NOTE: |g:brightest#pattern|を設定していない場合、カーソル上以外の単語がハイライトされるのでこの機能が正しく動作しない可能性があります。
NOTE: このオプションが設定されている場合パフォーマンスが遅くなる場合が
あります。
Default: > Default: >
let g:brightest#ignore_syntax_list = [] let g:brightest#ignore_syntax_list = []
< <