I've enabled true colors for Vim with success using:
set t_8f=\[[38;2;%lu;%lu;%lum set t_8b=\[[48;2;%lu;%lu;%lum set termguicolors
(check :h xterm-true-color
for more information)
I have then enabled a true color colorscheme to try the new setting, like:
set background=dark
colors deep-space
(https://github.com/tyrannicaltoucan/vim-deep-space)
Previously when using 256 colors I was able to get a transparent background by:
hi! Normal ctermbg=NONE guibg=NONE hi! NonText ctermbg=NONE guibg=NONE
Now, this is not working anymore and I don't know any alternative. Is it supported to get transparent background with Vim under termguicolors
?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, .
I use the same colorscheme as you.
I found I could get a transparent background outside tmux
.
when I open vim inside tmux, I got the problem like you.
hi! Normal ctermbg=NONE guibg=NONE
hi! NonText ctermbg=NONE guibg=NONE
These two lines also not work for me.
BTW, my TERM
value is xterm-256color
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
your TERM in tmux needs to be screen-256color or screen-256color-bce
I use tmux myself and have correctly setup it for true colors through the following setting:
# Enable 24 bit true colors
set -ga terminal-overrides ',xterm-256color:Tc'
Despite that, let's assume this report is about Vim without tmux, I don't want to involve yet another variable. I have the issue with Vim outside the tmux as well, can't get transparent background through true colours in any way. I have indeed heard that true colours got support from NeoVim first and that there the behaviour may be different.
@sfwn I had the tmux problem initially too, and thought the solution was to set TERM
to xterm-256color
, but that's not correct. I fixed the situation correctly by setting set -ga terminal-overrides ',xterm-256color:Tc'
and setting this on my .vimrc:
if has("termguicolors") " set true colors
set t_8f=\[[38;2;%lu;%lu;%lum set t_8b=\[[48;2;%lu;%lu;%lum set termguicolors
endif
where \[
is ESC. Check :h xterm-true-color
about this and how to input ESC.
You should restart tmux after applying the terminal-overrides setting, and correctly setting t_8f and t_8b in vim is necessary for it to work with true colors inside tmux.
@oblitum
I tried several times through set t_8f
and t_8b
but failed. I know it's my question about setting \[
, let me try now again.
sorry but I reallly don't know how to (replace ^[ with real escape)
.
@k-takata
Tks, I got it and success ☺️
After set
set -ga terminal-overrides ',xterm-256color:Tc'
set -g default-terminal "screen-256color"
in ~/.tmux.conf
and set
if has("termguicolors") " set true colors
set t_8f=\[[38;2;%lu;%lu;%lum
set t_8b=\[[48;2;%lu;%lu;%lum
set termguicolors
endif
in ~/.vimrc
, now I do have transparent background inside&outside tmux.
@sfwn Hi. Sorry but I think your problem is another one and is unrelated with the issue here. I'd not like to mix it with the issue being reported.
@sfwn I'm saying that because, for me, the issue happens regardless of using tmux or not.
I'd like to add to my report that :hi! Normal ctermbg=NONE guibg=NONE
is not having any effect at all. When I execute :hi! Normal ctermbg=0 guibg=#000000
, my background is changed to black, then when I execute :hi! Normal ctermbg=NONE guibg=NONE
, the background stays black, so :hi! Normal ctermbg=NONE guibg=NONE
is in reality doing nothing.
@oblitum :)
For what's worth, on NeoVim, the exact same configuration works to get the transparent background.
Even inside tmux.
I can reproduce the exact problem described by the OP with Vim 7.4p2235 in iTerm2 (OS X), both inside and outside tmux (other than that, I see correct true colors both inside and outside tmux). Just for completeness, this is the relevant snippet from my .vimrc
:
if has('termguicolors') && $TERM_PROGRAM ==# 'iTerm.app'
set t_8f=^[[38;2;%lu;%lu;%lum
set t_8b=^[[48;2;%lu;%lu;%lum
set termguicolors
endif
To reproduce, start Vim with the above configuration (whether you're in tmux doesn't really matter) and type:
:hi Normal ctermbg=NONE guifg=NONE
:set notermguicolors
:set termguicolors
The result is:
Ops, the command in my previous post should be: :hi! Normal ctermbg=NONE guibg=NONE
.
Your description of the issue is terribly confusing and thus misleading people.
You brought us three confusions.
It is true that, when Vim did not support 24-bit colors yet, you were able to get transparent background by setting
hi! Normal ctermbg=NONE
But guibg=NONE
was nothing to do with that because they were used to specify colors only for GVim those days.
Now Vim supports 24-bit colors and, when termguicolors
is enabled, it uses pixel values specified by guifg
and guibg
to paint colors. Note that, in this case, both ctermfg
and ctermbg
are not used.
So, I'm wondering how you could conclude from those two facts that
hi! Normal ctermbg=NONE guibg=NONE
would give you transparent background when termguicolors
was enabled. How could you infer that ctermbg=NONE
for non-24-bit color could correspond to guibg=NONE
for 24-bit color?
This is Confusion No. 1.
Next. You wrote:
The exact same configuration works on NeoVim 0.1.5.
and
on NeoVim, the exact same configuration works to get the transparent background
As I’ve never used that editor, I don't know much about it but once heard that it had no GUI.
Then, does it really have guibg
? What is that for with such a non-GUI editor? How can "the exact same configuration" be possible?
Note that Vim has a series of decent GUIs ranging from Linux to Windows, called GVim collectively.
Needless to say, every guibg
in highlight groups has a substantial role in GVim to determine a background color. Using guibg
to give transparent background to a terminal application which has full-fledged GUI versions, sounds like almost a joke and is confusing.
Try deep-space with one of our GUIs and do :hi! Normal guibg=NONE
there. What do you think happens with it? Yes, that completely ruins the colorscheme.
This is Confusion No. 2.
Or, for the editor you mentioned, this hypothesis might be possible: While guibg=NONE
is ignored, ctermbg=NONE
would has an effect to make the background transparent.
If this is the case, you must remember that, as I wrote previously, in Vim, enabling termguicolors
means choosing colors from the values of guifg
s and guibg
s, not from ctermfg
s or ctermbg
s.
Even if ctermbg=NONE
could give transparent background to another editor, that’s nothing to do with termguicolors
enabled Vim. The background color is chosen from guibg
.
This is Confusion No. 3.
What is your real issue? Could you clarify that, if any?
Actually, you can get a transparent background version of deep-space by
--- deep-space.vim 2016-08-14 16:24:48.000000000 +0000 +++ deep-space2.vim 2016-08-16 06:59:20.000000000 +0000 @@ -75,7 +75,11 @@ call s:HL('ModeMsg', s:green, '', '') call s:HL('MoreMsg', s:green, '', '') call s:HL('NonText', s:gray3, '', '') -call s:HL('Normal', s:gray4, s:gray0, 'none') +if has('gui_running') + call s:HL('Normal', s:gray4, s:gray0, 'none') +else + call s:HL('Normal', s:gray4, '', 'none') +endif call s:HL('Pmenu', s:gray4, s:gray2, '') call s:HL('PmenuSbar', s:gray3, s:gray4, '') call s:HL('PmenuSel',
What makes you think "Can't get transparent background with termguicolors enabled"?
As I’ve never used that editor, I don't know much about it but once heard that it had no GUI.
Neither do builds of Vim which don't enable the GUI components. There are GUIs for Neovim, they're just different projects.
Then, does it really have guibg? What is that for with such a non-GUI editor?
Yes, just like Vim does even if it isn't built with a GUI. 'termguicolors' is only relevant for ... the terminal. Storing guibg/guifg attributes when parsing :hi
commands has nothing to do with actually using a GUI.
How can "the exact same configuration" be possible?
Easy. It's just a couple cp or ln commands.
@nuko8 Why this level of condescension? I've opened an issue clearly showing that I was looking for options, since I didn't known any. I think my intention was fairly clear.
This is my actual relevant .vimrc
configuration which I use both for vim/gvim/nvim (NeoVim terminal):
if has("termguicolors") && has("nvim") " set true colors on NeoVim
set t_8f=�[38;2;%lu;%lu;%lum set t_8b=�[48;2;%lu;%lu;%lum set termguicolors
endif
set background=dark colors deep-space "colors seoul256-light hi! link Conceal Normal if !has('gui_running') hi! Normal ctermbg=NONE guibg=NONE hi! NonText ctermbg=NONE guibg=NONE endif
On Vim (terminal) it's falling back to 256 colors (not enabling termguicolors
) because my hi! Normal ctermbg=NONE guibg=NONE
patch doesn't work there, on NeoVim it's enabling termguicolors
since that highlighting patch does work to get transparent background on NeoVim. In any case, in GUI I don't care for transparent background, hence in GUI versions I simply don't execute the highlighting patch.
As you may check, I indeed did know a bit about the differences regarding terminal and GUI instances, anyway, is it so important to bring yet another variable to my question? My question is about terminal vim (termguicolors), not GVim et. al., I've already removed tmux from the discussion (that got mentioned by other user) to reduce scope.
I'm not looking to patch a specific colorscheme for that, the solution I'm looking for should resemble my old one, which still works on NeoVim, which is to patch highlighting from .vimrc
to get transparent background for any colorscheme.
I don't know but, this kind of answer seems a bit harsh and it's not the first time I get it out of a sudden. This makes a non-welcoming community and foster people to go for alternatives.
is it so important to bring yet another variable to my question?
Yes, absolutely. We need to take all users, in particular, GUI users in this case, as well as you into consideration to struggle for a reasonable solution with which most of them are satisfied.
this kind of answer seems a bit harsh and it's not the first time I get it out of a sudden. This makes a non-welcoming community and foster people to go for alternatives.
The principle is simple. I'm personally against someone which asks us for changing something for his own interest only at the expense of other users' benefits.
Please read my initial question. I didn't ask for a change, I simply asked.
Is it supported to get transparent background with Vim under termguicolors?
Yes, it is supported. You can freely change color schemes at runtime through :colorscheme
, no matter what background, opaque or transparent.
As expalained above, you cannot use hi! Normal guibg=NONE
to make background transparent at runtime.
We might introduce a new set option to make that possible, but we've not received this kind of proposal or request so far.
@nuko8 OK. At last, thanks for the answer. I've verified your patch applied to the specific colorscheme and it does work.
Since to me the fact that one is able get transparent background at runtime for notermguicolors
but can't for termguicolors
seems a discrepancy, I'll leave this open for anyone responsible to close as wontfix or bug.
Since because of this issue I've tried NeoVim for the first time and it seems to simply work with my .vimrc
and plugins without almost any changes, my personal solution meanwhile will be to stick to it.
I've verified your patch applied to the specific colorscheme and it does work.
Thank you for the check.
Since to me the fact of being able to get transparent background at runtime for notermguicolors but not being able to for termguicolors seems a discrepancy, I'll leave this open for anyone responsible to close it as wontfix or bug.
Makes sense. Now I understand what you really want.
Since because of this issue I've tried NeoVim for the first time and it seems to simply work with my .vimrc and plugins without almost any changes, my personal solution meanwhile will be to stick to it
Thanks to @jamessan's comment, now I see there was an unfortunate misunderstanding between us, and that you're not the one who is solely to blame for that. Before writing my first comment, I should have asked you about NeoVim and been aware of the discrepancy between it and Vim.
Bump.
This is still an issue:
Since to me the fact of being able to get transparent background at runtime for notermguicolors but not being able to for termguicolors seems a discrepancy, I'll leave this open for anyone responsible to close it as wontfix or bug.
Since because of this issue I've tried NeoVim for the first time and it seems to simply work with my .vimrc and plugins without almost any changes, my personal solution meanwhile will be to stick to it.
Still receiving the same issue:
set termguicolors
would not render background transparent
set notermguicolors
would render background transparent
Additional comment: it seems that normal Terminal.app on macOS works with properly, I've tried the configurations on HyperJs, iTerm and default Terminal.app.
All of the terminals report $TERM = xterm-256color
normal Terminal.app on macOS works with properly
Try and run the following command-line on Terminal.app and see if Terminal.app is true-color capable or not for yourself:
printf "\x1b[38;2;255;000;000mYou see red?\x1b[0m\n"
If it is true-color capable, you'll see characters in red; otherwise, your argument doesn't make sense.
Terminal.app is NOT true-color capable. I don't know why people keep thinking it is.
I'm not saying that it (Terminal.app) supports true colour however I wanted to emphasise that transparent background works without true colour mode.
Plus, neovim works with either of the options.
On iTerm2, which is capable of true-color, you can get the background to be translucent or transparent even if you specify a solid color for guifg
of highlight Normal
with set termguicolor
.
How to set up that terminal or another piece of software is definitely out of place for this issue tracker, IMHO.
I am not sure I understand the issues recently reported. @nuko8's explanation was quite clear, and in fact I have updated a couple of colorschemes of mine (Solarized 8 and WWDC16) to support transparent backgrounds after @nuko8's comments. They work for me in Terminal.app and iTerm2, within or without tmux.
I'd suggest people still having problems with transparent background to try the following:
set termguicolors
in your vimrc
.let g:solarized_termtrans=1
in your vimrc
(or download WWDC16 and let let g:wwdc16_term_trans_bg=1
).virmc
).Vim's background should be transparent (you should see the background image), no matter if your terminal supports true colors or not. If that is the case, and you don't get a transparent background with other colorschemes, I think that the problem is in those colorschemes.
At this moment this issue is solely about:
Since to me the fact of being able to get transparent background at runtime for notermguicolors but not being able to for termguicolors seems a discrepancy, I'll leave this open for anyone responsible to close it as wontfix or bug.
Meaning, you are able to tweak the background to transparent after finishing loading a colorscheme with opaque background, using the following on your .vimrc
:
hi! Normal ctermbg=NONE guibg=NONE hi! NonText ctermbg=NONE guibg=NONE
This works and has been working for quite some time with notermguicolors
, but has no effect for termguicolors
.
For comparison, on NeoVim, setting the background to None
on either case works as expected, it respects the original behavior of getting a transparent background.
I've bumped the issue for this.
It seems that my wordings it not clear,
@oblitum totally clear things up and said what I wanted to say.
@lifepillar I don't know about those colorscheme, maybe there is something I left off after walk-through the code. @nuko8 Yes I had my iTerm set-up properly
@oblitum I don't see any difference in Terminal.app between Vim and NeoVim: setting
hi! Normal ctermbg=NONE guibg=NONE
does immediately set a transparent background in both cases. For iTerm2, however, you are right: Vim sets the transparency only when (re)loading the colorscheme.
@lifepillar the testcase is:
termguicolors
and whatever is necessary for true colors.hi! Normal ctermbg=NONE guibg=NONE
and see whether background got transparent.@ThePooE you may still get transparent background if you modify your colorscheme directly as @nuko8 commented at #981 (comment). You just can't get it transparent afterwards.
This issue is weird because it makes it possible not being able to revert to an original true colors colorscheme that employs a transparent background. If you then set hi! Normal guibg=<some opaque color>
, you can't get back to original transparent state anymore, except by restarting Vim.
@oblitum @ThePooE As I said, your testcase passes in Terminal.app. I have no Linux box locally, but your testcase passes if I run Vim remotely on a Linux terminal (even if I open an SSH session from iTerm2).
So, the only terminal where the testcase fails (among those that I've tried) is iTerm2.
Re your last comment, in Terminal.app, if the current colorscheme has a transparent background and I set an opaque color, the background stays transparent. In iTerm2 it becomes opaque, but I can get it transparent again by reloading the colorscheme.
Aaargh. Sorry, I forgot that I am not setting termiguicolors
in Terminal.app (because, of course, it doesn't support true colors).
So, in the only true color terminal I can try now (iTerm2), I agree that highlight commands behave differently according to whether termguicolors
is set or not.
in Terminal.app, if the current colorscheme has a transparent background and I set an opaque color, the background stays transparent.
Strange, seems worth a report.
Regarding terminal emulator behaviour for "dynamic transparency", I'm unable to get it on whatever emulator I tried on Linux, I use xfce4-terminal-devel, where it works on NeoVim but not on Vim. Formerly I also tried others if I recall correctly (gnome terminal), but also got the same.
Aaargh. Sorry, I forgot that I am not setting termiguicolors in Terminal.app (because, of course, it doesn't support true colors).
OK.
Anyway, @nuko8 has clearly said that you should not expect hi! Normal guibg=NONE
to set a transparent background in a true-color terminal:
every
guibg
in highlight groups has a substantial role in GVim to determine a background color. Usingguibg
to give transparent background to a terminal application which has full-fledged GUI versions, sounds like almost a joke and is confusing.
NeoVim does it, however (hi! Normal guibg=NONE
sets a transparent background in NeoVim, so it doesn't seem to fallback to the value of ctermbg
). They may have been able to do it because there is no “GNeoVim”. Just guessing…
@lifepillar NeoVim has (3rd party) graphical frontends, I just don't use any, but I do see in issue tracker that they do care about them.
Regarding GVim, is one able to get transparency on it? It never worked for me, nor did I expect it to work.
@lifepillar regarding his argument, you may check my point of view here: #1118 (comment).
For people who consider that the issue of this thread really matters, try the following patch if you will:
diff --git a/src/syntax.c b/src/syntax.c
index 75ede36..fbb7fab 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -8227,6 +8227,24 @@ set_normal_colors(void)
cterm_normal_bg_gui_color = HL_TABLE()[idx].sg_gui_bg;
must_redraw = CLEAR;
}
+ else if (p_tgc && !gui.in_use)
+ {
+ /* Now that "... .sg_gui_bg == INVALCOLOR" holds as well as
+ * the conditions of the else-if statement above, it is highly
+ * likely that ":hi Normal guibg=NONE" has been invoked by the
+ * user running termguicolors-enabled Vim on terminal to get
+ * the translucent background. Honor it. */
+ if (HL_TABLE()[idx].sg_gui_bg_name)
+ {
+ /* Update sg_gui_bg_name accordingly in case it still
+ * holds the previous value, so that it will be consistent
+ * with the current state of sg_gui_bg. */
+ vim_free(HL_TABLE()[idx].sg_gui_bg_name);
+ HL_TABLE()[idx].sg_gui_bg_name = NULL;
+ }
+ cterm_normal_bg_gui_color = INVALCOLOR;
+ must_redraw = CLEAR;
+ }
}
}
#endif
@nuko8 I've tried your patch and it works fine as far as I've tried, thanks. I hope it or similar gets upstream and settle this.
@sfwn The problem in #981 (comment) is your terminal. I get that behavior in Terminator 1.91, but not in Konsole, Terminal.app or iterm2.
i fixed with this
hi NonText guifg=250 guifg=none hi Normal guifg=252 guibg=none
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
I am using jellybeans colorscheme. The only way I was able to get a transparent background was to set the following:
colorscheme jellybeans
" set transparent background - jellybeans specific
let g:jellybeans_overrides = {
\ 'background': { 'ctermbg': 'none', '256ctermbg': 'none' },
\}
if has('termguicolors') && &termguicolors
let g:jellybeans_overrides['background']['guibg'] = 'none'
endif
As described by the jellybeans author: https://nicedoc.io/nanotech/jellybeans.vim