Improve brightest#parse_cursorline_highlight_group.

This commit is contained in:
manga_osyo
2014-09-28 21:49:18 +09:00
parent 572d8bdb13
commit afc1f0380f

View File

@@ -31,6 +31,7 @@ endfunction
function! s:is_ignore_syntax_in_cursor(context) function! s:is_ignore_syntax_in_cursor(context)
let list = get(b:, "brightest_ignore_syntax_list", g:brightest#ignore_syntax_list) let list = get(b:, "brightest_ignore_syntax_list", g:brightest#ignore_syntax_list)
if empty(list) if empty(list)
return 0 return 0
endif endif
@@ -174,10 +175,15 @@ function! brightest#highlighting()
endfunction endfunction
let s:parse_cursorline_highlight_group_memo = {}
function! brightest#parse_cursorline_highlight_group(group) function! brightest#parse_cursorline_highlight_group(group)
redir => hl redir => hl
silent execute "highlight" a:group silent execute "highlight" a:group
redir END redir END
let key = hl
if has_key(s:parse_cursorline_highlight_group_memo, key)
return s:parse_cursorline_highlight_group_memo[key]
endif
let hl = substitute(hl, '\n', '', 'g') let hl = substitute(hl, '\n', '', 'g')
let hl = matchstr(hl, '.*xxx\zs.*') let hl = matchstr(hl, '.*xxx\zs.*')
let guibg = synIDattr(synIDtrans(hlID("CursorLine")), "bg", "gui") let guibg = synIDattr(synIDtrans(hlID("CursorLine")), "bg", "gui")
@@ -197,6 +203,7 @@ function! brightest#parse_cursorline_highlight_group(group)
let hl .= ' ctermbg=' . ctermbg let hl .= ' ctermbg=' . ctermbg
endif endif
endif endif
let s:parse_cursorline_highlight_group_memo[key] = hl
return hl return hl
endfunction endfunction