Clean up some ugly code in s:Highlights()
This commit is contained in:
parent
94d110f5a5
commit
c3e7c42207
@ -185,6 +185,7 @@ function! s:Highlights()
|
|||||||
let i = 0
|
let i = 0
|
||||||
while 1
|
while 1
|
||||||
let i += 1
|
let i += 1
|
||||||
|
|
||||||
" Only interested in groups that exist and aren't linked
|
" Only interested in groups that exist and aren't linked
|
||||||
if synIDtrans(i) == 0
|
if synIDtrans(i) == 0
|
||||||
break
|
break
|
||||||
@ -195,36 +196,32 @@ function! s:Highlights()
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !has_key(rv, synIDtrans(i))
|
let rv[i] = {}
|
||||||
let group = {}
|
let rv[i].name = synIDattr(i, "name")
|
||||||
let group.name = synIDattr(synIDtrans(i), "name")
|
|
||||||
|
|
||||||
for where in [ "term", "cterm", "gui" ]
|
for where in [ "term", "cterm", "gui" ]
|
||||||
let group[where] = {}
|
let rv[i][where] = {}
|
||||||
for attr in [ "fg", "bg", "sp", "bold", "italic",
|
for attr in [ "fg", "bg", "sp", "bold", "italic",
|
||||||
\ "reverse", "underline", "undercurl" ]
|
\ "reverse", "underline", "undercurl" ]
|
||||||
let group[where][attr] = synIDattr(synIDtrans(i), attr, where)
|
let rv[i][where][attr] = synIDattr(i, attr, where)
|
||||||
endfor
|
|
||||||
|
|
||||||
if s:NeedRedirFallback()
|
|
||||||
redir => temp
|
|
||||||
exe 'sil hi ' . group.name
|
|
||||||
redir END
|
|
||||||
let temp = matchstr(temp, where.'sp=\zs.*')
|
|
||||||
if len(temp) == 0 || temp[0] =~ '\s'
|
|
||||||
let temp = ""
|
|
||||||
else
|
|
||||||
" Make sure we can handle guisp='dark red'
|
|
||||||
let temp = substitute(temp, '[\x00].*', '', '')
|
|
||||||
let temp = substitute(temp, '\s*\(c\=term\|gui\).*', '', '')
|
|
||||||
let temp = substitute(temp, '\s*$', '', '')
|
|
||||||
endif
|
|
||||||
let group[where]["sp"] = temp
|
|
||||||
endif
|
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
let rv[synIDtrans(i)] = group
|
if s:NeedRedirFallback()
|
||||||
endif
|
redir => temp
|
||||||
|
exe 'sil hi ' . rv[i].name
|
||||||
|
redir END
|
||||||
|
let temp = matchstr(temp, where.'sp=\zs.*')
|
||||||
|
if len(temp) == 0 || temp[0] =~ '\s'
|
||||||
|
let temp = ""
|
||||||
|
else
|
||||||
|
" Make sure we can handle guisp='dark red'
|
||||||
|
let temp = substitute(temp, '[\x00].*', '', '')
|
||||||
|
let temp = substitute(temp, '\s*\(c\=term\|gui\).*', '', '')
|
||||||
|
let temp = substitute(temp, '\s*$', '', '')
|
||||||
|
endif
|
||||||
|
let rv[i][where]["sp"] = temp
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
return rv
|
return rv
|
||||||
|
Loading…
x
Reference in New Issue
Block a user