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

Too much italic for treesitter #41

Open
meijieru opened this issue Nov 17, 2021 · 3 comments
Open

Too much italic for treesitter #41

meijieru opened this issue Nov 17, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@meijieru
Copy link

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 meijieru added the bug Something isn't working label Nov 17, 2021
@sainnhe
Copy link
Owner

sainnhe commented Nov 17, 2021

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:

highlight! link TSFuncBuiltin Blue

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

call edge#highlight('Blue', s:palette.blue, s:palette.none)

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.

@antoineco
Copy link
Collaborator

antoineco commented Aug 29, 2022

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 nvim-treesitter/nvim-treesitter#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
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants