mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-22 21:45:06 +02:00
highlighter: vim9 script implementation of #exec
This commit is contained in:
parent
a6b7267979
commit
d9947beb0f
@ -402,4 +402,31 @@ else
|
|||||||
endif
|
endif
|
||||||
return true
|
return true
|
||||||
enddef
|
enddef
|
||||||
|
def airline#highlighter#exec(group: string, clrs: list<any>): void # {{{2
|
||||||
|
# TODO: is clrs: list<any> correct? Should probably be list<number> instead
|
||||||
|
# convert all themes to use strings in cterm color definition
|
||||||
|
if pumvisible()
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
var colors: list<string>
|
||||||
|
colors = map(copy(clrs), { _, v -> type(v) != type('') ? string(v) : v})
|
||||||
|
if len(colors) == 4
|
||||||
|
add(colors, '')
|
||||||
|
endif
|
||||||
|
if s:is_win32term
|
||||||
|
colors[2] = s:gui2cui(get(colors, 0, ''), get(colors, 2, ''))
|
||||||
|
colors[3] = s:gui2cui(get(colors, 1, ''), get(colors, 3, ''))
|
||||||
|
endif
|
||||||
|
var old_hi: list<string> = airline#highlighter#get_highlight(group)
|
||||||
|
var new_hi: list<string> = colors
|
||||||
|
colors = s:CheckDefined(colors)
|
||||||
|
if old_hi != new_hi || !s:hl_group_exists(group)
|
||||||
|
var cmd = ''
|
||||||
|
cmd = printf('hi %s%s', group, s:GetHiCmd(colors))
|
||||||
|
exe cmd
|
||||||
|
if has_key(s:hl_groups, group)
|
||||||
|
s:hl_groups[group] = colors
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
enddef
|
||||||
endif
|
endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user