Vim-plug: neovim Unknown function: plug#begin

Created on 11 Jun 2015  路  8Comments  路  Source: junegunn/vim-plug

I have the latest version of neovim, and when I run it using my .vimrc symlinked as .nvimrc I get the following error:

Error detected while processing /Users/alexander/.vim/settings/vimPlug.vim:
line   16:
E117: Unknown function: plug#begin

the vimPlug.vim file is sourced in my .vimrc and contains the following:

"setup vim-plug {{{

  "Note: install vim-plug if not present
  if empty(glob('~/.vim/autoload/plug.vim'))
    silent !curl -fLo ~/.vim/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
"}}}

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.

Most helpful comment

Check the output of the following commands

  • :echo &rtp
  • :echo globpath(&rtp, 'autoload/plug.vim')

All 8 comments

@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

"}}}
Was this page helpful?
0 / 5 - 0 ratings