sonph / onehalf

Clean, vibrant and pleasing color schemes for Vim, Sublime Text, iTerm, gnome-terminal and more.
MIT License
1.78k stars 236 forks source link

Italicize comments in Vim #101

Closed jawang35 closed 3 years ago

jawang35 commented 3 years ago

Italicized comments are popular for Vim users and IMO they look pretty good. This won't have any effect on terminals that don't support italics.

Screen Shot 2020-11-28 at 8 59 38 AM

fatteneder commented 3 years ago

This won't have any effect on terminals that don't support italics.

This does not apply to my setup:

Here is a picture how it looks like. Anybody got an idea how to fix this?

image

garrettn commented 3 years ago

This happened to me too, on Kitty with the light theme. I was able to fix it by adding this line to my .vimrc:

hi Comment gui=NONE cterm=NONE

This basically cancels out the change. It's weird because Kitty supposedly supports italic fonts. Maybe I don't have my fonts configured correctly.

Edit: The font I'm using (Fira Code) apparently doesn't have an italic variant, which I guess results in the gray background.

sonph commented 3 years ago

@fatteneder usually most terminals will have options to enable/disable bold and italic font styles. Maybe you can check your alacritty config? I don't use alacritty myself but a google search turned up some results such as this: https://github.com/alacritty/alacritty/issues/1977.

jawang35 commented 3 years ago

Terminals that don't support italics will indicate so in their terminfo file. AFAIK Alacritty and Kitty (which I use) both support italics. I'm guessing the issue you're seeing is probably @garrettn's suggestion that your font might not support italics. You should be able to specify a non-italic font in your terminal.

For Alacritty, in your alacritty.yml (using Fira Code as an example):

font:
  italic:
    family: Fira Code
    style: Regular
  bold_italic:
    family: Fira Code
    style: Bold

For Kitty, in your kitty.conf (using Fira Code as an example):

italic_font      Fira Code Regular
bold_italic_font Fira Code Bold
fatteneder commented 3 years ago

Thank you for all the replies.

After I wrote this issue yesterday I did some research myself and also tried to enable an italic font in my .alacritty.yaml. I could not get it to work yet. Interestingly, other terminals (Terminal.app and iTerm2) I tested also do not display italic fonts, but MacVim does. So this seems to be a more general problem with my setup which started showing up after updating my system yesterday. Since then I have also missing symbols in my vim-airline status line...

Anyways, for now I will use @garrettn's fix till I figure out how to get italics to work.

marcuslannister commented 3 years ago

I have same issue as @fatteneder , my platform is macOS Big Sur with iTerm2 (font is Hack that support italic).

I change line 126 on onehalf/vim/colors/onehalflight.vim

call s:h("Comment", s:comment_fg, "", "italic")

to

call s:h("Comment", s:comment_fg, "", "")

then it is ok.

marcuslannister commented 3 years ago

@fatteneder You can check this link to get italic to work.

marcuslannister commented 3 years ago

@jawang35 I suggest disable italic on the default setting, then add a vim variable to enable italic.

jawang35 commented 3 years ago

@marcuslannister that's a good suggestion and it looks like other color schemes use the same pattern. I've implemented it in https://github.com/sonph/onehalf/pull/108.

alovak commented 3 years ago

If you still want comments in italic in iterm+tmux (taken from here):

  1. Create two files:

File xterm-256color-italic.terminfo:

# A xterm-256color based TERMINFO that adds the escape sequences for italic.
xterm-256color-italic|xterm with 256 colors and italic,
  sitm=\E[3m, ritm=\E[23m,
  use=xterm-256color,

File tmux-256color-italic.terminfo:

# A xterm-256color based TERMINFO that adds the escape sequences for italic.
tmux-256color-italic|tmux with 256 colors and italic,
  sitm=\E[3m, ritm=\E[23m,
  use=xterm-256color,
  1. tic them both
tic xterm-256color-italic.terminfo
tic tmux-256color-italic.terminfo
  1. Tell your terminal to use xterm and tmux to use tmux with overrides.

Figure out how to set your terminals $TERM variable to xterm-256color-italic. In iTerm it's in Prefs -> profiles -> Terminal -> Report Terminal Type.

In your .tmux.conf file:

# tmux display in 256 colours
set -g default-terminal "tmux-256color-italic"
#  enable terminal compatibility with outside terminal
set-option -ga terminal-overrides ",xterm-256color-italic:Tc"
  1. Restart iterm, tmux. Done!

You may also find this article useful (to enable italic in iterm): https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/