From be403c40fbe80d4f01023542f8fc6bb6febf6b05 Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Sun, 24 Oct 2021 12:14:34 +0200 Subject: [PATCH] added 'bindings' file --- README.md | 5 ++++- plugin/vim-plug-config.vim | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1f05557..8e8a94e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,10 @@ Place this configuration before the `plug#begin()` ## Create or Edit -Just call `PlugConfig ` and it will either open an existing one (first one found) or it will create one in the first directory. Autocomplete is supported, too. +Just call `PlugConfig ` and it will either open an existing one (first one found) or it will create one in the first directory. Autocomplete is supported, too. + +`binding` is a special one, it will always be present and loaded if the file exists, regardless of the existence of a plugin named like this. It can be used to have bindings/mapping which trigger the loading of a plugin. In my case it contains `n :NERDTreeFocus` for example. + ## Installation diff --git a/plugin/vim-plug-config.vim b/plugin/vim-plug-config.vim index 6ea0d36..e240c87 100644 --- a/plugin/vim-plug-config.vim +++ b/plugin/vim-plug-config.vim @@ -3,6 +3,10 @@ if exists("g:vim_plug_config") || &cp || v:version < 700 endif let g:vim_plug_config = 1 +function! s:get_plugin_names() + return keys(g:plugs) + ['bindings'] +endfunction + function! s:get_config_path(name, create) " uniform name, remove vim prefix let l:pluginconfig = tolower(a:name).'.vim' @@ -45,8 +49,8 @@ endfunction function! s:load_all_configs() let g:plugs_configs = {} - for plug in keys(g:plugs) - if has_key(g:plugs[plug], 'on') || has_key(g:plugs[plug], 'for') + for plug in s:get_plugin_names() + if has_key(g:plugs, plug) && ( has_key(g:plugs[plug], 'on') || has_key(g:plugs[plug], 'for') ) execute 'autocmd User ' . plug . ' call s:load_config("' . plug . '")' else call s:load_config(plug) @@ -55,7 +59,7 @@ function! s:load_all_configs() endfunction function! s:names(...) - return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0')) + return sort(filter(s:get_plugin_names(), 'stridx(v:val, a:1) == 0')) endfunction call s:load_all_configs()