sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.96k stars 166 forks source link

Highlight links overridden by syntax files #118

Closed mtvec closed 2 years ago

mtvec commented 2 years ago

Operating system/version

Ubuntu 21.10

Terminal emulator/version

alacritty 0.9.0

$TERM environment variable

alacritty

Tmux version

No response

Feature matrix

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Nov 08 2021 14:17:01)
Included patches: 1-2434, 3402-3403, 3409, 3428, 3487, 3564, 3581-3582
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
+arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      +mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       +tcl
-autoservername    +folding           +multi_byte        +termguicolors
+balloon_eval      -footer            +multi_lang        +terminal
+balloon_eval_term +fork()            -mzscheme          +terminfo
+browse            +gettext           +netbeans_intg     +termresponse
++builtin_terms    -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              +perl              +title
+clientserver      +job               +persistent_undo   +toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     +keymap            +postscript        +vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      +langmap           +profile           +virtualedit
+comments          +libcall           -python            +visual
+conceal           +linebreak         +python3           +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          +rightleft         +wildignore
+cursorshape       +lua               +ruby              +wildmenu
+dialog_con_gui    +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       +X11
+dnd               +mouse             +sound             -xfontset
-ebcdic            +mouseshape        +spell             +xim
+emacs_tags        +mouse_dec         +startuptime       +xpm
+eval              +mouse_gpm         +statusline        +xsmp_interact
+ex_extra          -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+extra_search      +mouse_netterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-8aTS6W/vim-8.2.2434=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lselinux -lcanberra -lacl -lattr -lgpm -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.32/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.9/config-3.9-x86_64-linux-gnu -lpython3.9 -lcrypt -ldl -lm -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.7 -lm -L/usr/lib 

Minimal vimrc that can reproduce this bug.

if &compatible
  set nocompatible
endif

syntax on

call plug#begin()

Plug 'sainnhe/gruvbox-material'

call plug#end()

if exists('+termguicolors')
  let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
  let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
  set termguicolors
endif

set background=dark
colorscheme gruvbox-material

Steps to reproduce this bug using minimal vimrc

Edit a file type for which colors/gruvbox-material.vim provides specialized highlight! links and the file type's syntax definition also provides a link.

Expected behavior

The link defined by gruvbox takes precedence.

Actual behavior

The link defined by the file type's syntax file has precedence.

More info

This happens for example with Scala files. syntax/scala.vim defines this:

hi link scalaKeywordModifier Function

while colors/gruvbox-material.vim defines this:

highlight! link scalaKeywordModifier Orange

I would expect (and want) the color scheme's definition to take precedence but it does not:

:scriptnames
  1: /tmp/vimrc
  2: /usr/share/vim/vim82/syntax/syntax.vim
  3: /usr/share/vim/vim82/syntax/synload.vim
  4: /usr/share/vim/vim82/syntax/syncolor.vim
  5: /usr/share/vim/vim82/filetype.vim
  6: ~/.vim/autoload/plug.vim
  7: /usr/share/vim/vim82/ftoff.vim
  8: /usr/share/vim/vim82/ftplugin.vim
  9: /usr/share/vim/vim82/indent.vim
 10: ~/.vim/plugged/gruvbox-material/colors/gruvbox-material.vim
 11: ~/.vim/plugged/gruvbox-material/autoload/gruvbox_material.vim
 12: /usr/share/vim/vim82/plugin/getscriptPlugin.vim
 13: /usr/share/vim/vim82/plugin/gzip.vim
 14: /usr/share/vim/vim82/plugin/logiPat.vim
 15: /usr/share/vim/vim82/plugin/manpager.vim
 16: /usr/share/vim/vim82/plugin/matchparen.vim
 17: /usr/share/vim/vim82/plugin/netrwPlugin.vim
 18: /usr/share/vim/vim82/plugin/rrhelper.vim
 19: /usr/share/vim/vim82/plugin/spellfile.vim
 20: /usr/share/vim/vim82/plugin/tarPlugin.vim
 21: /usr/share/vim/vim82/plugin/tohtml.vim
 22: /usr/share/vim/vim82/plugin/vimballPlugin.vim
 23: /usr/share/vim/vim82/plugin/zipPlugin.vim
 24: /usr/share/vim/vim82/syntax/scala.vim
 25: /usr/share/vim/vim82/ftplugin/scala.vim
 26: /usr/share/vim/vim82/indent/scala.vim
sainnhe commented 2 years ago

It's a bug of scala syntax files, it should use hi default link instead of hi link. You should report this bug to their repo.

But there is a temp solution, try g:gruvbox_material_better_performance, this config option will generate after/ftplugin which should override the hi groups defined in the syntax files.

mtvec commented 2 years ago

But there is a temp solution, try g:gruvbox_material_better_performance, this config option will generate after/ftplugin which should override the hi groups defined in the syntax files.

This doesn't seem to work for me because the builtin syntax/scala.vim is loaded after gruvbox:

:scriptnames
...
47: ~/.vim/plugged/gruvbox-material/after/ftplugin/scala/gruvbox_material.vim
48: /usr/share/vim/vim82/indent/scala.vim
49: /usr/share/vim/vim82/syntax/scala.vim

Shouldn't gruvbox generate those files in after/syntax?

sainnhe commented 2 years ago

Shouldn't gruvbox generate those files in after/syntax?

You are right. Done via https://github.com/sainnhe/gruvbox-material/commit/b259ca990645d982655046ac24f115cc5d0f2e59

mtvec commented 2 years ago

Thanks! I can confirm the temp solution above now works.

Just a small note: I had to manually remove the old after/ftplugin directory after the upgrade. I don't think keeping it around will impact functionality but it might decrease performance.

sainnhe commented 2 years ago

Yeah, I know that, so I commit this https://github.com/sainnhe/gruvbox-material/commit/d043cd49c344e41cd07b19c5252ee31e356c8ebf

mtvec commented 2 years ago

Nice, I guess I missed that message when upgrading :sweat_smile: