0

I have the following vimscript:

let g:base_path="~/.config/nvim/"
let g:plugins_path=base_path."plugins/"
let g:repos_path=plugins_path."repos/github.com/"

set runtimepath+=g:repos_path."Shougo/dein.vim"

But it's doing something weird, instead of seeing a path at the end, I'm seeing this:

runtimepath=~/.config/nvim,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/usr/local/Cellar/neovim/0.2.2_1/share/nvi
    m/runtime,/usr/share/nvim/site/after,/usr/local/share/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,~/.config/nvim/after,g:repos_path.

It's adding this to the end:

,g:repos_path.

instead of

,~/.config/nvim/plugins/repos/github.com/Shougo/dein.vim

Why is vim not adding the path to the end correctly and also why is this happening?

EDIT: The only way to get this to work is to use the fullpath without any quotes like this:

set runtimepath+=~/.config/nvim/plugins/repos/github.com/Shougo/dein.vim
1

After reading this:

let &backupdir=s:vimetc.'backups/'

I realised what I needed to do was this:

let &runtimepath=&runtimepath.','.g:repos_path."Shougo/dein.vim"

I have to say, vim script can be a bit inconsistent, using bare strings works fine but without it you need to some some weird stuff to get it to work if you want to use variables.

  • There is no inconsistency, setting an option and letting a variable are very different things. vim offers an interface to options as variables, by prepending &. let &runtimepath.=','.g:repos_path.'Shougo/dein.vim' would also have worked. – Mass Mar 26 '18 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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