preservim / vim-thematic

Alter Vim's appearance to suit your task & environ
Other
224 stars 6 forks source link

Custom highlighting issue #8

Closed lervag closed 10 years ago

lervag commented 10 years ago

Hi. I've just begun testing your plugin, which seems convenient. However, I found that it "breaks" custom highlighting from my vimrc file, since the colorschemes and syntax plugins are loaded later than usual.

I don't see an immediate fix for this. That is, one possibility would be to add a functionality to add customizations to Thematic. For instance, I have the following customized highlights:

highlight clear SpellBad SpellCap SpellRare SpellLocal
highlight SpellBad   gui=bold guibg=#faa
highlight SpellCap   gui=bold guibg=#faf
highlight SpellRare  gui=bold guibg=#aff
highlight SpellLocal gui=bold guibg=#ffa

Perhaps you could implement something like this:

let g:thematic#custom_highlighting = {
  'SpellBad' : 'gui=bold guibg=#faa',
  ...
}

Where the custom highlighting is activated after a theme has been loaded?

lervag commented 10 years ago

I just noticed another related thing: Thematic breaks plugins that alter highlighting such as vim-niji. The reason seems to be the same as what I mentioned above.

Perhaps a better approach here would be to add some hooks after a theme has been loaded. Something like this:

let g:thematic#themes.theme.post_hook = 'MyFunction'

Where MyFunction is a function that is called after the theme has been loaded, and where I can make my customizations as desired.

reedes commented 10 years ago

Colorscheme initialization can be a tricky problem, as you observe. :)

Thematic will alter colors typically upon demand, much as if the user typed :colo solarized, which also will not re-initialize the customized highlights you had specified in your .vimrc. A configurable post-load hook sounds like one way to address that, perhaps on a per-theme basis.

Better yet you can set up your own event-driven hook:

augroup MyCustomHighlights
  autocmd!
  autocmd colorscheme *
   \ highlight SpellBad   gui=bold guibg=#faa |
   \ highlight SpellCap   gui=bold guibg=#faf |
   \ highlight SpellRare  gui=bold guibg=#aff |
   \ highlight SpellLocal gui=bold guibg=#ffa
augroup END

Regarding plugins like vim-niji that will override the highlighting, that's a more difficult problem. Ideally they should re-initialize after a user typed :colo solarized, but at least that plugin does not. I'd ask its author to do an event-driven hook as above to re-initialize themselves.

Does that answer your concerns/questions?

lervag commented 10 years ago

Yes, thank you!