Removing the syntax highlighting is easy. You're getting it because you're setting the 'filetype'
of the buffer to git
, which is loading those syntax definitions and applying them to the buffer you're opening in the popup. If you don't set the filetype at all, Vim will just not apply any syntax highlighting to it.
So you could simply change it to:
nnoremap <silent> <Leader>p :call popup_atcursor(split(system("hg log -p --follow -L " . expand("%:p") . "," . line(".") . ":" . line(".") . "\| grep -v ^files"), "\n"), { "padding": [1,1,1,1], "pos": "botleft", "wrap": 0 })<CR>
Which removes the setbufvar(winbufnr(...), "&filetype", "git")
part which is adding that setting.
(I also changed nmap
to nnoremap
, it's usually better to use the latter whenever possible, so that other mappings won't interfere with this one. I also added a space after <silent>
since it's an option and not part of the key definition. Those changes are not related to the solution of the issue.)
If you do want syntax highlighting, that might be a little harder, since you would pretty much have to write your own syntax rules and apply colors directly for that purpose. You could, for example, create a syntax/gitdarkbg.vim
file (or you could use syntax/diffdarkbg.vim
since highlighting is more about diff added and removed lines) and set the 'filetype'
of the popup menu to gitdarkbg
. This, of course, relies on the Pmenu
highlighting producing a light background, which is the case for you but is not always a valid assumption... It's doable, but definitely harder to get it right.
Vim does have support for themes that will use darker foreground colors when using a light background, which can be controlled with the 'background'
option, but unfortunately that option is global (you can't set it just the popup) and will actually affect Vim as a whole. The way colorschemes work, Vim will reload them fully when changing 'background'
, so that's definitely a non-starter here.
One option you might consider is changing the color of the popups to use a background that is different from the default Vim background, but still matches it. In your case, a popup with a dark (but not black) background. That way you would be able to reuse filetype syntax definitions inside a popup menu, without the effect of light text on light background. You could change the background color of popup menus by customizing the Pmenu
highlight group and possibly other groups related to it (such as PmenuSel
).
ctermfg
(orguifg
) inPmenu
? (Better yet use highlight groupPopup
which will be used instead ofPmenu
if it's defined.)