6

There are a few questions intertwined -- I hope I convey my intentions well enough so that someone understands where I'm confused and what I'm trying to do. I apologize ahead of time for the chaotic state of this post.

I have neovim installed via homebrew (OSX/macOS).

I plan to use nvim exclusively as a replacement for vim, and I plan to utilise gvim once I sort out this confusion.

The directory /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime contains an autoload directory amongst much more:

├── autoload/
├── bugreport.vim
├── colors/
├── compiler/
├── delmenu.vim
├── doc/
├── filetype.vim
├── ftoff.vim
├── ftplugin/
├── ftplugin.vim
├── ftplugof.vim
├── indent/
├── indent.vim
├── indoff.vim
├── keymap/
├── macmap.vim
├── macros/
├── makemenu.vim
├── menu.vim
├── mswin.vim
├── optwin.vim
├── pack/
├── plugin/
├── print/
├── scripts.vim
├── synmenu.vim
├── syntax/
├── tutor/
└── vimrc_example.vim

When installing vim-pathogen, the installation leads you to create the directories autoload and bundle within the ~/.vim directory.

I see that there are many important vim files in the runtime directory. I want to avoid redundancy as much as possible.

Would it be more efficient to symlink one/more of the directories in ~ to the runtime directory - or perhaps one/more of its subdirectories?

When installing vim plugins and other vim files to the config directory in my home directory, should I ensure that the same plugin files aren't located in both homebrew's autoload directory and ~/.vim/autoload? In other words, do I need to verify beforehand that a particular vim file isn't already located in homebrew's runtime directory for nvim before installing said vim file in ~/.vim/? Would it be more efficient to install all files in ~/.config/nvim instead of ~/.vim?

Should I modify the execute pathogen#infect() line in my .vimrc to reflect the runtime (or some other) directory?

I have /usr/bin/vim but not vim from homebrew. Would it make things easier if I installed homebrew's vim installed? This is something I eventually plan to do.


With syntax on in my .vimrc I receive this error every time I launch vim or nvim:

Can't open file /usr/bin/vim/syntax/syntax.vim

Yet syntax.vim exists within the runtime directory for nvim mentioned above.


What I have done so far:

  • Per here I have

    mkdir ~/.config
    ln -s ~/.vim ~/.config/nvim
    ln -s ~/.vimrc ~/.config/nvim/init.vim
    
  • In attempt to troubleshoot, I've started with a new .vimrc that contains

    execute pathogen#infect()
    syntax on
    filetype plugin indent on
    
  • pathogen.vim is the only file located within ~/.vim/autoload

  • Variable EDITOR is set to nvim in .bash_profile

  • I've reviewed this question.

With .vimrc containing only the three lines above, I get the following errors when I run vim and nvim, respectively:

vim

    Error detected while processing /Users/user/.vimrc:
    line    2:
    E484: Can't open file /usr/bin/vim/syntax/syntax.vim
    Press ENTER or type command to continue

nvim

    Error detected while processing /Users/user/.config/nvim/init.vim:
    line    1:
    E117: Unknown function: pathogen#infect
    E15: Invalid expression: pathogen#infect()
    line    2:
    E484: Cannot open file /usr/bin/vim/syntax/syntax.vim
    Press ENTER or type command to continue

The ultimate question isn't necessarily surrounding vim-pathogen, but rather trying to find a sound way to understand and manage all configurations (including directories) between vim, nvim, gvim, etc.

I sincerely appreciate any help.

1 Answer 1

13

You're looking at this all wrong. Read :h 'runtimepath'.

'runtimepath' or 'rtp' is analogous to $PATH in the shell. The files you see in /usr/local/Cellar/neovim/0.1.7/share/nvim/runtime is the pristine runtime files that come with Neovim. You should not add files to it.

If you want to see where scripts will be loaded from by default, run:

nvim -u NONE

Then

:echo &rtp

For Neovim, the default location is $HOME/.config/nvim. The directory structure there is expected to be the same as what's described in :h 'rtp'.

Specific plugin managers aside, all they do is help you manage 'rtp'. As an example, say you want to use one of my plugins: django-plus.vim

You will note that it has an autoload, after, and doc directory. These aren't meant to be merged into a monolithic directory. The entire repository is meant to be taken as-is in its own directory. If you decided to download it and place it into ~/vim-plugins, without a plugin manager, you would need to add it to 'rtp' in your init.vim script:

set rtp+=~/vim-plugins/django-plus.vim

Now the plugin is "installed". But, this is not the best method since it's being appended to the list. Ideally it should be prepended because django-plus.vim has a script filetype.vim that should run before $VIMRUNTIME/filetype.vim (like how $PATH is searched). All plugins will want to be prepended to the 'rtp' since the whole point is to override defaults. This is where plugin managers help you manage all of this.

I plan to use nvim exclusively as a replacement for vim, and I plan to utilise gvim once I sort out this confusion.

Neovim has GUIs.

With syntax on in my .vimrc I receive this error every time I launch vim or nvim:

Can't open file /usr/bin/vim/syntax/syntax.vim

You somehow changed 'rtp' or broke the runtime directories. Again, confirm with :echo &rtp.


On the topic of plugin managers, just use vim-plug. Everyone has their opinion about what the best plugin manager is, but I've never heard anyone say that vim-plug was hard to use.

call plug#begin('~/.local/share/nvim/plugged')
Plug 'tweekmonster/django-plus.vim'
" ...and so on...
call plug#end()

Then you run :PlugUpdate every now and then to keep things up to date.

Pathogen is minimalistic and leaves you still managing the plugins yourself. There's people that like this, but I'm not among them. I use a lot of plugins and I don't want to spend my time checking in on each one to see if they've been updated.

2
  • Thank you very much for helping me wrap my head around this, and thanks for vim-plug. I was sure that I hadn't explicitly modified vim's runtimepath, but I did notice a line in my .bash_profile, export VIM="$(command -v vim)". Changing this to ='/usr/local/share/vim/vim80' seems to have worked (it fixed the errors vim/nvim was throwing). Does this send up any red flags in your opinion? Should this constant export be placed elsewhere? I also unlinked the sym link that I mentioned in my original post.
    – waxwing
    Jan 27, 2017 at 2:17
  • 1
    The runtime path is hardcoded in the binary. See :h $VIM. You shouldn't need to set $VIM at all unless you actually want to use a completely different set of runtime files (you probably don't). The only environment variable related to Vim you should be concerned with is $EDITOR and $VISUAL
    – Tommy A
    Jan 27, 2017 at 3: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.