Skip to content

Commit b8d3123

Browse files
committed
wip: allow bg/fg with ctermfg and ctermbg
Slightly modified solution that allows bg, fg, background, foreground to be used as ctermfg and ctermbg colors, but also handles specific errors if these are used when the foreground or background colors are unknown. Note: has('gui') is still necessary as the terminal foreground and background will never be known while the gui is running.
1 parent d0c6385 commit b8d3123

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

autoload/fuzzyy/utils/popup.vim

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,18 @@ def ResolveCursor()
6868
hlset([fallback])
6969
return
7070
endif
71-
var special = ['bg', 'fg', 'background', 'foreground']
71+
var special = ['NONE', 'bg', 'fg', 'background', 'foreground']
7272
var guifg = attrs->get('guifg', 'NONE')
7373
var guibg = attrs->get('guibg', 'NONE')
7474
if has('gui')
7575
hlset([{name: 'fuzzyyCursor', guifg: guifg, guibg: guibg}])
7676
return
7777
endif
78-
if index(special, guifg) != -1 || index(special, guibg) != -1
79-
hlset([fallback])
80-
return
81-
endif
8278
var ctermfg = attrs->get('ctermfg',
83-
guifg ==# 'NONE' ? 'NONE' : string(colors.TermColor(guifg))
79+
index(special, guifg) != -1 ? guifg : string(colors.TermColor(guifg))
8480
)
8581
var ctermbg = attrs->get('ctermbg',
86-
guibg ==# 'NONE' ? 'NONE' : string(colors.TermColor(guibg))
82+
index(special, guibg) != -1 ? guibg : string(colors.TermColor(guibg))
8783
)
8884
try
8985
hlset([{
@@ -93,6 +89,9 @@ def ResolveCursor()
9389
ctermfg: ctermfg,
9490
ctermbg: ctermbg
9591
}])
92+
catch /(E419|E420|E453)/
93+
# foreground and/or background not known and used as ctermfg or ctermbg
94+
hlset([fallback])
9695
catch
9796
Warn('Fuzzyy: failed to resolve cursor highlight: ' .. v:exception)
9897
hlset([fallback])

0 commit comments

Comments
 (0)