small medium large xlarge

Back to: All Forums  Modern Vim
Generic-user-small
05 Feb 2018, 18:46
Roland Lang (2 posts)

As you describe in the book, one could easily switch from vim to neovim by changing the $VIMDATA / $VIMCONFIG variable. However, I decided to reuse my vimrc for configuration of neovim, by sourcing the vimrc within the init.vim-file of neovim (located in ~/.config/nvim).

Actually this works fine with all my settings, except of the colorschemes. Neovim cannot find my colorscheme located in the ~/.vim/colors-directory. Adding the directory to the runtimepath via neovims init.vim does not help. Loading the colorscheme with the explicit path (eg colorscheme $VIMCONFIG/colors/mycolor.vim - with or without vim-ending) does not work - for neither vim nor nvim.

My solution is now to add a softlink into neovims ~/.config/nvim/colors-directory that references to the colorscheme in the vim-config dir. However, is there a smarter solution to have a colorscheme loaded in the vimrc and stay compatible to both, vim and neovim?

Drewneil_pragsmall
05 Feb 2018, 21:26
Drew Neil (48 posts)

That’s strange. I have a couple of colorschemes installed in ~/.vim/colors and they seem to work fine for me in both Vim and Neovim. I can’t think why it wouldn’t be working for you.

Here’s the advice under the “Where to put what” section in Vim’s docs (:help pack-add):

Since color schemes, loaded with :colorscheme, are found below “pack//start” and “pack//opt”, you could put them anywhere. We recommend you put them below “pack/*/opt”, for example “.vim/pack/mycolors/opt/dark/colors/very_dark.vim”.

I’ve been following that advice, so any colorschemes I’ve installed lately have ended up in the ~/.vim/pack/minpac/opt directory.

I hope that helps?

Generic-user-small
10 Feb 2018, 23:27
Roland Lang (2 posts)

For me, using homebrewed vim on mac os (because the shipped vim does not have the clipboard compiled) and homebrewed nvim the colorscheme-file cannot be found if it is located in either the minpac/opt-directory or the mycolors/opt-directory (or both). For me, the solution with the softlink works fine, however, I seem to have a serious problem with my paths/runtimepaths also when it comes to the packages.

To show my setup in detail (I just finished Tip 7), here are some of my configuration-settings and some remarks.

~/.vim/vimrc:

set nocompatible
filetype plugin indent on
" Use the OS clipboard ("*y) by default (on versions compiled with `+clipboard`)
set clipboard=unnamed
" *** MINPAC packer manager configuration ***
" add runtimepathes so that vim and nvim can find the directories (but this does not work)
set runtimepath+=~/.vim/colors runtimepath+=~/.vim/pack runtimepath+=~/.vim/pack/minpac/opt
" add packet-manager minpac
packadd minpac
call minpac#init()
" shortcut to update/clean packages with minpac
command! PackUpdate call minpac#update()
command! PackClean call minpac#clean()
" add plugins
call minpac#add('tpope/vim-unimpaired')
call minpac#add('tpope/vim-scriptease', {'type': 'opt'})
call minpac#add('k-takata/minpac', {'type': 'opt'})
" Set color scheme!
colorscheme smyck

I added the runtimepath in the hope that the colorscheme can be found in the minpac/opt-dir, but it is not. I am setting the colorscheme AFTER I packadd-ed the minpac-packet, because I thought maybe the path is not known to vim as long as the packet is not added. Both with no effect. Having a look at the :scriptnames, I can see everything so long except the colorscheme (I use the smyck colorscheme).

  1: ~/.vim/vimrc
  2: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/filetype.vim
  3: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/ftplugin.vim
  4: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/indent.vim
  5: ~/.vim/pack/minpac/opt/minpac/plugin/minpac.vim
  6: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/getscriptPlugin.vim
  7: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/gzip.vim
  8: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/logiPat.vim
  9: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/manpager.vim
 10: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/matchparen.vim
 11: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/netrwPlugin.vim
 12: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/rrhelper.vim
 13: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/spellfile.vim
 14: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/tarPlugin.vim
 15: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/tohtml.vim
 16: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/vimballPlugin.vim
 17: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/plugin/zipPlugin.vim
 18: ~/.vim/pack/bundle/start/fzf/plugin/fzf.vim
 19: ~/.vim/pack/bundle/start/vim-unimpaired/plugin/unimpaired.vim
 20: ~/.vim/pack/minpac/start/vim-unimpaired/plugin/unimpaired.vim
 21: ~/.vim/after/plugin/fzf-mappings.vim
 22: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/scripts.vim
 23: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/ftplugin/vim.vim
 24: /usr/local/Cellar/vim/8.0.1450/share/vim/vim80/indent/vim.vim

The moment I am copying the colorscheme into my .vim/colors-directory, the colorscheme is also shown as loaded in the :scriptnames - becoming line 6 right after the minpac.vim

6: ~/.vim/colors/smyck.vim

But it gets better. When switching to nvim, with my init.vim:

set runtimepath+=~/.vim runtimepath+=~/.vim/after  runtimepath+=~/.vim/colors runtimepath+=~/.vim/pack runtimepath+=~/.
vim/pack/minpac/opt
let &packpath = &runtimepath
source ~/.vim/vimrc

Starting nvim (eg nvim init.vim), I get the following error:

E919: Directory not found in 'packpath': "pack/*/opt/minpac"
E117: unknown function: minpac#init
and also minpac#add of course
and the colorscheme cannot be found

The additional runtimepathes, I added in both vim’s vimrc and nvim’s init.vim have no influence.

Having a look at the :scriptnames in nvim, I can see, that only the my vimrc is loaded and nothing that is referred to in vimrc (eg the minpack).

I took a look to vim’s :version, and saw the following directories listed there:

   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"

$VIMCONFIG and $VIMDATA are export-set to my ~/.vim-directory - as mentioned in the book. However, $VIMRUNTIME and $VIM are not set. According to :help vimruntime, that seems allright: „[..]You don’t normally set $VIMRUNTIME yourself, but let Vim figure it out.[..]“.

Currently I have no idea, why:

  • vim is not looking in the pack-dirs for my colorscheme

  • nvim is not finding the way to the pack-dir located in my .vim-dir although I added the runtime-paths.

But, I am working on it…

You must be logged in to comment