Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit25a4302

Browse files
committed
feat(hues): adjustPmenu based on 'pumborder' value (on Neovim>=0.12)
1 parentc536f2a commit25a4302

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
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+
foreground 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+
--- foreground 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
localadjust=function(ev)
19511957
localadjust_all=ev.event=='VimEnter'
19521958
ifadjust_allorev.match=='fillchars'thenhi('MsgSeparator',H.attr_msgseparator(palette,true))end
1959+
ifadjust_allorev.match=='pumborder'thenhi('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
returnvim.o.fillchars:find('msgsep:%S')~=niland {fg=p.accent }or {bg=p.bg_mid }
19651972
end
19661973

1974+
H.attr_pmenu=function(p,autoadjust)
1975+
localis_pumborder=vim.fn.exists('+pumborder')==1andnot (vim.o.pumborder==''orvim.o.pumborder=='none')
1976+
return (autoadjustandis_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 & 1 deletion
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+
ifchild.fn.has('nvim-0.12')==1then
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()
@@ -513,7 +524,6 @@ T['apply_palette()']['respects `opts.autoadjust`'] = function()
513524
-- By default it should follow `config.autoadjust`
514525
child.lua('MiniHues.config.autoadjust = false')
515526
child.cmd('highlight clear')
516-
child.api.nvim_del_augroup_by_name('MiniHuesAdjust')
517527
child.o.fillchars='msgsep:-'
518528

519529
apply_palette(palette)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp