Vim Color Scheme Overwritten by a Plugin

1

I’m trying to set up some prettier highlighting for Vdebug.

I had a look at the source, and it says I need to target a DbgBreakptLine (I don’t know what they are called, but it’s the thing you put after hi).

But if I put:

hi DbgBreakptLine ctermbg=NONE ctermfg=NONE

in my vim color scheme, it does nothing. However, Pasting this into a session has the desired effect. I can only conclude that Vdebug is clobbering my chosen styles by taking precedence somehow. But how? Is it running after my color scheme? I don’t think so, because the first thing my .vimrc does is load pathogen, then selects my color scheme.

Given this, I had a look around the internet for any solutions to plugins overwriting config, but I couldn't find anything useful.

The relevant part of my .vimrc:

execute pathogen#infect()
call pathogen#helptags()

colorscheme maxbucknell

Update

I had a look at this question, and thought I would look at :scrip, which shows which files are loaded when. Sure enough, plugins are loaded after colors. Ideally I'd like some way of customising this, without changing the plugin, or doing something hacky like putting the command inside .vim/after.

Max Bucknell

Posted 2014-07-19T20:54:39.987

Reputation: 111

~/.vim/after is not "hacky" at all. – romainl – 2014-07-19T21:42:58.843

@romainl Is that the best way to do it? Perhaps "hacky" is the wrong word, but it sure doesn't feel elegant. – Max Bucknell – 2014-07-19T21:48:41.767

Answers

1

Did you notice that the plugin actually defines the style of that highlight group?

hi default DbgBreakptLine term=reverse ctermfg=White ctermbg=Green guifg=#ffffff guibg=#00ff00

Since it is sourced after your ~/.vimrc and your colorscheme it will override any rule with the same name.

That's not very clean, unfortunately, so you basically have three workable options:

  • change the colors right there in the plugin,

  • move those lines from the plugin to your colorscheme and edit them to your liking,

  • add these lines to your ~/.vimrc:

    augroup MyColors
        autocmd!
        autocmd ColorScheme * highlight DbgBreakptLine ctermbg=NONE ctermfg=NONE
    augroup END
    

Using the ~/.vim/after/ directory is not a hack at all: it's under-documented for sure but it's usually a lot cleaner than the equivalent mess in your ~/.vimrc. Anyway, I'm not sure it works for your specific needs. You could try this plugin (never tried) but I'm not sure what you want deserves another plugin in your setup.

edit

It turns out you can do it with ~/.vim/after/ but that solution actually looks quite "hacky" to me as it mixes "plugins" and "colorschemes". Whatever, just put this line in ~/.vim/after/plugin/foo.vim (the part before the dot of the file name doesn't matter):

hi DbgBreakptLine ctermbg=NONE ctermfg=NONE

romainl

Posted 2014-07-19T20:54:39.987

Reputation: 19 227

The plugins is correctly using :hi default ..., so if there's an earlier DbgBreakptLine definition, that command will be ineffective, as desired. – Ingo Karkat – 2014-07-20T17:54:42.213