sainnhe / edge

Clean & Elegant Color Scheme inspired by Atom One and Material
MIT License
860 stars 56 forks source link

Wrong hightling but correct in visual mode #36

Closed MuhammadSawalhy closed 2 years ago

MuhammadSawalhy commented 2 years ago
NVIM v0.5.0
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -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/build/neovim/src/neovim-0.5.0/build/config -I/build/neovim/src/neovim-0.5.0/src -I/usr/include -I/build/neovim/src/neovim-0.5.0/build/src/nvim/auto -I/build/neovim/src/neovim-0.5.0/build/include
Compiled by builduser

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

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

Run :checkhealth for more info

Minimal vimrc that can reproduce this bug

I will provide the minimal configuration (and steps) in each case in the Actual behaviour section.

$ nvim -u ~/.config/nvim/mini-init.vim -- the-file.js

Actual behaviour

edge alone

let g:plug_home = '~/.config/nvim/plugins'

call plug#begin(plug_home)
Plug 'sainnhe/edge'
call plug#end()

colo edge

image


edge + nvim-treesitter/nvim-treesitter

let g:plug_home = '~/.config/nvim/plugins'

call plug#begin(plug_home)
Plug 'sainnhe/edge'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}  " We recommend updating the parsers on update
call plug#end()

lua <<EOF
require'nvim-treesitter.configs'.setup {
  ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  -- ignore_install = { "javascript" }, -- List of parsers to ignore installing
  highlight = {
    enable = true,              -- false will disable the whole extension
    -- disable = { "c", "rust" }, -- list of language that will be disabled
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = true,
  },
  indent = {
    enable = true
  }
}
EOF

colo edge

image


edge + nvim-treesitter/nvim-treesitter + sheerun/vim-polyglot

The props of these tags are blue in, but when it is selected it turns to red.

let g:plug_home = '~/.config/nvim/plugins'

call plug#begin(plug_home)
Plug 'sainnhe/edge'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}  " We recommend updating the parsers on update
Plug 'sheerun/vim-polyglot'
call plug#end()

lua <<EOF
require'nvim-treesitter.configs'.setup {
  ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
  -- ignore_install = { "javascript" }, -- List of parsers to ignore installing
  highlight = {
    enable = true,              -- false will disable the whole extension
    -- disable = { "c", "rust" }, -- list of language that will be disabled
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = true,
  },
  indent = {
    enable = true
  }
}
EOF

colo edge

image

Expected behaviour

In all cases, I expect the selected not selected lines to be the same, but this doesn't happen in the last case.

sainnhe commented 2 years ago

Looks like it's a bug of tree-sitter. Can you reproduce it using default color scheme?

MuhammadSawalhy commented 2 years ago

Looks like it's a bug of tree-sitter. Can you reproduce it using default color scheme?

The second case (edge + treesitter only), no problem.

The issue occurs in the last case only, I think it is polyglot plugin that make this issue appear, but everything is fine when using other color schemes such as gruvbox, so it seems that the issue is in edge 🤷‍♂️.

sainnhe commented 2 years ago

What a color scheme does can be briefly summarized as creating highlight groups, it doesn't actually highlight the text. Instead, highlighting engines like builtin vim syntax engine (improved by vim-polyglot), nvim-treesitter and semantic highlighting provided by coc.nvim, will read these highlight groups and highlight the text based on these colors.

So if the colors work as expected in normal mode but break in visual mode, it's most likely caused by highlighting engines. I encountered similar issues before and it's caused by tree-sitter https://github.com/nvim-treesitter/nvim-treesitter/issues/1528

IMO it's not a bug in color scheme level, closed.

MuhammadSawalhy commented 2 years ago

I have discovered something, polyglot and treesitter are conflicting to highlight the code. What happened is that: edge makes the selection (visual mode) background somehow transparent (here polyglot wins), but in case of the unselected line (treesitter highlighting wins).

I thought edge is the source of this issue because this issue doesn't happen with gruvbox colour scheme, but the real reason that it doesn't happen with gruvbox is the way that this colour scheme do the selected lines. it swaps the foreground and the background. that's it.

image