added 'bindings' file

This commit is contained in:
2021-10-24 12:14:34 +02:00
parent aef3f53c7b
commit be403c40fb
2 changed files with 11 additions and 4 deletions

View File

@@ -15,7 +15,10 @@ Place this configuration before the `plug#begin()`
## Create or Edit
Just call `PlugConfig <pluginname>` 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 <pluginname|'bindings'>` 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 `<leader>n :NERDTreeFocus<CR>` for example.
## Installation

View File

@@ -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()