sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.83k stars 164 forks source link

Invisible TODO comments when `set cursorline` #200

Closed lekemula closed 4 months ago

lekemula commented 4 months ago

I have done the following steps before reporting this issue:

Operating system/version

macOS Ventura Version 13.4

Terminal emulator/version

iTerm2 3.4.23

$TERM environment variable

screen-256color

Tmux version

tmux 3.3a

Feature matrix

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Mar 05 2024 19:39:07)
macOS version - arm64
Included patches: 1-150
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby              +wildignore
+cursorbind        +lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             +sound             -xattr
-dnd               -mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       -xim
+emacs_tags        -mouse_gpm         +statusline        -xpm
+eval              -mouse_jsbterm     -sun_workshop      -xsmp
+ex_extra          +mouse_netterm     +syntax            -xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/opt/homebrew/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -o vim -lm -lncurses -lsodium -liconv -lintl -framework AppKit -L/opt/homebrew/opt/lua/lib -llua5.4 -mmacosx-version-min=13.6 -fstack-protector-strong -L/opt/homebrew/opt/perl/lib/perl5/5.38/darwin-thread-multi-2level/CORE -lperl -L/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/lib/python3.12/config-3.12-darwin -lpython3.12 -framework CoreFoundation -lruby.3.3 -L/opt/homebrew/Cellar/ruby/3.3.0/lib

Minimal vimrc that can reproduce this bug.

call plug#begin()
Plug 'sainnhe/gruvbox-material'
call plug#end()

set background=dark
set cursorline
let g:gruvbox_material_transparent_background = 0
let g:gruvbox_material_disable_italic_comment = 1
colorscheme gruvbox-material

Steps to reproduce this bug using minimal vimrc

  1. Write some TODO comment eg. Ruby: echo "# TODO: Some comment" > test.rb
  2. Open it: vim test.rb -N -u .mini.vimrc

Expected behavior

The TODO should have the same highlighting when the cursor is not on the same line.

image

Actual behavior

The TODO loses it's blue background and is barely visible when cursor is on the same line.

image
lekemula commented 4 months ago

Additionally, I don't know whether this is related but I noticed that TODO comments are not super visible when git diff-ing either, regardless of cursorline or nocursorline:

image
antoineco commented 4 months ago

Thanks for the detailed report! πŸ™Œ I'll look into this tomorrow.

antoineco commented 4 months ago

I was able to reproduce. Below is a summary of what I observed.

Analysis

Using the built-in habamax colorscheme, the background color of the TODO tag remains untouched when cursorline is set: image

With gruvbox-material, the background appears the same way as in your screenshot (unsurprisignly): image

In both cases the synstack is as follows:

:echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
['rubyComment', 'rubyTodo']
" rubyTodo    links to Todo
" rubyComment links to Comment

The observed behaviour can be explained by the usage of cterm=reverse gui=reverse in habamax, whereas gruvbox-material uses cterm=bold gui=bold:

habamax image

gruvbox-material image

Possible solution

Using the reverse attribute after swapping the values of fg and bg seems to yield the expected appearance:

:hi Todo term=standout cterm=reverse,bold ctermfg=109 ctermbg=235 gui=reverse,bold guifg=#7daea3 guibg=#282828

image

I have to evaluate the possible ramifications of using reverse in the colorscheme. The problem seems to be Vim-specific and, in Neovim, TODO comments are displayed correctly without this attribute. A possible compromise would be to gate the attribute behind a conditional and set the highlight group differently on Vim and Neovim.

antoineco commented 4 months ago

@lekemula this should now be solved, let us know if you're still running into similar issues πŸ™

lekemula commented 4 months ago
image

Thank you for the lightning fix and for allowing me to enjoy this beautiful theme to the fullest! 😍 πŸš€