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

Incorrect color contrast on vim with st #166

Closed
lucassardois opened this issue Jun 25, 2019 · 15 comments
Closed

Incorrect color contrast on vim with st #166

lucassardois opened this issue Jun 25, 2019 · 15 comments

Comments

@lucassardois
Copy link

lucassardois commented Jun 25, 2019

I'm using vim 8.1 (with +termguicolors) inside st under dwm. I applied the nord theme to st. I installed nord trough Plug as recommended.

But for some reason some colors are incorrect inside vim... For instance as you can see on the screenshots line numbers and comments color are to close to the background color.

More, there is no visual selection color at all. Everything else looks ok trough...

1561487256

@arcticicestudio
Copy link
Contributor

Hi @loustak 👋, please note that the linked st theme is not an official theme but a contribution of a Nord user. I've not checked if the used colors are matching Nord's styles for syntax highlighting so your problem might be related to this.
I've quickly checked the proposed theme and the adjustment of Nord's comment color is not included. This explains why comments and the line numbers using a darker color ( nord3) instead of the new #616e88 value ( nord3 brightness increased by 10%).

Also another problem might be that you Vim and terminal is not configured to use true colors. Can you please try to add the following config to your .vimrc and check if the problem still occurs:

if (has("termguicolors"))
  set termguicolors
endif

Also please make sure you're running at least Nord Vim v0.10.0 or higher, otherwise the new comment color is also not supported.

@lucassardois
Copy link
Author

Thanks for the answer @arcticicestudio. I tried changing the color inside my st configuration to the new nord3 color. No changes.

I checked my vim and tried set termguicolors it make all the text goes white:
1561628833

I checked the nord vim version inside nord.vim installed by plug, and I'm using v0.12.0:

let s:nord_vim_version="0.12.0"

@lucassardois
Copy link
Author

lucassardois commented Jun 27, 2019

I found a solution: vim/vim#993 (comment)

Adding the following lines to my .vimrc before setting the colorsheme solved all my colors problems:

" set Vim-specific sequences for RGB colors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

if (has("termguicolors"))
  set termguicolors
endif

colorscheme nord

@DictumMortuum
Copy link

Did the same thing, however I still can't get the current line highlight to work.
Maybe that requires a different sequence?

@lucassardois lucassardois reopened this Jun 27, 2019
@lucassardois
Copy link
Author

@DictumMortuum you are right. I didn't noticed it first but I have the exact same issue. So I reopen it.

@arcticicestudio
Copy link
Contributor

Has someone found a solution to also enable highlight support for the current cursor line?
I haven't installed and configured st so having some help here would be nice to resolve this ticket.

@arcticicestudio arcticicestudio added the help wanted GitHub filter label for contributors to signal that help is needed label Jul 21, 2019
@DictumMortuum
Copy link

I'd be happy to help, but I'm not sure what I should do - do you want me to try anything?

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Jul 23, 2019

Does it work if you're disabling italic font rendering in both st and the specific Nord theme configuration? Might be possible that there are conflicts with the terminal sequences.
Also are you running Vim within tmux? If yes, it might be possible that there is a wrong configuration for tmux like a missing or invalid default-terminal value (set -g default-terminal "tmux-256color").

@ghost
Copy link

ghost commented Jul 25, 2019

Hi !

St + vim works perfectly for me with this configuration. 😉

St + Vim
st_nord

St + Tmux + Vim
st_nord_tmux

" ~/.vimrc

if exists('+termguicolors') && ($TERM == "st-256color" || $TERM == "tmux-256color")
	let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
	let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
	set termguicolors
endif

let g:nord_italic = 1
let g:nord_italic_comments = 1
let g:nord_underline = 1
let g:nord_uniform_status_lines = 1
let g:nord_uniform_diff_background = 1
let g:nord_cursor_line_number_background = 1
colorscheme nord
# ~/.tmux.conf

# $TERM, fix colors
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",*256col*:Tc"

Source : tmux/tmux#1246 (comment)

@lucassardois
Copy link
Author

For my case, I'm not running vim inside tmux.
@cyrilaugier can you provide the versions of st, vim and nord please? Because I have the same setup without tmux and I don't get the current line highlighted.
1564073697

@arcticicestudio
Copy link
Contributor

@cyrilaugier Thanks, this helps a lot to encircle the root cause 👍

@loustak I guess I've also misunderstood your actual problem: I thought you're having wrong styles for the current line highlighting (like e.g. too dark or totally wrong color), but I guess this is also just a Vim setup problem on your side.
Have you enabled Vim's cursorline option? Otherwise the current line won't be highlighted at all 😄
You can add set cursorline to your vimrc to enable it by default or run the command from within Vim.

@lucassardois
Copy link
Author

Okay, I'm stupid, I just forgot to add the cursorline option...

The issue seems close now.

@arcticicestudio
Copy link
Contributor

@loustak Not stupid, human. I could tell you a lot of private or job-related development/coding situations where I was like "wow, the fix was a one-liner" after spending hours with debugging 🙃
Glad to see it works for your now.

@DictumMortuum Could you please also check if you're just missing the cursorline option? Otherwise we need to check other settings that might conflict with the theme.

@DictumMortuum
Copy link

DictumMortuum commented Jul 26, 2019 via email

@DictumMortuum
Copy link

Confirmed, I'd forgot to set the cursorline option. I think that we can close!

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

No branches or pull requests

4 participants