Skip to content

Handle only bg or fg set when resolving cursor hl #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions autoload/fuzzyy/utils/popup.vim
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,23 @@ def ResolveCursor()
gui: { 'reverse': true },
}
var attrs = hlget('Cursor', true)->get(0, {})
if !attrs->get('guifg') || !attrs->get('guibg')
if !attrs->get('guifg') && !attrs->get('guibg')
hlset([fallback])
return
endif
var special = ['NONE', 'bg', 'fg', 'background', 'foreground']
var guifg = attrs->get('guifg')
var guibg = attrs->get('guibg')
if index(special, guifg) != -1 || index(special, guibg) != -1
hlset([fallback])
var guifg = attrs->get('guifg', 'NONE')
var guibg = attrs->get('guibg', 'NONE')
if has('gui')
hlset([{name: 'fuzzyyCursor', guifg: guifg, guibg: guibg}])
return
endif
var ctermfg = attrs->get('ctermfg', string(colors.TermColor(guifg)))
var ctermbg = attrs->get('ctermbg', string(colors.TermColor(guibg)))
var ctermfg = attrs->get('ctermfg',
index(special, guifg) != -1 ? guifg : string(colors.TermColor(guifg))
)
var ctermbg = attrs->get('ctermbg',
index(special, guibg) != -1 ? guibg : string(colors.TermColor(guibg))
)
try
hlset([{
name: 'fuzzyyCursor',
Expand All @@ -85,6 +89,9 @@ def ResolveCursor()
ctermfg: ctermfg,
ctermbg: ctermbg
}])
catch /\v:(E419|E420|E453):/
# foreground and/or background not known and used as ctermfg or ctermbg
hlset([fallback])
catch
Warn('Fuzzyy: failed to resolve cursor highlight: ' .. v:exception)
hlset([fallback])
Expand Down