[vim/vim] Incorrect colors in :terminal (#5346)

151 views
Skip to first unread message

Melandel

unread,
Dec 11, 2019, 11:26:17 AM12/11/19
to vim/vim, Subscribed

Describe the bug
The colors used inside :terminal do not seem to match the colors used from a normal shell.

To Reproduce
Detailed steps to reproduce the behavior:

  1. Install bat
  2. Run bat path/to/some/code/file inside your shell
  3. Open a new shell, run vim inside, then run :terminal
  4. Run bat path/to/some/code/file inside your :terminal window
  5. The colors are not the same in the window from the shell, and in the terminal window inside vim

Expected behavior
The two file previews should look identical

Screenshots
On the right, this is what bat shows when run from a shell:
image

On the right, that is what bat shows when run from a vim :terminal:
image

Environment (please complete the following information):

  • Vim version: 8.1 including patch 1-2197
  • OS: Windows 10 19033.1
  • Terminal: cmd and pwsh.exe

Additional context
I use bat with the default theme, which from their source code, should be Monokai Extended.


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

Bram Moolenaar

unread,
Dec 11, 2019, 4:50:36 PM12/11/19
to vim/vim, Subscribed

I use a test file to check that the colors are exactly the same. Most likely there is something in your setup that isn't quite right.

Melandel

unread,
Dec 11, 2019, 5:13:37 PM12/11/19
to vim/vim, Subscribed

Here's the output with vim -u NONE in %windir%\system32\cmd.exe:
image

What could be other elements of my setup that impact this issue?

Christian Brabandt

unread,
Dec 11, 2019, 5:26:47 PM12/11/19
to vim/vim, Subscribed

Hm, perhaps the windows default terminal is buggy? There is a known problem #5092, perhaps its the same?

Nobuhiro Takasaki

unread,
Dec 11, 2019, 6:20:51 PM12/11/19
to vim/vim, Subscribed

Color problems have been recognized for some time and patches have been written.
I was checking the operation in my real environment.
A similar problem has now been noticed as it has moved away from PC life.

Bram Moolenaar

unread,
Dec 11, 2019, 6:29:51 PM12/11/19
to vim/vim, Subscribed

Oh, you are using an MS-Windows console to run a terminal in? Obviously this has restrictions, since a terminal window is made to run in a terminal (such as xterm), a console in MS-Windows doesn't have nearly the kind of support needed for that. The ConPTY stuff is supposed to make it work, but there are bugs...

Nobuhiro Takasaki

unread,
Dec 11, 2019, 11:01:46 PM12/11/19
to vim/vim, Subscribed

I was able to reproduce it. The display will be crushed. It wasn't just the color difference.
I will do my best to resolve it.

Nobuhiro Takasaki

unread,
Dec 12, 2019, 3:19:13 PM12/12/19
to vim/vim, Subscribed

Maybe ConPTY's device detection '^[[0c' and winpty features are mixed.
'vim -u NONE' starts winpty, ConPTY reports as VT101, bat seems it and outputs in ANSI color.

"vim -u NONE -c 'set termwintype=conpty'" 's :terminal is no color, right.
notermguicolors, t_Co=16 is originally a 16-color palette, and colors are output using the API.

For now, use ConPTY's :terminal. However, not all will be solved.

The line next to the ruled lines becomes trashy, which requires a retest.
Line breaks don't work, this requires additional testing.

Melandel

unread,
Dec 12, 2019, 5:01:28 PM12/12/19
to vim/vim, Subscribed

Thank you so much!

I didn't know about termwintype.

Thanks again!

Nobuhiro Takasaki

unread,
Dec 12, 2019, 8:26:52 PM12/12/19
to vim/vim, Subscribed

Thank you for your report!
I am very encouraged.

Now, ruled lines, the so-called ambiwidth problem. A destructive display in my environment. This does not solve cleanly.

Shane-XB-Qian

unread,
Dec 13, 2019, 2:33:41 AM12/13/19
to vim/vim, Subscribed

probably it do had a issue, i was thinking if that's a bug also, though maybe not same issue like here.
for example: yellow '^[[1;33mtest' that's a different color in my xfce-term and :term in vim.
but problem maybe just about highlight or bold of one color.

Nobuhiro Takasaki

unread,
Dec 13, 2019, 6:02:53 AM12/13/19
to vim/vim, Subscribed

The color is different between the newly installed Windows 10 terminal and the Windows 10 terminal updated from the previous Windows. Incredible.
Color development is a heavy issue. I care and do my best.

Shane-XB-Qian

unread,
Dec 13, 2019, 7:58:42 AM12/13/19
to vim/vim, Subscribed

um, that issue said actually not specific to windows, but linux also, probably mac same.
just a fyi to @brammool , it did not impact sth, but just the color looks different between :term of vim and outside.
as for issue this ticket saying, pls keep going, sorry jump in.. :)

Nobuhiro Takasaki

unread,
Dec 14, 2019, 1:03:19 AM12/14/19
to vim/vim, Subscribed

There is also such a thing.
#5359

Nobuhiro Takasaki

unread,
Dec 14, 2019, 4:34:09 AM12/14/19
to vim/vim, Subscribed

I read the source code. Vim script is easier to implement. Well...

Shane-XB-Qian

unread,
Dec 15, 2019, 1:51:38 AM12/15/19
to vim/vim, Subscribed

@ntak vim script sometime was not the best option either :)
compiled within vim itself sometime can avoid sth .. just jumped such out of my mind.
you are doing great.

Bram Moolenaar

unread,
Dec 15, 2019, 7:51:28 AM12/15/19
to vim/vim, Subscribed

I have tuned the behavoir of the terminal window using src/testdir/color_ramp.vim. That works perfectly in an xterm now: "cat testdir/color_ramp.txt" shows the same colors at the shell prompt as inside a terminal window. Since the terminal window uses an xterm-like terminal this is possible, for Windows it will be more tricky. But we can try.

Shane-XB-Qian

unread,
Dec 16, 2019, 4:33:43 AM12/16/19
to vim/vim, Subscribed

those looks for 256 colors, but for palette - looks some term has its own setting.
anyway, to my issue i bring up here, i found it caused by my term has a option to switch bold to bright.
that's why color looks was not its intact one. @brammool gave me some tips.

Melandel

unread,
Jul 5, 2020, 12:10:16 PM7/5/20
to vim/vim, Subscribed

I am using ntak's fix for now (set termwintype=conpty from this comment) and though the colors are fixed, I find myself unable to use arrows, home and end keys.

I can confirm that removing set termwintype=conpty gives me back support of arrows, and keys.

I'm using gvim v8.2.1127 on Windows10, with the vifm.vim plugin:

  • on the left, set termwintype= with ability to use <up>, <down>, <left>, <right>, <home> and <end> but incorrect colors
  • on the right, set termwintype=conpty with correct colors but <up>, <down>, <left>, <right>, <home> and <end> don't seem to respond
    image

Melandel

unread,
Dec 13, 2021, 7:53:27 AM12/13/21
to vim/vim, Subscribed

Any news on this issue?


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

Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

JesseBot

unread,
Nov 2, 2022, 11:27:34 AM11/2/22
to vim/vim, Subscribed

My issue may be unrelated as windows is being discussed here and I'm on macOS, but my colors are also not as would seem correct.

I have set termguicolors in my .vimrc and I am also seeing issue with the way colors are working for :terminal right now. I am using iterm2 and this version of vim:

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Oct 19 2022 18:24:48)
macOS version - x86_64

I also have export TERM=xterm-256color in my .bashrc.

I'll use neofetch to show color examples, since it outputs the main terminal colors.

This is just my normal BASH config in iterm2:
Schermafbeelding 2022-11-02 om 15 52 56

I moved my actual .vimrc out of the way so I could test with the minimal settings you see on the right side of each image below.

This is without set termguicolors, which fixes the shell, but breaks my vim colorscheme:
Schermafbeelding 2022-11-02 om 16 10 52

This is with set termguicolors, which fixes my vim colorscheme, but breaks the :terminal colors:
Schermafbeelding 2022-11-02 om 16 10 20

Perhaps I am just doing something wrong, or there is an additional setting I should be aware of?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/5346/1300676886@github.com>

Christopher Plewright

unread,
Nov 2, 2022, 5:55:20 PM11/2/22
to vim/vim, Subscribed

Can I ask what happens after you exit vim, but stay in the same terminal session? Does vim then correctly restore the terminals colors to what they were previously, or do they stay different until you restart the terminal?

I'm thinking it maybe similar to what i'm fixing for windows. In windows, Vim tries to get the terminals default color table (the colors mapped to the standard 16 ansi color names), and then change that table while vim is running, and then tries to restore it on exit. This fails on the new windows terminal, because windows has changed how they reports the colortable - it doesnt mean the same thing anymore as it used to in the old command prompt console.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/5346/1301362183@github.com>

Maxim Kim

unread,
Nov 2, 2022, 11:38:32 PM11/2/22
to vim/vim, Subscribed

Perhaps I am just doing something wrong, or there is an additional setting I should be aware of?

With termguicolors, vim uses g:terminal_ansi_colors variable to set up 16 colors of built-in terminal. If you (or your colorscheme) didn't set it up, then I guess some default hardcoded values are used.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/5346/1301605375@github.com>

Reply all
Reply to author
Forward
0 new messages