Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting fish_term24bit to 1 breaks colors in neovim terminal #2600

Closed
raichoo opened this issue Dec 11, 2015 · 18 comments
Closed

Setting fish_term24bit to 1 breaks colors in neovim terminal #2600

raichoo opened this issue Dec 11, 2015 · 18 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@raichoo
Copy link
Contributor

raichoo commented Dec 11, 2015

I just wanted to report this so that fellow neovim users might know what it going on.

Commit b73bf53bd30cb8b6056888a473368968041dbe66 sets fish_term24bit to 1 on truecolor terminals. This breaks my highlighting in neovim like so:

screenshot from 2015-12-11 23-10-54

What I'm expecting is something like this:

screenshot from 2015-12-11 23-03-53

I work around this issue by putting something along these lines into my config.fish.

if test "$NVIM_LISTEN_ADDRESS" = ""
 # snip
else
  set -u fish_term24bit
  #snip
end

It's a little bit of a hack but does the job.

Kind regards,
raichoo

@ridiculousfish
Copy link
Member

Thanks for the report! I don't understand what the issue is however. Is it that neovim has its own terminal emulator, but it's picking up environment variables from the "root" terminal emulator, and therefore fish thinks 24 bit color is supported?

@faho
Copy link
Member

faho commented Dec 12, 2015

@raichoo: Is this still your nvimrc?

What's your config.fish?

I work around this issue by putting something along these lines into my config.fish

Last I heard and when I just tested it, nvim assumes the shell is sh-compatible, so you'd have set shell=/bin/sh in your rc or it breaks in new and interesting ways. Can you try that?

The reason I'm asking is because it seems nvim inheriting fish_term24bit breaks stuff, which is weird because to nvim it should just be another environment variable that it shouldn't care about. So it seems it's running fish somewhere which is known to cause issues.

@faho
Copy link
Member

faho commented Dec 12, 2015

I just tried that nvimrc verbatim, and it works for me. So I'd like to take a look at your config.fish now.

Also, what is your terminal emulator?

@pickfire
Copy link
Contributor

@raichoo, don't use fish as the shell for nvim as it will break a lot of things. Use set shell=/bin/sh instead like what @faho says.

I am not sure how to check if fish is using 24bits color. I can't reproduce this by:

  1. nvim
  2. :terminal
  3. fish

@raichoo
Copy link
Contributor Author

raichoo commented Dec 12, 2015

fish works fine for me with nvim.

@ridiculousfish: I've turned on true color support for nvim but the build in terminal does not support true colors (this will be fixed some time in the future). I suppose this is where the mixup happens.

@pickfire
Copy link
Contributor

@raichoo, take a look at https://gist.github.com/XVilka/8346728 to make sure you have true colors support in terminal in order to use true colors in nvim.

@raichoo
Copy link
Contributor Author

raichoo commented Dec 12, 2015

I have true color support. It's the built in terminal of nvim that does not support that yet (there is an open issue addressing that).

@faho
Copy link
Member

faho commented Dec 12, 2015

@raichoo: Again, what is in your config.fish? I've ran ":terminal" in nvim, which then launched an embedded fish, with your exact nvimrc (at least what you have uploaded to github) and it worked. (This is with neovim 0.1.1 in konsole 15.08.3 on archlinux)

@pickfire
Copy link
Contributor

@raichoo, as @faho asked: What is your terminal emulator?

That's easy for us to test it and to check for problems.

@faho
Copy link
Member

faho commented Dec 28, 2015

@raichoo: Ping?

@rakr
Copy link

rakr commented Jan 11, 2016

Not sure if it is the right place as I'm just discovering fish.
My setup: Iterm2 nightly Build 2.9.20160108-nightly
config.fish contains set -u fish_term24bit and everything works perfectly.
Again just a couple of hours on fish, but amazing so far. I thought I had the same issue as mentioned here, but realised that was because I was using an alias in zsh that I didn't create on fish (face palm)

@pickfire
Copy link
Contributor

@rakr, if the terminal is detected to support true colors (by $TERM), fish will automatically set fish_term24bit for you.

You can actually use set -Ux fish_term24bit 1 instead of setting it in config.sh if you want to set it everytime, but note that it will break framebuffer.

@krader1961
Copy link
Contributor

@pickfire, You said

if the terminal is detected to support true colors (by $TERM), fish will automatically set fish_term24bit for you.

As far as I can tell that is not true. Fish will, however, automatically set fish_term256 based on $TERM. See function update_fish_color_support in input.cpp.

@faho
Copy link
Member

faho commented Jan 13, 2016

@krader1961: https://github.com/fish-shell/fish-shell/blob/master/share/functions/__fish_config_interactive.fish#L289-L296. It's a hack, but it's the best we can do.

I'll have to recheck which of those cases is true in nvim's terminal.

@krader1961
Copy link
Contributor

Ah, yes, I was only looking at the core C++ code, @faho, and had forgotten about that recent addition to the interactive function. But that raises the question of whether we should move the equivalent logic for setting fish_term256 out of the C++ update_fish_color_support function and into that fish script function.

@raichoo, can you tell us what the values of the following env vars are inside your neovim terminal: KONSOLE_PROFILE_NAME, ITERM_SESSION_ID, TERM, VTE_VERSION, COLORTERM?

@faho
Copy link
Member

faho commented Jan 14, 2016

Urgh, I've found the issue.

neovim's terminal swallows the 24bit sequences without interpreting them, even in a terminal. That means e.g. echo \e"[38;2;85;136;255mbanana" will show a white "banana". This is just what fish will send for echo (set_color 5588FF)banana if fish_term24bit is set. (This does not change with NVIM_TUI_ENABLE_TRUE_COLOR set)

The reason I didn't see that is because fish still sends the old-school sequences for named colors (set_color banana).

can you tell us what the values of the following env vars are inside your neovim terminal: KONSOLE_PROFILE_NAME, ITERM_SESSION_ID, TERM, VTE_VERSION, COLORTERM?

TERM is set to xterm-256color, the rest seem to be inherited from the environment. There's also a $NVIM_LISTEN_ADDRESS set.

There's a few ways to deal with it:

  • Ignore it - nvim's supposed to get 24bit support soon (tm)
  • Back out the 24bit enabling entirely
  • Guard it with not set -q NVIM_LISTEN_ADDRESS

Of those, I like the last the most, though it's possible neovim GUIs also set that and do interpret the 24bit sequences properly, I consider (and this was a major goal of that way of enabling 24bit) it more important that nothing gets the colors wrong than that everything gets the colors right.

@faho
Copy link
Member

faho commented Jan 14, 2016

@raichoo, @rakr: I believe this is now fixed - by disabling 24bit for nvim.

@faho faho added the bug Something that's not working as intended label Jan 14, 2016
@faho faho added this to the next-2.x milestone Jan 14, 2016
@rakr
Copy link

rakr commented Jan 20, 2016

Great thanks

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

6 participants