itchyny / calendar.vim

A calendar application for Vim
MIT License
1.95k stars 72 forks source link

Customizing Colors #110

Closed fcpg closed 7 years ago

fcpg commented 7 years ago

There are a few highlight groups for the calendar eg. CalendarSaturday, but they seem to be constantly reset so it's not possible to simply override them to customize colors.

Could you add checks so that the user's highlight groups are used if defined?

itchyny commented 7 years ago
augroup calendar-syntax
  autocmd!
  autocmd FileType calendar highlight CalendarSaturday ctermfg=16 ctermbg=82 guifg=#whatever your like
  autocmd FileType calendar highlight CalendarSunday cterm...
augroup END
fcpg commented 7 years ago

Already tried, doesn't work.

The closest thing I got is:

augroup myCalendarColors
  au!
  autocmd FileType calendar
        \  autocmd BufEnter,BufWinEnter,BufNew,BufAdd <buffer>
        \      exe "hi! CalendarSaturday ctermbg=0 ctermfg=173"
augroup END

which repeatedly applies the highlight, but I first have to BufLeave+BufEnter for it to work. And it's no longer a "simple override" at that point, anyway.

itchyny commented 7 years ago

Hmm, autocmd FileType calendar highlight works well on my environment and it's simple enough...

fcpg commented 7 years ago

Yes, your code is standard and it's the first thing I tried; I don't know why it doesn't work for me. I'm on terminal Vim 8.0 patch 1-94, with most compiled options available. It's as though the syntax were reset each time a significant event occurs.

fcpg commented 7 years ago

This is probably related to 'autoload/calendar/autocmd.vim'. After you customized the highlight groups, have you tried to switch to another visible window?

fcpg commented 7 years ago

Found the issue: I use syntax manual in my .vimrc, with an autocmd to set syntax=on for all the files I want to be syntax highlighted. It turns out that it doesn't play well with this plugin's autocmd.

For the record, my workaround is to avoid syntax=on for the calendar filetype and to define all the calendar syntax in an augroup of mine, like suggested above.

itchyny commented 7 years ago

I think you're doing something special... I only test my plugin assuming syntax enabled on the editor startup, because most people set it on in vimrc.