itchyny / calendar.vim

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

Calendar custom colors #116

Closed echuraev closed 7 years ago

echuraev commented 7 years ago

Sometimes default colors is unreadable. I added possibility to change default colors. Please, see screenshots below. Before my patch with default colors: calendar_before After my patch with custom colors: calendar_after

itchyny commented 7 years ago

Basically I want to make syntax colours looks nice by default for any environment because configuring colours would be difficult for beginners. Also, configuring by autocmd works for me and this way is basically works for many plugins.

autocmd FileType calendar highlight CalendarSunday ctermfg=196 ctermbg=255

Would you mind paste the result of :hi CalendarSelect and :hi CalendarDayTitle and your desirable colours and I'll try to make the appearance better by default.

echuraev commented 7 years ago

Thank you for your answer. It would be very nice if syntax colours will look good by default. But I think that more flexibility in changing calendar colours is a good feature. Sometimes you could just want to change something in your life and why it couldn't be the colours in your calendar. I don't think that it is very difficult to configure colours (even for beginners), but it is only optional parameters, you could use default colour settings if you wish. I hope that you would agree with me. Do you think that autocmd is the better way to change colour settings? If yes, could you please add some information about that to the documentation?

At home on my MacOS I don't have the same picture as on the screenshots. I'll try to set autocmd tomorrow on my computer at my work. There I have problems with colours.
At MacOS I have the following results of :hi CalendarSelect and :hi CalendarDayTitle: :hi CalendarSelect: CalendarSelect xxx ctermbg=254 :hi CalendarDayTitle: CalendarDayTitle xxx ctermfg=253 ctermbg=254

So, I see that the problem is that the values of ctermfg and ctermbg are very close. I tried to set colours with autocmd and it works. But in this case I also set colours manually.

On computer there I have taken the screenshots I use the following colours configuration: let g:calendar_fg_color=238 let g:calendar_comment_fg_color=13 let g:calendar_select_color=243 let g:calendar_today_fg_color=0 let g:calendar_today_color=230

itchyny commented 7 years ago

Ah, please let me know the result of :echo [calendar#color#bg_color('Normal'), calendar#color#fg_color('Normal')].

echuraev commented 7 years ago

This is the results of the previous command on the machine from screenshots: [255, 252]

itchyny commented 7 years ago

That looks like a problem of the syntax... The fg and bg colours of Normal highlight are very close (see :hi Normal will also help what's going on).

itchyny commented 7 years ago

Ahh, sorry, there's still possibility a bug of calendar.vim, please ensure that :echo &background ==# 'dark' prints 1 because it's a dark theme.

echuraev commented 7 years ago

Yes, :echo &background ==# 'dark' prints 1. What is the problem?

itchyny commented 7 years ago

Which colorscheme do you use? Would you paste the result of :hi Normal please.

echuraev commented 7 years ago

This is the result of :hi Normal: Normal xxx ctermfg=252 guifg=#d0d0d0 guibg=#1c1c1c So, I use xoria256 colorscheme. But with some modifications such as transparent background. You can find my view configuration here: https://github.com/echuraev/Linux-env/blob/master/.vim/configs/common/common.vimrc#L16-L37

itchyny commented 7 years ago

Hmm, I'm confused... As &background ==# 'dark' is 1, calendar.vim should recognise it as dark colorscheme, but calendar#color#bg_color('Normal') is 255 and your screenshot suggests that it mistakenly sets the background color. In dark background environment, calendar#color#bg_color('Normal') should return dark colours. The code is around here.

echuraev commented 7 years ago

Oh... Sorry I rechecked the result of :echo &background ==# 'dark' in new vim session and it was 0. May be I changed something in my last session and therefore it was 1. But If I set in my vimrc background manually: set background=dark then I have also terrible view. See screenshot. calendar_dark

To be honest, I tried to find there value of background is set to light, but I didn't find it... If I disable setting colorscheme in my config files (remove this line: colorscheme xoria256) then everythink is good and :echo &background ==# 'dark' returns 1. So, I think that the problem in the colorscheme but I have analyzed the source of xoria256 and I didn't find where light background was set.

Do you have any suggestions why it has happened?

itchyny commented 7 years ago

I found the behaviour of Vim setting &background on highlight Normal ctermbg=XXX. I want to say that this is a bug of Vim but there might be less hope to be fixed. https://groups.google.com/d/msg/vim_dev/k3VeiGxHMtY/YU1ANLpG23YJ https://groups.google.com/d/msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ https://github.com/vim/vim/blob/c96272e30e2b81e5e0c8418f09d9db4e2fcd5d73/src/syntax.c#L7826-L7851 https://github.com/vim-scripts/xoria256.vim/blob/ae38fd50b365052ed4ddbc79a006a45628d5786a/colors/xoria256.vim#L27-L39 https://github.com/tomasr/molokai/blob/c67bdfcdb31415aa0ade7f8c003261700a885476/colors/molokai.vim#L274-L276

Anyway, I think I should reconsider the logic judging colorscheme dark or light based on &background...

itchyny commented 7 years ago

I have updated the plugin not to use &background. I think it should stop misjudging dark or light the colorscheme is.

echuraev commented 7 years ago

I see. Now it is much better. But I think that color customization is should be nice feature. Do you think that it is better to not give such functionality and user could customize colors only by using autocmd?

itchyny commented 7 years ago

Yes. To be honest, I'm planning to write more tests for this plugin. Tests for syntax as well. Adding more feature on untested code will be a pain for me. I'm very sorry but I'm going to close because I will not merge this for now. Thank you for your feedback.