mirror of
https://github.com/osyo-manga/vim-brightest.git
synced 2025-11-15 06:53:52 -05:00
Change option name.
This commit is contained in:
@@ -16,13 +16,14 @@ BrightestEnable
|
|||||||
BrightestDisable
|
BrightestDisable
|
||||||
|
|
||||||
" ハイライトするグループ名を設定します
|
" ハイライトするグループ名を設定します
|
||||||
let g:brightest_highlight = {
|
" アンダーラインで表示する
|
||||||
\ "group" : "Search"
|
let g:brightest#highlight = {
|
||||||
|
\ "group" : "BrightestUnderline"
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" ハイライトする単語のパターンを設定します
|
" ハイライトする単語のパターンを設定します
|
||||||
" デフォルト(空の文字列の場合)は <cword> が使用されます
|
" デフォルト(空の文字列の場合)は <cword> が使用されます
|
||||||
let g:brightest_pattern = '\k\+'
|
let g:brightest#pattern = '\k\+'
|
||||||
|
|
||||||
|
|
||||||
" filetype=cpp を無効にする
|
" filetype=cpp を無効にする
|
||||||
|
|||||||
@@ -77,9 +77,35 @@ endfunction
|
|||||||
" call s:Highlight.highlight("current_word", a:current_group, current, -1)
|
" call s:Highlight.highlight("current_word", a:current_group, current, -1)
|
||||||
" endfunction
|
" endfunction
|
||||||
|
|
||||||
|
let g:brightest#pattern = get(g:, "brightest#pattern", '')
|
||||||
|
|
||||||
function! brightest#highlight(pattern, highlight, cursorline, ...)
|
|
||||||
|
let s:highlight_default = {
|
||||||
|
\ "group" : "WarningMsg",
|
||||||
|
\ "priority" : -1,
|
||||||
|
\ "format" : '\<%s\>',
|
||||||
|
\}
|
||||||
|
let g:brightest#highlight = get(g:, "brightest#highlight", {})
|
||||||
|
function! s:default()
|
||||||
|
return get(b:, "brightest_highlight", extend(s:highlight_default, g:brightest#highlight))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
let s:highlight_in_cursorline_default = {
|
||||||
|
\ "group" : "",
|
||||||
|
\ "priority" : -1,
|
||||||
|
\ "format" : '\<%s\>',
|
||||||
|
\}
|
||||||
|
let g:brightest#highlight_in_cursorline = get(g:, "brightest#highlight_in_cursorline", {})
|
||||||
|
function! s:highlight_in_cursorline()
|
||||||
|
return get(b:, "brightest_highlight_in_cursorline", extend(s:highlight_in_cursorline_default, g:brightest#highlight_in_cursorline))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function! s:highlighting(pattern, highlight, cursorline, ...)
|
||||||
call brightest#hl_clear()
|
call brightest#hl_clear()
|
||||||
|
|
||||||
if !s:is_enable_in_current()
|
if !s:is_enable_in_current()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -87,10 +113,20 @@ function! brightest#highlight(pattern, highlight, cursorline, ...)
|
|||||||
if get(a:, 1, "") == ""
|
if get(a:, 1, "") == ""
|
||||||
return s:single_word(a:pattern, a:highlight, a:cursorline)
|
return s:single_word(a:pattern, a:highlight, a:cursorline)
|
||||||
else
|
else
|
||||||
return s:with_current(a:1, a:group, a:pattern)
|
" return s:with_current(a:1, a:group, a:pattern)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function! brightest#highlight()
|
||||||
|
call s:highlighting(
|
||||||
|
\ get(b:, "brightest_pattern", g:brightest#pattern),
|
||||||
|
\ s:default(),
|
||||||
|
\ s:highlight_in_cursorline(),
|
||||||
|
\ )
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
unlet s:save_cpo
|
unlet s:save_cpo
|
||||||
|
|||||||
@@ -7,57 +7,22 @@ let g:loaded_brightest = 1
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
let g:brightest_pattern = get(g:, "brightest_pattern", '')
|
|
||||||
" let g:brightest_pattern = get(g:, "brightest_pattern", '\k\+')
|
|
||||||
" let g:brightest_highlight_group = get(g:, "brightest_highlight_group", "WarningMsg")
|
|
||||||
" let g:brightest_highlight_group_in_cursor = get(g:, "brightest_highlight_group_in_cursor", "")
|
|
||||||
" let g:brightest_highlight_group_in_cursorline = get(g:, "brightest_highlight_group_in_cursorline", "")
|
|
||||||
|
|
||||||
let g:brightest_enable = get(g:, "brightest_enable", 1)
|
let g:brightest_enable = get(g:, "brightest_enable", 1)
|
||||||
|
|
||||||
|
|
||||||
let s:highlight_default = {
|
|
||||||
\ "group" : "WarningMsg",
|
|
||||||
\ "priority" : -1,
|
|
||||||
\ "format" : '\<%s\>',
|
|
||||||
\}
|
|
||||||
let g:brightest_highlight = get(g:, "brightest_highlight", {})
|
|
||||||
function! s:highlight()
|
|
||||||
return get(b:, "brightest_highlight", extend(s:highlight_default, g:brightest_highlight))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
let s:highlight_in_cursorline_default = {
|
|
||||||
\ "group" : "",
|
|
||||||
\ "priority" : -1,
|
|
||||||
\ "format" : '\<%s\>',
|
|
||||||
\}
|
|
||||||
let g:brightest_highlight_in_cursorline = get(g:, "brightest_highlight_in_cursorline", {})
|
|
||||||
function! s:highlight_in_cursorline()
|
|
||||||
return get(b:, "brightest_highlight_in_cursorline", extend(s:highlight_in_cursorline_default, g:brightest_highlight_in_cursorline))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! s:init_hl()
|
function! s:init_hl()
|
||||||
highlight BrightestDefaultCursorWord gui=underline guifg=NONE
|
highlight BrightestDefaultCursorWord gui=underline guifg=NONE
|
||||||
highlight BrightestUnderline term=underline cterm=underline gui=underline
|
highlight BrightestUnderline term=underline cterm=underline gui=underline
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:hl()
|
|
||||||
call brightest#highlight(
|
|
||||||
\ get(b:, "brightest_pattern", g:brightest_pattern),
|
|
||||||
\ s:highlight(),
|
|
||||||
\ s:highlight_in_cursorline(),
|
|
||||||
\ )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -bar BrightestEnable let g:brightest_enable = 1 | call s:hl()
|
command! -bar BrightestEnable let g:brightest_enable = 1 | call brightest#highlight()
|
||||||
command! -bar BrightestDisable let g:brightest_enable = 0 | call brightest#hl_clear()
|
command! -bar BrightestDisable let g:brightest_enable = 0 | call brightest#hl_clear()
|
||||||
|
|
||||||
|
|
||||||
augroup brightest
|
augroup brightest
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd CursorMoved * call s:hl()
|
autocmd CursorMoved * call brightest#highlight()
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user