[vim/vim] Clear termguicolors guibg with :hi * guibg=NONE (#2332)

582 views
Skip to first unread message

Nick Jensen

unread,
Nov 13, 2017, 3:17:07 PM11/13/17
to vim/vim, Subscribed

This is a patch by @nuko8 from #981, allowing terminal vim to clear the background when using termguicolors


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/2332

Commit Summary

  • Clear termguicolors guibg with :hi * guibg=NONE

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Christian Brabandt

unread,
Nov 13, 2017, 3:35:10 PM11/13/17
to vim/vim, Subscribed

You forgot to mention which problem this fixes.

Nick Jensen

unread,
Nov 13, 2017, 4:02:14 PM11/13/17
to vim/vim, Subscribed

@chrisbra in terminal vim when using :set termguicolors it is not possible to clear the background (allowing transparency or the terminal background to be displayed). :hi Normal guibg=NONE has no effect, so the only way to get a transparent background in a true color terminal is by not setting the guibg - which in many cases means patching colorschemes.

This patch (not written by me) allows :hi Normal guibg=NONE to clear an existing guibg highlight. See #981 for more information.

Nick Jensen

unread,
Nov 13, 2017, 4:34:40 PM11/13/17
to vim/vim, Push

@nickspoons pushed 1 commit.

  • 5cf8d1f Move if(!gui.in_use) into #ifdef FEAT_GUI


You are receiving this because you are subscribed to this thread.

View it on GitHub

Bram Moolenaar

unread,
Nov 13, 2017, 5:07:00 PM11/13/17
to vim/vim, Subscribed

Nick Jensen wrote:

> This is a patch by @nuko8 from #981, allowing terminal vim to clear
> the background when using termguicolors

Can we have some examples of what this fixes? And how do we know this
doesn't break anything?

--
"You're fired." (1980)
"You're laid off." (1985)
"You're downsized." (1990)
"You're rightsized." (1992)
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Nick Jensen

unread,
Nov 13, 2017, 5:30:31 PM11/13/17
to vim/vim, Subscribed

Here's an example of an unpatched vim (above) and a patched vim (below) on black terminal backgrounds. The unpatched can't clear its guibg highlight so keeps the grey background colour which gets set in the colorscheme.
guibg-example

For each of these, the command :hi Normal outputs Normal xxx ctermfg=223 guifg=#ebdbb2.

@brammool the current tests pass. I don't know how to otherwise ensure that it doesn't break anything else.

Nick Jensen

unread,
Nov 13, 2017, 7:37:42 PM11/13/17
to vim/vim, Subscribed

Minimum steps to reproduce:

  1. vim -u NONE
  2. :set termguicolors
  3. :hi Normal guibg=Red
  4. :hi Normal guibg=NONE

Without this patch, the background remains red.

I have built and tested vim and gvim on Arch linux, and vim on cygwin (Windows 7)

Codecov

unread,
Nov 13, 2017, 9:52:09 PM11/13/17
to vim/vim, Subscribed

Codecov Report

Merging #2332 into master will increase coverage by 0.05%.
The diff coverage is 71.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2332      +/-   ##
==========================================
+ Coverage   74.42%   74.48%   +0.05%     
==========================================
  Files          90       90              
  Lines      132167   132174       +7     
  Branches    30902    29028    -1874     
==========================================
+ Hits        98367    98446      +79     
+ Misses      33775    33728      -47     
+ Partials       25        0      -25
Impacted Files Coverage Δ
src/syntax.c 77.5% <71.42%> (+0.01%) ⬆️
src/version.c 80.8% <0%> (ø) ⬆️
src/gui_gtk_x11.c 47.6% <0%> (ø) ⬆️
src/ex_cmds2.c 80.64% <0%> (+0.09%) ⬆️
src/gui.c 47.63% <0%> (+0.15%) ⬆️
src/if_xcmdsrv.c 84.71% <0%> (+0.17%) ⬆️
src/message.c 68.26% <0%> (+0.19%) ⬆️
src/term.c 50.94% <0%> (+0.21%) ⬆️
src/window.c 81.38% <0%> (+0.52%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1dcada1...5cf8d1f. Read the comment docs.

joaqo

unread,
Jan 23, 2018, 9:58:32 PM1/23/18
to vim/vim, Subscribed

Hey, sorry if I am reviving an old ticket, but just got to this PR after a couple of hours of debugging my vimrc using google. It seems that this PR will solve my particular problems. Do you guys know if it will get accepted any time soon? Should I just build it myself? Thanks a lot for the work you are doing, and sorry if this kind of pinging old PRs is frowned upon.

Gregory Pakosz

unread,
Feb 27, 2018, 4:09:49 AM2/27/18
to vim/vim, Subscribed

Landed here as well after having read #981.

Could this PR be revived by chance?

Gregory Pakosz

unread,
Feb 27, 2018, 8:45:11 AM2/27/18
to vim/vim, vim-dev ML, Manual

Thanks Bram 👍

Matěj Cepl

unread,
Feb 27, 2018, 8:52:40 AM2/27/18
to vim/vim, vim-dev ML, Manual

Awesome! My vim looks reasonably now, not like a malnourished tiger. Thank you. Made me even make out-of-cycle build on my COPR for Fedora/RHEL.

Nick Jensen

unread,
Apr 5, 2018, 8:04:16 PM4/5/18
to vim/vim, vim-dev ML, Manual

Thanks Bram, this is great.

Reply all
Reply to author
Forward
0 new messages