fraxture
fraxture

Reputation: 5510

How to use the Operator font with neovim?

I am trying to setup my neovim with the operator mono. I am running neovim in iterm2, so I have used the profile preferences to select the Operator font, and that is more or less working.

However I would rather use my vimrc to specify the font for neovim. So my first question is whether that is possible?

Partly, I'd like to do that because I would like to take advantage of the Operator fonts special italics. Normally, I'd activate those for comments in my vimrc like so:

highlight Comment gui=italic
highlight Comment cterm=italic
highlight htmlArg gui=italic
highlight htmlArg cterm=italic

However, these don't seem to work with neovim. So my second question is: how do I activate Operator italic font for commented out code in neovim.

Thanks!

Upvotes: 0

Views: 2524

Answers (1)

nabn
nabn

Reputation: 2408

AFAIK, terminal vim/neovim use the font-family that's specified in your terminal emulator preferences. So no, you can't specify the font family in your vimrc.

To get italic comments, create a xterm-256color-italic.terminfo anywhere on your computer with these contents:

 # 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,

then do tic xterm-256color-italic.terminfo (from the same location as the file). This will create a new TERMINFO to be added to the TERM database.

Now, to setup iterm2 to use this terminfo, set Report Terminal Type under Terminal tab of your iterm profile to the value xterm-256color-italic (type it manually as it might not show up on the dropdown menu.

enter image description here

If you relaunch iterm2, you should have italic comments now with highlight Comment cterm=italic on your vimrc. Verify this with

 echo `tput sitm`italics`tput ritm` 

source: https://alexpearce.me/2014/05/italics-in-iterm2-vim-tmux/#tmux-21-and-above

Upvotes: 4

Related Questions