justinmk / vim-sneak

The missing motion for Vim :athletic_shoe:
http://www.vim.org/scripts/script.php?script_id=4809
MIT License
3.24k stars 88 forks source link

Custom highlight in .vimrc does not apply automatically #266

Closed TymekDev closed 3 years ago

TymekDev commented 3 years ago

I am having an issue with custom highlight defined in .vimrc. When starting Vim the highlight used is the default one instead of the one I have defined in .vimrc. However, after :so $MYVIMRC the custom highlight is applied as shown in the video below.

asciicast

I have also tried adding other options: image That did not help either.

TymekDev commented 3 years ago

I have done some additional testing and came up with minimal .vimrc to reproduce this issue:

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'justinmk/vim-sneak'
call vundle#end()

highlight Sneak ctermfg=8 ctermbg=0

colorscheme delek  " does not work

The problem is caused by setting the color scheme. Once that is removed the custom highlight works without additional sourcing of .vimrc. I have tested it with both, xterm and kitty.

Should any additional information come in handy please let me know.

TymekDev commented 3 years ago

As it turned out it is just Vim working as intended. I managed to resolve this by following this guide and replacing:

highlight Sneak ctermfg=8 ctermbg=0

with:

augroup ApplyHighlight
    autocmd!
    autocmd ColorScheme * highlight Sneak ctermfg=8 ctermbg=0
augroup END