-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling causes syntax highlighting to break for other color themes #65
Comments
Yeah, this is a problem I noticed early on too. I believe that it's because the other themes you used didn't handle background switching well. The way to handle that is hacky, and the themes themselves should handle that. I got a PR that helped doing that #20 Let me know how it works out! |
@NLKNguyen I am actually explicitly setting those ( PS. Thank you for this theme; I worked in it all day and it has been a pleasure! |
There are two parts of the trick. I put in the comment of the below theme snippet. I really don't understand why it has to be this way, but it works. So, I guess if you modify the other dark theme that you use to include this, then it probably will work let s:is_dark=(&background == 'dark') " <-- trick #1: this variable can be used to correctly
" check if the current background is dark
" Vim Highlighting
call s:HL("Normal", s:foreground, s:background, "")
" ^^^^ this is just a helper function in PaperColor theme. It's not required.
" The important thing is that it sets highlighting for `Normal` group by calling something like:
" highlight Normal guifg=#444444 guibg=#F5F5F5 ctermfg=238 ctermbg=255
" trick #2: call `set background` AFTER setting the above `Normal` group highlighting
" and BEFORE the rest of the syntax groups of the theme
" Switching between dark & light variant through `set background`
" https://github.com/NLKNguyen/papercolor-theme/pull/20
if s:is_dark " DARK VARIANT
set background=dark
else " LIGHT VARIANT
set background=light
endif
" ... other syntax group highlightings
Glad that the theme pleases you :) I enjoy using it as well. |
I tried adding the trick as suggested but it didn't seem to make a difference sadly. I also checked out Gruvbox and the highlighting groups still seem to break. Specifically with Go (haven't tested others). I've also not run into this particular issue with toggling between light and dark with other color themes. Not saying it's PaperColor explicitly, just trying to help debug :) Example snippet: import (
"fmt"
)
func main() {
go doSomething()
go doSomething()
fmt.Printf("Hello world\n")
}
func doSomething() {
fmt.Printf(" hello!")
} my ToggleColor Function looks like this: function! ToggleLightDark()
if &background == "dark"
set background=light
let g:airline_theme='PaperColor'
colorscheme PaperColor
else
set background=dark
let g:airline_theme='gruvbox'
color gruvbox
endif
endfunction |
Sure, it's good for me to know that there is something inconsistent about this theme. I'm inspecting this. What Go syntax plugin that you are using? I installed vim-go, but the highlighting seems like you are using something else. |
I am indeed using |
After digging for a while, I finally found a way to solve the problem. It turned out that GruvBox and many other themes like Solarized relink the syntax highlighting groups, provided by the syntax plugins, to the theme's custom syntax highlighting groups. In altercation/solarized#102 tpope says that it's not the color scheme business, and Vim doesn't anticipate that. PaperColor, on the other hand, doesn't relink anything. xolox suggested that the color scheme switching issue is a Vim bug altercation/solarized#102 (comment), so he wrote this plugin https://github.com/xolox/vim-colorscheme-switcher to help handle that. Now to fix this issue, you just install that plugin then replace your function with this: " Default is gruvbox dark
set background=dark
colorscheme gruvbox
function! ToggleLightDark()
if &background == 'dark'
set background=light
let g:airline_theme='PaperColor'
call xolox#colorscheme_switcher#switch_to("PaperColor")
else
set background=dark
let g:airline_theme='gruvbox'
call xolox#colorscheme_switcher#switch_to("gruvbox")
endif
endfunction Note: in my test, it only works if GruvBox is the default, and I don't know why. |
@NLKNguyen apologies on the delay. Thank you a ton for the digging and the work around. Awesome theme again. Thanks for sharing it with everyone! |
You're welcome :) |
I have a toggle function which switches between light and dark; I use a different dark theme but would love to use this for light. However, when switching back to my dark theme (or any other theme) the highlighting seems to break. If I go to PaperColor it all still works fine. See the attached screenshots for an example:
Dark mode before:
Enable Light - Still looks good

Back to dark - Now broken

Other themes broken too

The text was updated successfully, but these errors were encountered: