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

FZF colors no longer match your color scheme #1152

Open
blayz3r opened this issue Oct 28, 2020 · 33 comments
Open

FZF colors no longer match your color scheme #1152

blayz3r opened this issue Oct 28, 2020 · 33 comments
Labels

Comments

@blayz3r
Copy link

blayz3r commented Oct 28, 2020

After v0.24
image

Before v0.18
image

" Customize fzf colors to match your color scheme
let g:fzf_colors =
            \ { 'fg':      ['fg', 'Normal'],
            \ 'bg':      ['bg', 'Normal'],
            \ 'hl':      ['fg', 'Comment'],
            \ 'fg+':     ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
            \ 'bg+':     ['bg', 'CursorLine', 'CursorColumn'],
            \ 'hl+':     ['fg', 'Statement'],
            \ 'info':    ['fg', 'PreProc'],
            \ 'border':  ['fg', 'Ignore'],
            \ 'prompt':  ['fg', 'Conditional'],
            \ 'pointer': ['fg', 'Exception'],
            \ 'marker':  ['fg', 'Keyword'],
            \ 'spinner': ['fg', 'Label'],
            \ 'header':  ['fg', 'Comment'] }
@junegunn
Copy link
Owner

Works for me.

@blayz3r
Copy link
Author

blayz3r commented Oct 28, 2020

I am windows 10 maybe that's why

@blayz3r
Copy link
Author

blayz3r commented Oct 28, 2020

The code below looks redundant now

" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }

@blayz3r blayz3r closed this as completed Oct 28, 2020
@blayz3r
Copy link
Author

blayz3r commented Oct 28, 2020

#1141

@blayz3r
Copy link
Author

blayz3r commented Oct 29, 2020

junegunn/fzf#1858

@blayz3r blayz3r reopened this Oct 30, 2020
@blayz3r
Copy link
Author

blayz3r commented Oct 30, 2020

2020-10-30_13-34-59

Latest update destroyed everything.....

@junegunn
Copy link
Owner

What do you mean by "Latest update"?

@blayz3r
Copy link
Author

blayz3r commented Oct 30, 2020

junegunn/fzf@7915e36, Sorry not sure what issue goes here or the other repo

junegunn added a commit to junegunn/fzf that referenced this issue Oct 30, 2020
@junegunn
Copy link
Owner

I see. I reverted the commit.

/cc @wjrogers

@kelleyma49
Copy link

kelleyma49 commented Oct 30, 2020

VimFzf
Using just the --height option seems to work fine (see above.) It must be an issue with rendering in the popup. The --height option uses the light renderer on Windows, if available.

I'm not a vim expert, so can someone give me the simpliest way to run fzf.exe in a vim popup window?

@junegunn
Copy link
Owner

@kelleyma49 Hi, thanks for chiming in. The latest version of the Vim plugin runs fzf inside a popup window by default.

If you don't use Vim at all and are not familiar with its plugin ecosystem. Here is an easy way to try it:

  1. Git clone https://github.com/junegunn/fzf
  2. Load the file with the command: :source <CLONE DIR>/plugin/fzf.vim
  3. Run :FZF
    • It will use fzf in your PATH if available

Since the Vim plugin determines the size of the popup window, it doesn't use --height option at all. It actually appends --no-height at the end of the option string.

@junegunn
Copy link
Owner

junegunn commented Oct 31, 2020

After reading #1141, now I realized that the image you titled "After v0.24" is actually showing the right colors. The colors shown in "Before v0.18" are incorrect. So this is not an issue.

@blayz3r blayz3r reopened this Oct 31, 2020
@blayz3r
Copy link
Author

blayz3r commented Oct 31, 2020

After reading #1141, now I realized that the image you titled "After v0.24" is actually showing the right colors. The colors shown in "Before v0.18" are incorrect. So this is not an issue.

Isn't setting g:fzf_colors supposed to match the vim colorscheme... If not how do you get FZF to match your colorscheme after 0.24

@junegunn
Copy link
Owner

junegunn commented Oct 31, 2020

I don't have a Windows 10 PC to test this, so I can only guess. The colors in the first picture are not the default colors of fzf, which made me think that the variable was playing its part. However, it's indeed strange that the background color is not changed. A few things to check:

  1. Have you tried switching to a different color scheme and run fzf with it? No difference?
  2. What is the output of :echo fzf#wrap().options? Does it contain proper --color configuration?
  3. If so, open up a terminal inside Vim (:terminal) and run fzf with the options. Are the colors correct? Do you see the same colors when you run the same command on Command Prompt (cmd) outside of Vim?
  4. Do you see no difference in colors when you unlet g:fzf_colors?

@blayz3r
Copy link
Author

blayz3r commented Oct 31, 2020

echo fzf#wrap().options shows:

--color=bg+:236,bg:235,spinner:170,hl:59,fg:145,header:59,info:180,pointer:170,marker:204,fg+:145,prompt:170,hl+:170

The colors match what is in the terminal
image

I am starting to think it is a limitation of the terminal?

unletting g:fzf_colors matches my colorscheme slightly better

image

Is this relevant:
junegunn/fzf#1858 (comment)

@junegunn
Copy link
Owner

junegunn commented Oct 31, 2020

So these are 256 ANSI colors rather than 24-bit true colors,

--color=bg+:236,bg:235,spinner:170,hl:59,fg:145,header:59,info:180,pointer:170,marker:204,fg+:145,prompt:170,hl+:170

and the difference you see (such as the background color) is due to the limitation of the 256-color palette.

The latest version of fzf does support 24-bit colors on Windows, but the Vim plugin is not generating 24-bit colors according to g:fzf_colors on Windows because not all terminals on Windows are capable of displaying 24-bit colors. See junegunn/fzf#1793.

This patch will make g:fzf_colors generate 24-bit colors (i.e. :echo fzf#wrap().options will show something like --color=bg+:#3F3F3F,bg:#4B4B4B,border:#6B6B6B,spinner:#98BC99 ...), but I have no idea if GVim on Windows is able to display the colors.

diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 14d0276..1eef9e3 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -303,7 +303,7 @@ function! s:common_sink(action, lines) abort
 endfunction
 
 function! s:get_color(attr, ...)
-  let gui = !s:is_win && !has('win32unix') && has('termguicolors') && &termguicolors
+  let gui = has('gui_running') || has('termguicolors') && &termguicolors
   let fam = gui ? 'gui' : 'cterm'
   let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
   for group in a:000

@blayz3r
Copy link
Author

blayz3r commented Oct 31, 2020

So these are 256 ANSI colors rather than 24-bit true colors,

--color=bg+:236,bg:235,spinner:170,hl:59,fg:145,header:59,info:180,pointer:170,marker:204,fg+:145,prompt:170,hl+:170

and the difference you see (such as the background color) is due to the limitation of the 256-color palette.

The latest version of fzf does support 24-bit colors on Windows, but the Vim plugin is not generating 24-bit colors according to g:fzf_colors on Windows because not all terminals on Windows are capable of displaying 24-bit colors. See junegunn/fzf#1793.

This patch will make g:fzf_colors generate 24-bit colors (i.e. :echo fzf#wrap().options will show something like --color=bg+:#3F3F3F,bg:#4B4B4B,border:#6B6B6B,spinner:#98BC99 ...), but I have no idea if GVim on Windows is able to display the colors.

diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 14d0276..1eef9e3 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -303,7 +303,7 @@ function! s:common_sink(action, lines) abort
 endfunction
 
 function! s:get_color(attr, ...)
-  let gui = !s:is_win && !has('win32unix') && has('termguicolors') && &termguicolors
+  let gui = has('gui_running') || has('termguicolors') && &termguicolors
   let fam = gui ? 'gui' : 'cterm'
   let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
   for group in a:000

New output

--color=bg+:#2C323C,bg:#282C34,spinner:#C678DD,hl:#5C6370,fg:#ABB2BF,header:#5C6370,info:#E5C07B,pointer:#C678DD,marker:#E06C75,fg+:#ABB2BF,prompt:#C678DD,hl+:#C678DD

Yes, that change would fix the issue

@blayz3r
Copy link
Author

blayz3r commented Nov 1, 2020

So these are 256 ANSI colors rather than 24-bit true colors,

--color=bg+:236,bg:235,spinner:170,hl:59,fg:145,header:59,info:180,pointer:170,marker:204,fg+:145,prompt:170,hl+:170

and the difference you see (such as the background color) is due to the limitation of the 256-color palette.

The latest version of fzf does support 24-bit colors on Windows, but the Vim plugin is not generating 24-bit colors according to g:fzf_colors on Windows because not all terminals on Windows are capable of displaying 24-bit colors. See junegunn/fzf#1793.

This patch will make g:fzf_colors generate 24-bit colors (i.e. :echo fzf#wrap().options will show something like --color=bg+:#3F3F3F,bg:#4B4B4B,border:#6B6B6B,spinner:#98BC99 ...), but I have no idea if GVim on Windows is able to display the colors.

diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 14d0276..1eef9e3 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -303,7 +303,7 @@ function! s:common_sink(action, lines) abort
 endfunction
 
 function! s:get_color(attr, ...)
-  let gui = !s:is_win && !has('win32unix') && has('termguicolors') && &termguicolors
+  let gui = has('gui_running') || has('termguicolors') && &termguicolors
   let fam = gui ? 'gui' : 'cterm'
   let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
   for group in a:000

I can close this if you commit this change....

@junegunn
Copy link
Owner

junegunn commented Nov 2, 2020

Unfortunately, it's not that simple. I have a Windows 2016 server and GVim running there does not properly display 24-bit colors in its terminal (it's probably a limitation of old cmd.exe) so this change makes the colors way worse.

  • Can we be sure that 24-bit colors are supported on Windows 2019?
  • If so, is there a way in Vim to find out if we're running Windows 2019?

/cc @janlazo

@blayz3r
Copy link
Author

blayz3r commented Nov 2, 2020

From what I gather windows 10 terminals/consoles have had 24 bit color support by default since 2017.

2016 initial implementation.
https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/ but I'll let others chime in

2017 widespread support
microsoft/WSL#2178 (comment)

@janlazo
Copy link
Contributor

janlazo commented Nov 3, 2020

On Vim, there is has('conpty') and termmode option from vim/vim@aa5df7e. termmode is renamed to termwintype in vim/vim@c6ddce3. There is an open PR on Neovim for has('conpty').

If https://github.com/microsoft/terminal is the terminal for cmd.exe and powershell.exe on recent versions of Windows 10, then the earliest stable v1.x release is https://github.com/microsoft/terminal/releases/tag/v1.0.1401.0, released on May 19, 2020.

@blayz3r
Copy link
Author

blayz3r commented Nov 4, 2020

@junegunn as an aside does GFiles? work on Windows 2016 server

@junegunn
Copy link
Owner

junegunn commented Nov 5, 2020

@blayz3r Yes, both :GF and :GF? work as expected.

@blayz3r
Copy link
Author

blayz3r commented Nov 5, 2020

:GF?

Even the preview:
image

I'll debug on my end then

@blayz3r blayz3r closed this as completed Nov 24, 2020
@blayz3r blayz3r reopened this Dec 12, 2020
@ecmrauh
Copy link

ecmrauh commented Dec 15, 2020

I had a similar problem on Linux (Debian 10, KDE). In my terminal (Konsole), everything worked as expected, but in GVim, the colors didn't match the color scheme (as in your screenshot above). After setting ...

set termguicolors

... in my .gvimrc (or .vimrc, that doesn't matter), the colors matched the color scheme in GVim.

@dkarter
Copy link

dkarter commented Dec 17, 2020

I'm on Mac and not sure if this is related, but I run fd as the FZF_DEFAULT_COMMAND:

let $FZF_DEFAULT_COMMAND = 'fd --type f --hidden --follow --color=always -E .git --ignore-file ~/.gitignore'

Since updating to the latest version today e9d62b4, all colors started looking off:
CleanShot 2020-12-16 at 19 19 36@2x

@junegunn
Copy link
Owner

@dkarter

Try starting a terminal buffer and run fzf there.

:term

echo $TERM
fzf

@dkarter
Copy link

dkarter commented Dec 17, 2020

@junegunn Thank you so much! You are correct the issue was caused due to a PR on my colorscheme that removed those g:terminal_color_* settings rakr/vim-one#104

@blayz3r
Copy link
Author

blayz3r commented Dec 19, 2020

On Vim, there is has('conpty') and termmode option from vim/vim@aa5df7e. termmode is renamed to termwintype in vim/vim@c6ddce3. There is an open PR on Neovim for has('conpty').

If https://github.com/microsoft/terminal is the terminal for cmd.exe and powershell.exe on recent versions of Windows 10, then the earliest stable v1.x release is https://github.com/microsoft/terminal/releases/tag/v1.0.1401.0, released on May 19, 2020.

So this issue can be closed if we add the above condition to:

 function! s:get_color(attr, ...)
-  let gui = !s:is_win && !has('win32unix') && has('termguicolors') && &termguicolors
+  let gui = has('gui_running') || has('termguicolors') && &termguicolors
   let fam = gui ? 'gui' : 'cterm'
   let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
   for group in a:000

kralicky pushed a commit to kralicky/fzf that referenced this issue Jun 23, 2021
@kian1245
Copy link

2020-10-30_13-34-59

Latest update destroyed everything.....

hello use ubuntu or debian

@Kamholtz
Copy link

It seems that this is blocked by a need to maintain compatibility with cmd.exe but not having a way to determine whether the terminal supports 24 bit colours or not. Can I suggest adding an option g:fzf_force_24_bit_colors to allow windows users to get around this issue in the meantime? I have made a pull request on the fzf repository here:

junegunn/fzf#2889

@Freedzone
Copy link

Freedzone commented Oct 29, 2022

For Windows GVim users, I could fix the issue with these 2 options:

set termwintype=conpty
let g:fzf_force_termguicolors = 1

Also if you want the embedded terminal to match your color scheme add this:

highlight! link Terminal Normal

@Sharlock93
Copy link

Sharlock93 commented Aug 1, 2023

Just leaving a note here regarding the above comment about using conpty, on my machine (Windows 11) doing a :Files and then hitting escape to close the popup causes a hang in vim, breaking this in a debugger somewhere its waiting on conpty to either close or do something. Leaving this comment here just in case someone runs into it.

This is an issue in vim and not fzf.vim: vim/vim#12438 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants