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

Italicize comments in Vim #101

Merged
merged 1 commit into from
Jan 31, 2021
Merged

Italicize comments in Vim #101

merged 1 commit into from
Jan 31, 2021

Conversation

jawang35
Copy link
Contributor

@jawang35 jawang35 commented Nov 28, 2020

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

@sonph sonph merged commit 141c775 into sonph:master Jan 31, 2021
@fatteneder
Copy link

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

This does not apply to my setup:

  • Alacritty - 0.7.1
  • Vim - 8.2

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

image

@garrettn
Copy link

garrettn commented Feb 2, 2021

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
Copy link
Owner

sonph commented Feb 3, 2021

@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: alacritty/alacritty#1977.

@jawang35
Copy link
Contributor Author

jawang35 commented Feb 3, 2021

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
Copy link

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
Copy link

marcuslannister commented Feb 20, 2021

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
Copy link

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

@marcuslannister
Copy link

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

@jawang35
Copy link
Contributor Author

jawang35 commented Feb 21, 2021

@marcuslannister that's a good suggestion and it looks like other color schemes use the same pattern. I've implemented it in #108.

@alovak
Copy link

alovak commented Mar 12, 2021

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/

t4ku added a commit to t4ku/onehalf that referenced this pull request Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants