1

I have pathogen set up in my vim installation and various plugins installed.

"Call pathogen to set up various plugins
"filetype off
call pathogen#infect()
call pathogen#incubate()
call pathogen#helptags()

When I write my .vimrc in vim, the following command is supposed to reload the file (and it does seem to work).

" Source the vimrc file after saving it
if has("autocmd")
  autocmd bufwritepost .vimrc source $MYVIMRC
endif

After writing .vimrc, however, pathogen does not reload.

Here is the output of :set rtp? after starting vim:

runtimepath=~/.vim,~/.vim/bundle/Jellybeans,~/.vim/bundle/TwitVim,~/.vim/bundl
e/badwolf,~/.vim/bundle/calendar,~/.vim/bundle/tagbar,~/.vim/bundle/vim-airline,
~/.vim/bundle/vim-colors-solarized,~/.vim/bundle/vim-colorschemes,~/.vim/bundle/
vizardry,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/s
hare/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after 

and after :w in .vimrc it returns to the default.

 runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/
vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after

I tried adding the following modification to no avail...

if has("autocmd")
    autocmd bufwritepost .vimrc source $MYVIMRC
    autocmd bufwritepost .vimrc call pathogen#incubate()
endif

I've been looking around and can't seem to find a solution other than just restarting vim every time I modify my .vimrc, which is fairly disruptive. Any help would be appreciated.

edit: output of tree -d -L 2...

.
├── autoload
└── bundle
    ├── badwolf
    ├── calendar
    ├── color~
    ├── Jellybeans
    ├── tagbar
    ├── TwitVim
    ├── vim-airline
    ├── vim-colorschemes
    ├── vim-colors-solarized
    └── vizardry
thoss
  • 13
  • 3
  • 1
    Why do you call `pathogen#incubate()`? It gets called by `pathogen#infect()` so there would be no reason to include it. Also I can not replicate this from the code snippets you have posted. – FDinoff Feb 19 '14 at 05:07
  • 1
    Also make sure to put your autocmds in groups http://stackoverflow.com/questions/18024842/vimrc-file-takes-longer-and-longer-to-reload/18025045#18025045 – FDinoff Feb 19 '14 at 05:13
  • I added pathogen#incubate a while ago after being prompted by the program, I believe, and as I was diagnosing the problem I think I tried different combinations of execute pathogen#infect(), call pathogen#infect(), and call pathogen#incubate()... For a while I just thought pathogen#infect() was broken. However, it does seem to work, until I write my .vimrc. – thoss Feb 19 '14 at 06:32
  • As for autocmd, I will address that, but saving my .vimrc doesn't seem like it should reset the rtp, right? I can post the whole file up on pastebin. It's a bit of a hodgepodge as I'm new to vim. http://pastebin.com/YUU0HyVu – thoss Feb 19 '14 at 06:35
  • OK, I did the obvious. Commenting out `autocmd bufwritepost .vimrc source $MYVIMRC` seems to remove the problem. I liked that feature though, since I am often discovering new features and modifying .vimrc very frequently, so any help implementing this without breaking pathogen would be nice. – thoss Feb 19 '14 at 07:07

1 Answers1

1

The problem may be the following lines on your .vimrc:

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

On $VIMRUNTIME/debian.vim there is a line that reset the runtime path:

" Debian system-wide default configuration Vim

set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after

The problem doesn't happens when the .vimrc is loaded on startup because these lines are executed before call pathogen#infect(). When you reload your .vimrc you are overwriting your &rtp, but pathogen doesn't set it again (possible because s:done_bundles is already set).

mMontu
  • 8,983
  • 4
  • 38
  • 53
  • The following code fixes it: `if (exists("g:loaded_pathogen")==0) runtime! debian.vim endif` – thoss Feb 20 '14 at 03:52
  • @thoss `!exists()` is an idiom easier to understand when compared to `exists() == 0`, but of course they achieve the same result. – mMontu Feb 20 '14 at 11:11
  • Right, I realized that shortly after posting -- I had mistyped the !exists command and thought that syntax didn't work in vim. – thoss Feb 21 '14 at 05:59