1

Oftentimes I'll want to put remaps in my .vimrc that use plugin commands. When a plugin happens to not be installed, these remaps will result in errors. A simple workaround would be to put an if-statement around plugin-specific remaps that checks whether that plugin has been activated.

How can I do this with VimPlug? Does VimPlug store a list somewhere?


Edit, to clarify things: I need an actual list or a string, not the panel that :PlugStatus brings up. For example: with a list of activated plugins, any remaps specific to the plugin pluginname would be wrapped in this if statement:

if index(pluginlist, "pluginname")!=-1
  <special remaps here>
endif

The index command returns -1 if the string "pluginname" is not contained in the list pluginlist.

2

You can get all plugs from g:plugs_order list or g:plugs dict. g:plugs's value also contain useful config infomation about the plug. Like dir where the plug is installed.

So, you can use:

if has_key(g:plugs, "name")
    " do something
endif

to check and do something when the plug exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.