edge icon indicating copy to clipboard operation
edge copied to clipboard

Too much italic for treesitter

Open meijieru opened this issue 2 years ago • 3 comments

Operating system/version

WSL2

Terminal emulator/version

wezterm

$TERM environment variable

xterm-256color

Tmux version

No response

Feature matrix

NVIM v0.6.0-dev+582-g87a053f12
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az68-363

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Minimal vimrc that can reproduce this bug.

    require'nvim-treesitter.configs'.setup {
        highlight = {enable = true, disable = {'vim'}},
    }

Steps to reproduce this bug using minimal vimrc

Use the above config

Expected behavior

Like gruvbox-material, some texts are italic

Actual behavior

Almost everything is italic image

meijieru avatar Nov 17 '21 02:11 meijieru

The text of blue color should not be italicized.

I did some debug, and found that it's a bug of tree-sitter.

This line:

https://github.com/sainnhe/edge/blob/f2c8e3d2a72f3763e3ea9c620a118e73e2146fb1/colors/edge.vim#L365

Will link TSFuncBuiltin to Blue. TSFuncBuiltin controls the color of builtin functions like print(), open() and len(). The Blue highlight group is defined here:

https://github.com/sainnhe/edge/blob/f2c8e3d2a72f3763e3ea9c620a118e73e2146fb1/colors/edge.vim#L236

The output of :hi Blue:

:hi Blue
Blue           xxx ctermfg=110 guifg=#6cb6eb
Press ENTER or type command to continue

As you can see, TSFuncBuiltin is linked to Blue which is NOT italicized.

But it is italicized here.

IMO, it's a bug of nvim-treesitter, report this to their repo.

sainnhe avatar Nov 17 '21 02:11 sainnhe

I'm facing the same kind of issues whenever I use Edge. And yes, this behaviour comes from Treesitter and it doesn't seem like Neovim offers a way to counteract it. I just opened https://github.com/nvim-treesitter/nvim-treesitter/issues/3396.

The problem with Treesitter is that, since highlight attributes are inherited, anything with TSVariable as parent will inherit the italic attribute of that parent (or any other attribute):

Screenshot 2022-08-29 at 10 54 15

Unfortunately, even forcing the child's attributes to NONE (which Edge does anyway) doesn't seem to reset the attributes inherited from the parent.

highlight! Blue cterm=NONE gui=NONE  " no effect

This seems to be a recurring issue in any color scheme that sets non-NONE highlight attributes on TSVariable.

antoineco avatar Aug 29 '22 09:08 antoineco

Here is a workaround that solves most (all?) issues related to inherited attributes:

hi Fg     gui=nocombine
hi Grey   gui=nocombine
hi Red    gui=nocombine
hi Yellow gui=nocombine
hi Green  gui=nocombine
hi Cyan   gui=nocombine
hi Blue   gui=nocombine
hi Purple gui=nocombine

Maybe we could make gui=nocombine the default for these base groups.

antoineco avatar May 03 '23 13:05 antoineco