How to make vim pathogen to reload plugins? - vim

Is it possible to make vim to reload pathogen plugins without restarting vim?
I have opened vim with many files, then I add plugin to:
~/.vim/bundle
Since now I'd like to force vim to use the new plugin.

Pathogen just manipulates the 'runtimepath' option; the situation with plugin reloads is therefore the same as with the plain default plugin structure. (Other plugin managers may offer this kind of reload / dynamic enable functionality; I suppose you want to stick with Pathogen.)
To retroactively enable a plugin in a running Vim session, you need to :source all (usually that's only one) plugin scripts that have been added. For a plugin named foobar, that would be:
:source ~/.vim/bundle/foobar/plugin/foobar.vim
If you can get Pathogen to re-initialize the 'runtimepath' (or augment it yourself via :set rtp+=~/.vim/bundle/foobar), you can also use the shorter
:runtime plugin/foobar.vim

If you use a modern version of vim, you can use its built-in package manager, which has a convenient function to reload all plugins:
:packloadall
http://vimhelp.appspot.com/repeat.txt.html#%3Apackloadall

I was in the same boat before util I find an awesome plugin(vim-reload) to do these stuffs automatic in an amazing way.You should have a shot at this plugin.

Related

How can I use vim plugins with Ideavim?

I would like to use Tim Pope's vim surround plugin in my Pycharm IDE. I've been using the IdeaVim plugin for Pycharm to use vim motions and commands.
I know I can use ~/.ideavimrc like my normal .vimrc but I cannot find
information about how to use plugins with ideavim.
Can I specify the plugins directory inside my ~/.ideavimrc or do I have to go another way? Can I use a plugin manager like pathogen?
The latest version of IdeaVim includes the vim-surround plugin. Enable it by adding
set surround
to your .ideavimrc file
https://github.com/JetBrains/ideavim#emulated-vim-plugins
Most applications only emulate Vim's / vi key bindings (and often only the basic navigation and editing commands). That goes a long way to helping vi users edit comfortably, but it isn't the real thing.
Unfortunately, to be able to use Vim plugins, you'll need the full Vimscript interpreter and infrastructure around 'runtimepath'. I'm not aware of any application that provides this, and because of the complexities and idiosyncrasies of Vim, this would be very hard indeed.
To get more of Vim's special capabilities into your IDE, use both concurrently; it is very easy to set up a external tool in your IDE that launches Vim with the current file (and position). Automatic reloading of changes allows you to edit source code in both concurrently.
If it's any comfort to you, the same applies to Emacs / Elisp as well.
The ideaVim plugin added "Support for vim-surround commands ys, cs, ds, S, enable it with set surround in your ~/.ideavimrc" since version 0.46.
No. Vote for VIM-506 for Vim scripts support (unlikely to be implemented) and for VIM-769 for vim-surround emulation (likely to appear in future versions).
This was mentioned in a changelog relatively recently.
https://github.com/JetBrains/ideavim/blob/master/CHANGES.md#features-5
I didn't mange this work. Looks like I need vim-plug installed and I use another package manager in my NeoVim and also I don't want to mix up two configs. It should work in general.

How can I reload a VIM plugin after VIM was started?

I am modifying an installed VIM plugin and in another Terminal tab I am testing the results.
Each time I want to test the changes I have to restart VIM.
Is there any faster way to do this process? How can I reload a VIM plugin after VIM was started?
The plugin is installed via Vundle
I have tried to run :so % that is supposed to reload the .vimrc file but I still cannot see my changes.
If there weren't an inclusion guard (if ! exists('g:loaded_pluginname') ...), you could simply :runtime! plugin/pluginname.vim (or :source % if it's currently opened) and all plugin definitions would be re-read.
But as most plugins (correctly) use such a guard, you need to :unlet that variable first:
:unlet g:loaded_pluginname | runtime! plugin/pluginname.vim
My ReloadScript plugin can do this with one command if the guard name adheres to the canonical naming, and the scriptease plugin has such a command, too.
Edit: Some plugins use differently named guard variables, or other ways that prevent reloading. The plugins from mattn (like emmet.vim) are quite elaborate; maybe there's some special mechanism; I don't use that plugin. You could ask the author for advice, though.

Manually and conditionally load plugins for Vim

I have two different projects that I'm working on (let's call them projA and projB) that have their own Vim plugins.
Each plugin folder has an ftdetect, ftplugin, plugin and syntax subfolder, and each deals with the same type of files (.cpp, .html, etc).
If I load both sets of plugins then nothing I want works right so I need a way to only load the plugin that corresponds to the project I'm working on.
My idea is to detect what my current working directory is via getcwd() and then only load the relevant plugin, but I have no idea how to manually load a single plugin.
I'm currently using Vundle to manage the rest of my plugins.
With vim-plug
The vim-plug plugin manager supports loading plugins conditionally.
This is straight from their readme:
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Package managers like Vundle and Pathogen separate each plugin into its own subtree and concatenate all those paths into the 'runtimepath' option so that Vim considers all of them. That makes it particularly simple to disable plugins: Just prevent the inclusion of the plugin's subtree into 'runtimepath'.
Vundle references plugins in ~/.vimrc via Bundle 'foo/bar' commands, so you just have to put a conditional around it:
if getcwd() ==# '/work/cpp'
Bundle example/cpp
else
Bundle example/other
endif
conventional approach
With a conventional, single ~/.vim/ configuration hierarchy, you'd have to resort to suppressing plugin loads by setting the canonical g:loaded_PluginName inclusion guard. This requires support from the plugin, and mostly won't work for ftplugins, indent, and syntax scripts.

Syntastic not working with MiniBufExplorer vim plugin

First off I'm a windows user using VIM and vundle to manage my plugins.
I have the Syntastic vim plugin (https://github.com/scrooloose/syntastic) and it works great highlighting any syntax errors for the first javascript file I open and save.
I also have the minibufexplorer plugin (https://github.com/sontek/minibufexpl.vim). Once I open a second file the MiniBufExplorer window appears allowing me to navigate between previously opened files via :b1, :b2, etc. I've noticed when this happens Syntastic stops working.
If I remove the minibufexplorer plugin then Syntastic always works. I'd really like to get both working together, does anyone have a solution for this? I would gladly use an alternative to minibufexplorer if it works with Syntastic.
I'm using pathogen to organize my installed plugins. I have syntastic and minibufexplorer and they work well together for me.
I have done no configuration at all to any of thees plugins. But to handle bufferswitching in an easy way (also works without minibufexplorer) I use this in my .vimrc:
map § :bnext^M
map ½ :bprevious^M
Its the key just below the Esc-key. It makes it very easy to just hit the § key to cycle through all open buffers.
Here is a good place to start your configuration.
Since I'm open to alternatives I will be removing the MiniBufExplorer plugin and using the :ls vim command to view the buffer list when desired. It's not as convenient as using the MiniBufExplorer plugin but I find syntax highlighting more important and am satisfied with this workaround.

share eclim -friendly .vimrc

I am trying to to use eclim for my daily development requirements. My .vimrc has some issues preventing few functionalities like code completion etc.
It would be great if anyone using eclim regularly share your .vimrc.
You can find my vim setup on github. I use eclim to do Android development.
See visualstudioinvoke.vim for how I launch Vim from eclim. This isn't necessary, but it's useful to start at the current line in the current file. It also sets up my eclim menu, bindings, and settings.
It's best to start the eclim server (by opening the "Eclim" eclipse tab) before you start gvim.
I have eclim's code completion mapped to Ctrl-Space.
You won't get any code completion for classes that aren't in the scope of the current file. To import, I have a menu option under Eclim > ImportMissing.
However, my vimrc might be pretty alien to you, so you might be better served whittling down your vimrc until you figure out what's breaking things. The default map for completions is Ctrl-x Ctrl-u. You can use :verb map <C-x> to search for maps that start the same way and it will show you where they're defined.
If you use SuperTab, try disabling it. SuperTab and eclim are both maintained by
Eric Van Dewoestine so they should be compatible, but you may have a SuperTab configuration problem.
You could also try updating all of your plugins.

Resources