1

I tried to install the better official color schemes (https://github.com/vim/colorschemes) the exact way it is described there: Putting them under .vim/pack/something/start.

The thing is that those new color schemes have the same names as the preinstalled ones. And apparently the command colorscheme evening still chooses the color scheme from $VIMRUNTIME, not the one I just installed. It is probably a problem caused by search order of the folders where VIM looks for color schemes. Because when I rename the new color scheme I can actually choose it without an issue.

The official help states:

:colo[rscheme] {name}   Load color scheme {name}.  This searches 'runtimepath'
                        for the file "colors/{name}.vim".  The first one
                        is found is loaded.
                        Also searches all plugins in 'packpath', first below
                        "start" and then under "opt".

But it does not state in which order the search happens. Is this documented and can it be changed somehow? I would appreciate not having to rename the scheme every time I fetch updates from the color schemes repository.

2
  • It appears to me that Bram Moolinaar has updated the source with these new color schemes, at least for Vim 9. Compiling from source is quite easy. I'm running Vim 9 now and it seems even faster than before.
    – MDeBusk
    Jul 1, 2022 at 22:00
  • Yes, VIM 9 includes them, but I usually just use the version shipping with apt as its more convenient as updating myself...
    – Matthias
    Jul 2, 2022 at 6:56

1 Answer 1

4

It uses the list of paths in runtimepath, in order, similar to how the $PATH environment variable behaves for looking up commands.

You can see the current list with:

:echo &runtimepath

This output may be long, because it doesn't just include your ~/.vim, the system-wide vimrc, but also an entry for every plugin. To get a more readable list you can use:

:echo &runtimepath->split(',')->join("\n")

Or to load the list in the current buffer:

:call setline('.', &runtimepath->split(','))

The output on my system is:

/home/martin/.vim
/home/martin/.vim/pack/plugins/start/vim-swap
/home/martin/.vim/pack/plugins/start/vim-qf
[.. more plugins omitted ..]
/usr/share/vim/vimfiles
/usr/share/vim/vim90
/home/martin/.vim/pack/plugins/start/vim-qf/after
/home/martin/.vim/pack/mine/start/jumpy.vim/after
/usr/share/vim/vimfiles/after
/home/martin/.vim/after

This means the load order is:

  • ~/.vim
  • Plugins
  • /usr/share/vim/vimfiles
  • /usr/share/vim/vim90

Which is repeated for the after/ directory.


To check which colour scheme is currently loaded and from where you can use:

:verbose hi Constant
Constant       xxx term=underline ctermfg=1 guifg=#cd0000
        Last set from ~/.vim/pack/mine/start/default2.vim/colors/default2.vim line 61

Pretty much every colour scheme defines Constant, so this should work for all colour schemes.

I think the reason you're confused is that the new colour schemes are already integrated in Vim since 8.2.4954 from May 2021 so it could be you're not seeing much change because there are no changes, but with the information above you should be able to verify this (another quick hack to verify this would be to change a colour to something that stands out, so you know that correct one gets loaded).

1
  • The verbose trick is pretty helpful. So apparently, it does what I want when I type the command in the command window. So with the help of the verbose command I was able to track down the issue: I should include packloadall before the colorscheme command in my .vimrc. Otherwise the pack directory is not yet added to the runtimepath.
    – Matthias
    Jul 2, 2022 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.