While I have no problems with Vim's terminal colors with notermguicolors
, when termguicolors
is set the terminal always uses a default palette. For example, these are the ANSI colors in iTerm2 when both iTerm2's ANSI colors and Vim's colorscheme are set to Solarized:
The same with MacVim (and, I guess, with any gVim). Is there a way yet to change those colors? I have only been able to change the background through the Terminal
highlight group. Perhaps, there should be TerminalBlack
, TerminalRed
, and so on?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
Well, the idea is that you have already set terminal colors for use with Vim
I'm not sure I understand. Do you mean my OS's terminal colors?
and that's what you will get in the terminal window.
When termguicolors
is set (or in GUI Vim), the colors of my OS's terminal are not the colors I get in Vim's terminal window, except for the background (see screenshot in my previous post). Which is not surprising to me: at least in GUI Vim, which colors could Vim choose?
The main problem is that such colors are not always clearly visible against the background (in the example above, Solarized's background). I know that I can set the attributes of the Terminal
highlight group to change the background. But my question is: can I change the remaining 15 colors instead?
For example, NeoVim has g:terminal_color_NN
variables for that purpose.
—
I haven't explained myself well, sorry. I am talking about the 16 ANSI colors that most terminals support and allow redefining. I am always running Vim in an environment that has at least 256 colors. In what follows, I assume that I am running Vim in an environment supporting millions of colors (i.e., a true-color terminal or a GUI version of Vim).
If I use a terminal and set notermguicolors
, when I open a terminal window inside Vim—say, with a Bash shell—such shell inherits the 16 ANSI colors from the OS's terminal. So, a shell in my OS's terminal and a shell inside a Vim terminal window look the same. So far, so good.
If I set termguicolors
, when I open a terminal window inside Vim, such window has its background set to Normal
, but it uses a default 16-color palette independent of my OS's terminal settings.
For example, the following is a Vim terminal window, with notermguicolors
and the Solarized 8 colorscheme, running in iTerm2 whose 16-color palette is set to Solarized, too:
And this is the same configuration, but with termguicolors
set:
Note that, in this case, the shell does not use the Solarized palette.
NeoVim has 16 variables g:terminal_color_0
through g:terminal_color_15
, to set Vim's terminal 16-color palette using GUI colors (e.g., let g:terminal_color_0 = '#404040'
).
—
So it should work OK, if you set t_Co to 16 in Vim and disable 'termguicolors'. Can you try that?
All is fine when termguicolors
is disabled. My issue is specifically with termguicolors
set, and with the first 16 colors only.
What would work is to ignore 'termguicolors' for the first 16 colors.
When Vim runs within a GUI (e.g., MacVim), which colors should a terminal window display then?
—
You are receiving this because you commented.
Is there any possibility of this being addressed for the 8.1 release?
There's no way to adjust the ansi colors used in a :terminal
in Gvim or when using termguicolors
. I've resorted to changing the values in the ansi_colors
table in src/libvterm/src/pen.c
.
I understand the motivation for using the same colors as the underlying terminal, but this still leaves GVim out since there's no parent terminal. Generally, it would be nice if the RGB colors were configurable, if the user chooses to deviate from libvterm's defaults. This is necessary with many vim colorschemes, since the libvterm colors are difficult to read against certain backgrounds.
—
You are receiving this because you commented.
—
You are receiving this because you commented.
This is necessary with many vim colorschemes, since the libvterm colors are difficult to read against certain backgrounds
Indeed, on macOS they're unusably difficult to read whenever the background is black or nearly so. This by itself is sufficient to make the :terminal
feature worthless to me personally.
—
You are receiving this because you commented.
so when a program running in a terminal window changes the ANSI colors
Sorry, I'm not sure I fully follow. As far as I know, it's not possible for a program running in a terminal window to change the RGB values of the ANSI color palette since libvterm does not support the OSC 4 code for this. If a program uses the basic 8 or 16 ANSI colors, the expectation is that the user has already set up their terminal to their preference- the exact RGB values of these colors are not standardized between terminals so there's no consistency guarantee.
use the specified colors instead of the 16 ANSI colors that Vim uses itself
Yes, but I think it doesn't matter with GUI/termguicolors, since when does a GUI user ever see Vim's built-in 16 ANSI colors? Besides, how does one configure the 16 ANSI colors that GVim uses, as displayed in syntax/colortest.vim? Perhaps Vim's built-in 16 colors could be configured along with libvterm's 16 colors, but there is also little harm if they are distinct.
Or would that mean all the colors that libvterm has should be used?
What I am suggesting is give the Vim user the ability to use do some action or set some option which calls vterm_state_set_palette_color
to change the RGB codes that libvterm knows the ANSI colors by. I am aware this would only work for GUI/termguicolors. A terminal+notermguicolors user would continue to see their normal terminal colors.
—
You are receiving this because you commented.
—
You are receiving this because you commented.
As @lifepillar said, neovim terminal handles colors properly out of the box.
I did not have to set the g:terminal_color_
myself, everything was done automatically.
I don't know how they did it, but could Vim handle terminal colors the same way ?
—
You are receiving this because you commented.
What do you mean with "properly"? Please give a reproducible example. And without using iTerm2, I don't have that.
—
You are receiving this because you commented.
@brammool , first my mistake, g:terminal_color_
are actually set by gruvbox
(my colorscheme plugin).
Then here is the minimal .vimrc to reproduce the different behaviors:
call plug#begin('~/.vim/plugins_by_vimplug') Plug 'morhetz/gruvbox' call plug#end() set termguicolors colorscheme gruvbox
I used gnome-terminal on Ubuntu 16.04.
Here is what ls --color=auto
looks on vim:
Here is what ls --color=auto
looks on neovim:
Maybe setting extra variable is not the right approach, but if it is, would it be possible to keep the same naming convention as in neovim ?
More and more features are slightly different between vim and neovim (terminal, jobs etc) and it makes it harder and harder for users and plug-in developers to support both editors.
Thanks a lot !
—
You are receiving this because you commented.
—
You are receiving this because you commented.
—
You are receiving this because you commented.
There is a need for Vim 8 terminal colors 1 to 16 to be user definable. It is especially important for those of us who maintain Vim colorschemes.
The color issue is most pronounced in MacVim
and gVim
which are GUI programs and hence can not inherit any terminal colors. For instance FZF.vim, which now uses Vim 8 terminal, looks especially bad due to the default terminal colors chosen by MacVim
and gVim
. Allowing terminal color overides, like Neovim already provides, would solve the issue.
New highlight group names like TermColor1
, TermColor2
, etc makes sense as noted by @vim-ml.
—
You are receiving this because you were mentioned.