Search code examples
vimcolorsvim-plugin

Installed vim colorscheme is not be found at startup, but it can be set once vim is loaded


I have installed with Vundle this github colours theme. I installed is with :VundleInstall and it seems to work just fine. The directory ~/.vim/bundle/vim-colors-github is there. Indeed, I can switch the color scheme with colorscheme github.

Next, I have added the following lines to ~/.vimrc to make this change permanent:

" github colors
let g:github_colors_soft = 1 
Plugin 'cormacrelf/vim-colors-github'
colorscheme github

But this raises the error "E185: colorscheme «github» not found".

It just doesn't work during the loading of vim!? What's going on here? I guess there is something that hasn't been set yet at the time of calling the change in the colorscheme. How could I debug this?


Solution

  • You seem to be missing the call to vundle#end() at the end of your plug-in configuration. See the quick start guide which shows an example of defining plug-ins in your vimrc:

    call vundle#begin()
    Plugin ...
    call vundle#end()            " required
    filetype plugin indent on    " required
    

    In your case, adding those lines around your Plugin definition will most likely fix the issue:

    " load plugins
    call vundle#begin()
    Plugin 'cormacrelf/vim-colors-github'
    call vundle#end()            " required
    filetype plugin indent on    " required
    
    " github colors
    let g:github_colors_soft = 1 
    colorscheme github
    

    Also note that Vundle hasn't really been very thoroughly maintained. While there's nothing wrong with it, vim-plug is a compatible alternative (works the same way, uses similar configuration and similar commands) which is well maintained and offers improvements in terms of performance and features. I'd definitely recommend switching to vim-plug, particularly if you're getting started with a Vim plug-in manager of this style.