gerardbm / vim-atomic

Atomic color scheme for Vim, Neovim and Gvim
https://github.com/gerardbm/atomic
MIT License
16 stars 1 forks source link

Italic and underline didn't work in neovim #1

Open Karmenzind opened 6 years ago

Karmenzind commented 6 years ago

I really love this colorscheme :smile: Thanks for your work.

Recently I started using neovim then I found italic and underline didn't show as it does in regular Vim. But other colorsheme, like Solarized, worked well in both Vim and Neovim.

Close it if there is no need to solve it.

gerardbm commented 6 years ago

Hi, Karmenzind.

Keep in mind there are two versions of atomic colorscheme for vim/neovim at this moment, the version 3.0 and the version 3.1.

The version 3.0 is available from https://github.com/gerardbm/atomic and it had syntax using italic and underline at the same time. I will remove this version.

The newest version is the current repository (https://github.com/gerardbm/vim-atomic). In this version I removed the style 'italic,underline' for the following cases: SpellBad, SpellCap, SpellLocal, SpellRare; and I removed the style 'italic' for these cases: cssPseudoClass, cssPseudoClassId, cssPseudoClassFn, cssPseudoClassLang and VendorPrefix. I only kept the style 'italic' in markdownItalic.

If you installed first the version 3.0 manually or using the script ./install.sh into the folder $HOME/.vim/colors/, and then you installed the version 3.1 using the current repository through a plugin manager, vim will still use the version 3.0. So then if you install the version 3.1 as well in neovim, you will see diferences between the two versions.

Probably, it's what happened here.

BTW, I like the issue because it will help others, and it remembered me I have to remove the old version.

If it's not your case, it would be nice to know more info about your terminal, your font used, your vim and neovim versions and the result of echo $TERM on your terminal. Also, it's important to mention that if you are using tmux, it might not work into it, and depending on the terminal and the variable $TERM, it could be necessary to compile a modified terminfo using tic (see: man tic), only if it's the case.

You can also check italics and underline in your terminal with this command: echo -e "\e[3mitalic\e[0m \e[4munderline\e[0m \e[3m\e[4mitalic-underline\e[0m\e[0m"

The reason I removed the style 'italic,underline' is because some terminals don't support it, it's difficult to make it work into tmux, and the goal of it was to make a colorscheme with the same look and usability for all terminal emulators. So at the end I decided to implement italics only when it's a WYSIWYG format as in markdown files.

I tried both versions (3.0 and 3.1) and they are working on vim and neovim, so I can't reproduce the issue using the terminals URxvt, XTerm and gnome-terminal, using vim 8.0.707 and neovim through AppImage 2.2 and 3.1. It fails when the variable $TERM is not properly set (I'm using the value screen-256color).

Tell me if this info helped you.

Regards! :)

Karmenzind commented 6 years ago

Thanks for your such kind and detailed help.

I never installed the 3.0 version, so maybe the problem is nothing to do with the versions.

Firstly, the italic and underline symbols work well with original Vim (with or without tmux). I append highlight Comment cterm=italic,underline after colorscheme atomic. This is vim8.1+atomic: image This is neovim+atomic: image This is neovim+atomic but without set termguicolors at first: image And this is neovim+Solarized: image

So, I think maybe it is something special about vim-atomic and neovim's termguicolors.


Some days ago, I tried a lot to deal with the italic inside tmux and finally fix it. So I think the $TERMs of my terminal and inside tmux are fairly suitable. FYI, here is some info about my system.

system: ArchLinux
font: Monaco Nerd Font + Hack Nerd Font
terminal: alacritty
vim 8.1
neovim v0.3.1 Build type: Release LuaJIT 2.0.5
$TERM: xterm-245colors; tmux-245color (inside tmux)

The result of echo -e "\e[3mitalic\e[0m \e[4munderline\e[0m \e[3m\e[4mitalic-underline\e[0m\e[0m" (with or without tmux): image

And here are my .vimrc and init.vim.

gerardbm commented 5 years ago

I'm not sure what is happening because it depends on too many factors (variable $TERM, terminal escape sequences and how vim/neovim handle them, etc). For example, this works fine using the gnome-terminal (version 3.22.2):

  1. open vim or neovim (with or without termguicolors)
  2. :highlight vimLineComment cterm=italic,underline

I will investigate more to clarify the factors affecting this issue.

By the way, there's an issue related to Vim and the use of the prefixes cterm and gui through the setting termguicolors. I opened this issue last year and it's not fixed, at the moment: https://github.com/vim/vim/issues/1740 (Neovim recognizes both prefixes, fortunately).

Thanks for your information. Any help is welcome!

Karmenzind commented 5 years ago

Thanks 😄

gerardbm commented 5 years ago

It's probably a Neovim issue. This is what happens with atomic and solarized (both cases).

Using gnome-terminal (xterm-256color), terminator (xterm-256color), xfce4-terminal (xterm-256color):

Using rxvt-unicode-256color terminal (screen-256color), xterm (screen-256color), lxterminal (xterm):

What I don't understand is why I'm getting identical results for both color schemes. I only get different results changing the terminal or the $TERM variable; differencies between Vim and Neovim, but not between atomic and solarized.

There's a pattern: it works when $TERM == xterm-256color.

@Karmenzind, could you try setting this $TERM variable? xterm-256color. Only temporarily to check if "italic,underline" works with atomic using the alacritty terminal. Check it with one of the mentioned terminals as well lif you can. Thanks in advance!


By the other hand, in Vim is possible to set termcap codes (for example to fix emphasis support), however Neovim handles it automatically, it's term-dependent (according to $TERM value and terminfo files). While in Vim we can check italics support with the commands :set t_ZH (italics mode) and :set t_ZR (italics end), we can't do the same with Neovim.

In Vim, the output should be '3m' and '23m', if not, this fixes the problem:

let &t_ZH="\e[3m"
let &t_ZR="\e[23m"

In Neovim, the output is the error «E846: Key code not set». It should work automatically, and these settings were removed.

This info won't fix the issue, but it's useful. It will help others as well.


I have another question: why do you use xterm-245colors instead of xterm-256color? I can only find one result on Google containing that $TERM: this thread. It would be nice to know if changing this fixes something.

PS. I didn't know about Alacritty terminal. I will give it a try when I have more time. It's interesting!

Edit: I asked to Alacritty devs. This is the line of code with the default $TERM variable: https://github.com/jwilm/alacritty/blob/015a6d4c03764608778d8aea80638fcc9704c2f3/src/tty.rs#L213

Check it because using xterm-245colors you probably have other issues (no related).

Karmenzind commented 5 years ago

sorry, a little busy here... I'll read and try your advice after finishing my work. Thanks a lot.


I have another question: why do you use xterm-245colors instead of xterm-256color?

hmmm... It's a typo. The real number of my $TERM is 256... I'm being used to my new keyboard. Maybe the result that you googled is a typo too.

Karmenzind commented 5 years ago

Sorry for the late. I tried xterm-256color with xfce4-terminal just now, but it didn't work the same as yours:

It's weird. I'll try with alacritty later.

BTW, '3m' and '23m' didn't help.