Pathogen (Vim) non-default bundle directory location - vim

I like the idea of keeping all my Vim plugins and my vimrc in Dropbox. I also love pathogen. Looking at the pathogen.vim file, it seems I can provide the pathogen#infect() function with an alternative location for my bundle folder. But this just doesn't work. I've searched high and low for a solution, but nothing I do will allow me to change the 'working directory', as it were, for pathogen to '~/Dropbox/Vim/GlobalRuntimePath/bundle'. I've tried sourcing pathogen.vim directly in my vimrc, to no avail. Pathogen doesn't complain, just my vimrc when it tries to call upon functions from plugins that no longer exists when I remove their local copies.
Am I asking the wrong questions?

There is a way for adding custom bundle directories provided in
Pathogen. First, one should append paths to the directories containing
additional bundles to the runtimepath option:
:set runtimepath+=~/Dropbox/Vim/GlobalRuntimePath
Then, when loading Pathogen in .vimrc file, one should specify the
name of all bundle directories (they must have the same one) as the
argument to the runtime_append_all_bundles call:
:call pathogen#runtime_append_all_bundles('bundle')
If bundle directories are named by default, bundle, the argument can
be omitted.

Related

Where do I save pathogen.vim so that the plugin installs

I've just downloaded the file pathogen.vim from vim.org
Where do I save this file so that it becomes part of gVim? In one of the runtimepath locations?
Does this .vim need to go in either of these locations?:
- C:\Program Files (x86)\Vim73\
- C:\Program Files (x86)\Vim\vimfiles\
You don't need pathogen to install plugins.
For the nth time this week, put your plugins into the C:\Users\username\vimfiles directory and your settings into the C:\Users\username\_vimrc file. You must create those directories/files yourself.
What you should have:
C:\Users\username\_vimrc
C:\Users\username\vimfiles\
C:\Users\username\vimfiles\autoload\
C:\Users\username\vimfiles\autoload\pathogen.vim
C:\Users\username\vimfiles\bundle\
Many Vim plugins have UNIX-oriented instructions and Vim itself is mostly UNIX-oriented so you'd better learn a thing or two about the UNIX command line.
If you are using windows, I recommend that you install your gVim into a custom directory instead of under Program Files or Program Files (x86) directories.
This makes things a lot easier going forward.
For instance, in a location like this:-
Install gvim in your user's home directory (e.g. C:\Users\whytheq\) (where whytheq is your user name) so it becomes C:\Users\whytheq\Vim73\.
Then, create a _vimrc file (with no file extension) there as well with the following contents:
set nocp
call pathogen#infect()
syntax on
filetype plugin indent on
Next, create a folder under C:\Users\whytheq\Vim73 called vimfiles with two subfolders beneath that, autoload and bundle.
Then, download the pathogen.vim file and moved it into the autoload folder.

pathogen#infect not updating the runtimepath

I have started working with pathogen.vim with gvim on Windows, following Tim Pope's setup guide at his github repository here.
However, I'm running into the problem that pathogen#infect() does not seem to be modifying the runtimepath (as seen by running :echo &runtimepath in gvim).
The simple test case _vimrc that I came up with is as follows. Please note that pathogen gets loaded just fine.
"Set a base directory.
let $BASE_DIR='H:\development\github\vimrc'
"Source pathogen since it's not in the normal autoload directory.
source $BASE_DIR\autoload\pathogen.vim
"Start up pathogen
call pathogen#infect()
"call pathogen#infect('$BASE_DIR\functions')
Neither running pathogen#infect() without an argument (which should add the bundles directory under the vimfiles directory) nor specifying a directory to contain files works.
Substituting the pathogen#infect() call with pathogen#runtime_prepend_subdirectories('$BASE_DIR\functions'), which is what pathogen#infect() does fails to change the runtimepath as well.
Any ideas that I've missed? Any more information that would be helpful?
My repository with the non-trivial example is here.
EDIT
In addition to creating directories under the directory I infected, as mentioned by qqx, I renamed those directories to plugin and colors which Vim will automatically load vim files from.
pathogen#infect() doesn't add the bundle directory or the directory named in the argument to &runtimepath, only subdirectories of that directory. In your github repository, the vimrc file uses the functions directory as the argument, but that directory only has files in it no subdirectories.

Plugins in gVim not working

I need help in installing some of the popular plugins in Vim. I just started learning this editor and is very excited to use the popular plugins. I'm using gVim in Windows XP and have extracted the .vim files and copied them to the Program Files folder of Vim.
Inside my "F:\Program Files\Vim" folder, there are exactly two folders the "vim73" and the "vimfiles" folder. I put the .vim files (EasyMotion.vim) into the "plugin" folder inside the "vimfiles" folder.
When I run gVim, the plugins doesn't work, and in my case, the EasyMotion plugin is not working. I typed the "/w" to make the EasyMotion plugin work (as stated on its usage on its github account) and nothing seems to work.
Am I missing out something here? Are there extra commands to put in the vimrc file to recognize those plugins?
Cheers!
Never touch Program Files. There is a vim setting called 'runtimepath' (see the :help 'rtp') that says where Vim is going to locate the plugins. For each directory in the runtimepath, Vim will source every .vim file found in the plugin subfolder, and lookup for functions containing # in their names in the .vim files of the autoload folder. It will also lookup filetype plugins in the ftplugin folder when 'ft' is set.
Normally you should have %HOMEPATH%\Vim\vimfiles in your runtimepath (:echo &rtp to know). Unzip Easymotion there, NOT in Program Files.
Due to that structure, vim plugins mix up in the same 2-3 folders. However it is possible to install every plugin in its own subfolder if you play with runtimepath. The pathogen plugin is dedicated to that. It makes it possible to have every plugin in its own subfolder, and adds every plugin root folder to the runtimepath. The Readme is self-explanatory.
As #benoit said, you should never in general put files into your vim73 folder
(notable exceptions exist, but you'll know when you encounter them).
On windows, Vim searches for configuration files (those include _vimrc and your
plugins) in several directories, in a certain order. First it will look in
$HOME ... which is your c:\documents and settings\username\ folder
$VIM ... which is the folder where you installed or extracted Vim
$VIMRUNTIME ... which is your \vim73 folder ...
and so on ...
What this means? It means it will first look in $HOME before looking in let's
say, your Vim install folder. So it is a nice way of separating plugins which
you just want to test out before being sure you're gonna be keeping them.
For example, you could organize your Vim related files in this manner:
- install vim to c:\vim or c:\program files\vim\
(vim's program files will go in \...\vim\vim73\)
- put your _vimrc in \vim\
- put your vimfiles in \vim\vimfiles\
- and put your temporary vimfiles in c:\documents and settings\username\vimfiles\
That way when you're done with them, you can just delete that last
\username\vimfiles\ folder.

gvim pathogen issues

I downloaded pathogen.vim from github and put it in "autoload" directory under ~/.vim. However now when I fire up gvim, and do :helptags, it says "Argument required". The contents of my ~/.vimrc file are:
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
What am I missing?
Thanks.
Andy
PS: I am doing this so that I can install Nerdtree
--- EDIT 1 ---
Based on what I have seen so far, the pathogen.vim plugin from github did not work for me, so I had to download it from vim.org, and it worked. However now when I do "unzip nerd_tree -d ~/.vim/bundle" and then start up gvim, I can still not find nerdtree.
-----End ---------
According to the pathogen README on github site, you should use :Helptags instead of :helptags. With :Helptags command executed, pathogen should generate all the documentations under directory ~/.vim/bundle now.
helptags is a vim command which has nothing to do with pathogen. The helptags command in vim takes a directory as an argument where it will process .txt files and generate the tags file.
To tell if pathogen is loading correctly you should be able to attempt to :call pathogen#helptags(). If running that manually does not fail, then pathogen is loaded (this is actually unnecessary if you are not getting an error when you start vim because your .vimrc is already running these commands).
The next step for you to complete is to read the documentation provided here on how to install a plugin as a bundle. To summarize:
Make a directory called ~/.vim/bundle
Unzip/clone/copy files from an upstream source into ~/.vim/bundle/plugin-name/. This may contain many files and directories (ftplugin, autoload, doc, etc.).
Fire up vim and test that the functionality provided by plugin-name is available. If not, check that you have completed the above steps correctly.
If you're having problems with pathogen, just remember installing a bundle is not all that different than installing a plugin the normal way. The advantage is you get to keep all files and folders related to that specific plugin in their own directory. This allows you to manage each plugin individually and be confident you are only touching files related to that plugin.
I use pathogen and I find it great, but you don't need pathogen at all to use NERDTree.
Just put the files like this then issue :helptags ~/.vim/doc and it will work:
~/.vim/doc/NERD_tree.txt
~/.vim/nerdtree_plugin/exec_menuitem.vim
~/.vim/nerdtree_plugin/fs_menu.vim
~/.vim/plugin/NERD_tree.vim
My setup with pathogen is very standard:
~/.vim/bundle/NERD_tree/doc/NERD_tree.txt
~/.vim/bundle/NERD_tree/nerdtree_plugin/exec_menuitem.vim
~/.vim/bundle/NERD_tree/nerdtree_plugin/fs_menu.vim
~/.vim/bundle/NERD_tree/nerdtree_plugin/insert_image.vim <-- a custom script not included with the distribution
~/.vim/bundle/NERD_tree/plugin/NERD_tree.vim
and works like a charm.
It it helps, here are the first lines of my ~/.vimrc:
" This must be first, because it changes other options as side effect
set nocompatible
" Use pathogen to easily modify the runtime path to include all plugins under
" the ~/.vim/bundle directory
filetype off " force reloading *after* pathogen loaded
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
filetype plugin indent on " enable detection, plugins and indenting in one step

Moving vimfiles location breaks snipmate.vim?

I'm working on moving my whole vim config to my Dropbox folder in order share it between machines more effectively. To do this, I've changed my .vimrc to the following:
set runtimepath+=$HOME/My\ Documents/Dropbox/vim
source $HOME\My Documents\Dropbox\vim\vimrc.vim
vimrc.vim looks like this:
set nocompatible
filetype on
filetype plugin on
filetype indent on
syntax enable
The problem is then that snipMate.vim no longer works. I know that there aren't any plugins interfering with it, as I've done a fresh install of vim and removed all the other plugins. It worked perfectly before I moved the plugins to the dropbox folder. I think it may have something to do with the fact that the after directory in vimfiles doesn't seem to be getting read once I move the plugin folder to the dropbox (i.e. after/snipmate.vim only shows up in :scriptnames when I have vimfiles as the plugin folder). I've tried explicitly sourcing the script in the after directory by adding the following to my .vimrc:
source $HOME\My Documents\Dropbox\vim\after\plugin\snipMate.vim
but snipmate still doesn't work.
Any ideas on fixing this?
You have to add the after directory to 'runtimepath' if you want Vim to look for it.
set runtimepath^=$HOME/My\ Documents/Dropbox/vim
set runtimepath+=$HOME/My\ Documents/Dropbox/vim/after
This follows the normal behavior of having your personal vim directory sourced first, then the system-wide stuff, and finally your personal after directory.

Resources