Closed alexanderjeurissen closed 9 years ago
@alexanderjeurissen I believe the issue is that the plug#begin is sourced from plug.vim which is at ~/.vim/autoload/plug.vim
. By default, nvim makes its own files all prefixed with n
. So instead of .vim, it makes .nvim. So by default, nvim will source autoloads from ~/.nvim/autoload/plug.vim
. I imagine there isn't a plug.vim in that folder. Your snippet only checks/downloads to .vim
folder.
To solve, you could:
1) Symlink .vim
to .nvim
.
2) Symlink .vim/autoload
to .nvim/autoload
3) Download/copy plug.vim to ~/.nvim/autoload/plug.vim
.
Edit:
4) You could also put ~/.vim/autoload
onto your nvim runtimepath. I don't like idea though, since vim-plug should do the rtp magic.
Personally, I keep nvim & vim separate and use this snippet in my vimrc to share the vimrc. You can see my bootstrapping here.
symlinking .vim
to .nvim
did the trick.. Thanks.
Will symlinking .vim
to .nvim
cause things to run/load twice? I have everything in .vim
, but someone else is having trouble copying my setup.
Tried symlinking anyway, but still getting the same error (can't find plug#begin).
Check the output of the following commands
:echo &rtp
:echo globpath(&rtp, 'autoload/plug.vim')
Just copying .vim to .nvim made trick for me. Ofcourse with /autoload/plug.vim inside
Just for anyone else looking at this for Bash on Windows. if you do the
:echo &rtp
as @junegunn suggested. For some reason the right directory doesn't show up. So, just put the autoload in whatever one of the directories listed in the command above. I just used ~/.config/nvim
For future reference, this works fine. Mostly to give a copy/pastable answer from the above snippet:
"setup vim-plug {{{
"Note: install vim-plug if not present
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
"Note: Skip initialization for vim-tiny or vim-small.
if !1 | finish | endif
if has('vim_starting')
set nocompatible " Be iMproved
" Required:
call plug#begin()
endif
"}}}
on my case I was installing vim-plug for vim, instead of Neovim! 🤦 , all was good after installing vim-plug for NeoVim!
A variation of @wizzat's solution, with variables. Tested using my Neovim's init.vim:
" Put plugins and dictionaries in this directory
let vimDir = expand('$XDG_CONFIG_HOME/nvim')
let vimPlugFile = vimDir . '/autoload/plug.vim'
" Install vim-plug if not present
if empty(glob(vimPlugFile))
" There is no vim-plug file → Download and install it"
let vimPlugUrl = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
exec '!curl -fLo ' . vimPlugFile . ' --create-dirs ' . vimPlugUrl
autocmd VimEnter * PlugInstall
endif
call plug#begin()
" Surrounds text with other text like parentheses or HTML tags
Plug 'https://github.com/tpope/vim-surround'
" Some more plugins, probably
call plug#end()
It works! I have no idex why it works. Thanks very much! I spent hours googling, nothing worked.
In Windows 10, $XDG_CONFIG_HOME in nb720's script should be changed to $HOME which will create a nvim directory in %USERPROFILE% (\Users\Username). to hold autoload.
I have the latest version of neovim, and when I run it using my .vimrc symlinked as .nvimrc I get the following error:
the vimPlug.vim file is sourced in my
.vimrc
and contains the following:I'm really not sure what is causing this, I already tried commenting out all plugins, reinstalling neovim etc. but it still fails on the vim-plug initialisation.