4

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 mappings specific to the plugin plugin_name would be wrapped in this if statement:

if index(plugin_list, 'plugin_name') != -1
  <special maps here>
endif

The index command returns -1 if the string 'plugin_name' is not contained in the list plugin_list.

2

1 Answer 1

5

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 and acknowledge you have read our privacy policy.

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