Add function to clone highlight groups with attrs
This commit is contained in:
parent
dda5ee4e8b
commit
9fbe25fee7
@ -5,6 +5,29 @@ function! FoldText()
|
|||||||
return line.' '.string(v:foldend - v:foldstart + 1).' lines '
|
return line.' '.string(v:foldend - v:foldstart + 1).' lines '
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Derived from http://stackoverflow.com/a/1333025
|
||||||
|
function! CloneHighlightGroupWithAttributes(group, new_group, attributes)
|
||||||
|
" Get group details, resolving group links.
|
||||||
|
redir => group
|
||||||
|
exe "silent hi " . a:group
|
||||||
|
redir END
|
||||||
|
while group =~ "links to"
|
||||||
|
let index = stridx(group, "links to") + len("links to")
|
||||||
|
let linked_group = strpart(group, index + 1)
|
||||||
|
redir => group
|
||||||
|
exe "silent hi " . linked_group
|
||||||
|
redir END
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
" Get highlight parameters and existing remove attributes.
|
||||||
|
let parameters = matchlist(group, '\<xxx\>\s\+\(.*\)')[1]
|
||||||
|
let parameters = substitute(parameters, '\(c\?term\|gui\)=\w\+', '', 'g')
|
||||||
|
|
||||||
|
" Create the cloned highlight group with new attributes.
|
||||||
|
exe 'hi '.a:new_group.' '.parameters.
|
||||||
|
\' term='.a:attributes.' cterm='.a:attributes.' gui='.a:attributes
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Strip trailing whitespace
|
" Strip trailing whitespace
|
||||||
function! <SID>StripWhitespace()
|
function! <SID>StripWhitespace()
|
||||||
let l = line(".")
|
let l = line(".")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user