junegunn / goyo.vim

:tulip: Distraction-free writing in Vim
MIT License
4.52k stars 118 forks source link

Possible fix to #160 - Fix other side effects from resetting colorscheme #195

Open TaDaa opened 5 years ago

TaDaa commented 5 years ago

Hi there -- this is an attempt to remove the colorscheme reset in goyo.vim, which should fix #160 . There are a number of side effects caused by resetting the colorscheme (reset of user highlights + incorrect highlights are sometimes reset)

I haven't tested this PR much other than just to verify that the basic functionality is working both within vim, neovim, gui, and terminal and that user highlights are no longer blown away.

The code could be cleaned up a bit - but wanted to see if there was any interest before moving any further with it.

nathanshelly commented 5 years ago

Would love to see this merged! (provided people who know more about vimscript than I do think it's a good idea)

Having the same highlighting issues mentioned in #160

junegunn commented 5 years ago

There are a number of side effects caused by resetting the colorscheme (reset of user highlights + incorrect highlights are sometimes reset)

I've answered this question several times in the past. The point is; you'll have the same issue without Goyo if you switch your color scheme. You will lose custom highlights whenever you run :colo some-other-colorscheme, even if you don't start Goyo. And you don't want that.

A definite, robust, and simpler (from Goyo's perspective) solution to the problem is to set up custom highlights on autocmd ColorScheme. See https://github.com/junegunn/goyo.vim/issues/84#issuecomment-156299446.

Making Goyo remembering and restoring the attributes of highlight groups should be more convenient for users who don't know the implications of setting custom highlights without autocmd, but it's still a partial fix to the problem and I didn't like the extra code I should maintain. See my previous comment here: https://github.com/junegunn/goyo.vim/issues/103#issuecomment-199151453

Having said that, I'm not saying that Goyo shouldn't do this, just suggesting there's a better solution to the problem. I'll review and test the patch when I get a chance.

holychowders commented 2 years ago

Oh, I didn't see this PR.

I left a comment on #160. My "fix" was to just remove line 340, but I didn't have to replace it with anything (as is being done here). I don't know if that means anything to you.

Here's the comment: https://github.com/junegunn/goyo.vim/issues/160#issuecomment-974770662