Skip to content

Commit 575c165

Browse files
committed
feat(hues): adjust Pmenu based on 'pumborder' value (on Neovim>=0.12)
1 parent 87c7d49 commit 575c165

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ There are following change types:
113113

114114
### Evolve
115115

116-
- Add auto adjusting of highlight groups based on certain events (like `MsgSeparator` group based on changing of `msgsep` flag of 'fillchars' option). It can be disabled via new `autoadjust` config setting or `opts.autoadjust` in `apply_palette()`.
116+
- Add auto adjusting of highlight groups based on certain events. It can be disabled via new `autoadjust` config setting or `opts.autoadjust` in `apply_palette()`. Affected groups:
117+
- `MsgSeparator` depends on `msgsep` flag of 'fillchars' option.
118+
- `Pmenu` depends on 'pumborder' option value (on Neovim>=0.12).
117119

118120
### Refine
119121

doc/mini-hues.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ events relevant to them. Currently adjusted groups:
207207
- |hl-MsgSeparator| is adjusted based on `msgsep` flag in |'fillchars'|.
208208
If it is whitespace - highlight background, otherwise - foreground.
209209

210+
- |hl-Pmenu| is adjusted based on |'pumborder'| value (on Neovim>=0.12).
211+
If it results in a border - same as floating window (but with no accent
212+
in border), otherwise - same as |hl-CursorLine|. This design
213+
makes |ins-completion-menu| stand out from regular floating windows.
214+
210215
# Examples ~
211216
*MiniHues-examples*
212217

lua/mini/hues.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ end
194194
--- - |hl-MsgSeparator| is adjusted based on `msgsep` flag in |'fillchars'|.
195195
--- If it is whitespace - highlight background, otherwise - foreground.
196196
---
197+
--- - |hl-Pmenu| is adjusted based on |'pumborder'| value (on Neovim>=0.12).
198+
--- If it results in a border - same as floating window (but with no accent
199+
--- in border), otherwise - same as |hl-CursorLine|. This design
200+
--- makes |ins-completion-menu| stand out from regular floating windows.
201+
---
197202
--- # Examples ~
198203
--- *MiniHues-examples*
199204
---
@@ -516,7 +521,8 @@ MiniHues.apply_palette = function(palette, plugins, opts)
516521
hi('NormalFloat', { fg=p.fg, bg=p.bg_edge })
517522
hi('NormalNC', { link='Normal' })
518523
hi('OkMsg', { fg=p.green, bg=nil })
519-
hi('Pmenu', { fg=p.fg, bg=p.bg_mid })
524+
hi('Pmenu', H.attr_pmenu(p, autoadjust))
525+
hi('PmenuBorder', { link='Pmenu' })
520526
hi('PmenuExtra', { link='Pmenu' })
521527
hi('PmenuExtraSel', { link='PmenuSel' })
522528
hi('PmenuKind', { link='Pmenu' })
@@ -1950,6 +1956,7 @@ H.setup_autoadjust = function(palette)
19501956
local adjust = function(ev)
19511957
local adjust_all = ev.event == 'VimEnter'
19521958
if adjust_all or ev.match == 'fillchars' then hi('MsgSeparator', H.attr_msgseparator(palette, true)) end
1959+
if adjust_all or ev.match == 'pumborder' then hi('Pmenu', H.attr_pmenu(palette, true)) end
19531960
end
19541961

19551962
-- Use single autocommand without pattern for performance (skips Neovim doing
@@ -1964,6 +1971,11 @@ H.attr_msgseparator = function(p, autoadjust)
19641971
return vim.o.fillchars:find('msgsep:%S') ~= nil and { fg = p.accent } or { bg = p.bg_mid }
19651972
end
19661973

1974+
H.attr_pmenu = function(p, autoadjust)
1975+
local is_pumborder = vim.fn.exists('+pumborder') == 1 and not (vim.o.pumborder == '' or vim.o.pumborder == 'none')
1976+
return (autoadjust and is_pumborder) and { link = 'NormalFloat' } or { fg = p.fg, bg = p.bg_mid }
1977+
end
1978+
19671979
-- Utilities ------------------------------------------------------------------
19681980
H.error = function(msg) error('(mini.hues) ' .. msg, 0) end
19691981

scripts/minimal_init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ vim.cmd([[let &rtp.=','.getcwd()]])
44

55
-- Ensure persistent color scheme (matters after new default in Neovim 0.10)
66
vim.o.background = 'dark'
7-
require('mini.hues').setup({ background = '#11262d', foreground = '#c0c8cc' })
7+
require('mini.hues').setup({ background = '#11262d', foreground = '#c0c8cc', autoadjust = false })
88
vim.g.colors_name = 'minitest-scheme'
99

1010
-- - Make screenshot tests more robust across Neovim versions

tests/test_hues.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,17 @@ T['setup()']['respects `config.autoadjust`'] = function()
240240
validate_hl_group('MsgSeparator', 'guifg=#dddddd guibg=#3e3e3e')
241241
child.o.fillchars = 'msgsep: '
242242
validate_hl_group('MsgSeparator', 'guifg=#dddddd guibg=#3e3e3e')
243+
244+
-- Should autoadjust `Pmenu` based on 'pumborder'
245+
if child.fn.has('nvim-0.12') == 1 then
246+
child.cmd('highlight clear')
247+
child.o.pumborder = 'single'
248+
load_module({ background = '#222222', foreground = '#dddddd' })
249+
validate_hl_group('Pmenu', 'links to NormalFloat')
250+
251+
child.o.pumborder = 'none'
252+
validate_hl_group('Pmenu', 'guifg=#dddddd guibg=#3e3e3e')
253+
end
243254
end
244255

245256
T['make_palette()'] = new_set()

0 commit comments

Comments
 (0)