Skip to content
Browse files

Added addon_completion_lhs option

--HG--
branch : cxcpoption
  • Loading branch information...
1 parent 6e7790c commit e2c4c75e7e2bc4761f05102709d6c350bef6fde2 @ZyX-I ZyX-I committed Jan 25, 2012
Showing with 21 additions and 9 deletions.
  1. +14 −9 autoload/vam.vim
  2. +7 −0 doc/vim-addon-manager.txt
View
23 autoload/vam.vim
@@ -6,7 +6,7 @@
" don't need a plugin. If you want to use this plugin you call Activate once
" anyway
-augroup VIM_ADDON_MANAGER
+augroup VAM_addon_info_handlers
autocmd!
autocmd BufRead,BufNewFile *-addon-info.txt,addon-info.json
\ setlocal ft=addon-info
@@ -43,6 +43,7 @@ unlet s:d
let s:c['plugin_root_dir'] = expand(s:c['plugin_root_dir'])
let s:c['dont_source'] = get(s:c, 'dont_source', 0)
let s:c['plugin_dir_by_name'] = get(s:c, 'plugin_dir_by_name', 'vam#DefaultPluginDirFromName')
+let s:c['addon_completion_lhs'] = get(s:c, 'addon_completion_lhs', '<C-x><C-p>')
" More options that are used for plugins’ installation are listed in
" autoload/vam/install.vim
@@ -364,13 +365,17 @@ command! -nargs=* -complete=customlist,vam#install#UninstallCompletion Uninstall
" plugin name completion function:
-augroup VAM
- function! s:CompleteAddonName()
- let savedof=&l:omnifunc
- let &l:omnifunc='vam#install#CompleteAddonName'
- return "\<C-x>\<C-o>\<C-r>=['', setbufvar('%', '&omnifunc', ".string(savedof).")][0]\n"
- endfunction
- autocmd FileType vim inoremap <buffer> <expr> <C-x><C-p> <SID>CompleteAddonName()
-augroup END
+if !empty(s:c.addon_completion_lhs)
+ augroup VAM_addon_name_completion
+ autocmd!
+ function! s:CompleteAddonName()
+ let savedof=&l:omnifunc
+ let &l:omnifunc='vam#install#CompleteAddonName'
+ return "\<C-x>\<C-o>\<C-r>=['', setbufvar('%', '&omnifunc', ".string(savedof).")][0]\n"
+ endfunction
+ let s:lhs=escape(substitute(s:c.addon_completion_lhs, ' ', '<Space>', 'g'), '|')
+ execute 'autocmd FileType vim inoremap <buffer> <expr> '.s:lhs.' <SID>CompleteAddonName()'
+ augroup END
+endif
" vim: et ts=8 sts=2 sw=2
View
7 doc/vim-addon-manager.txt
@@ -411,6 +411,10 @@ vam#install#RewriteName({name}) *vam#install#RewriteName()*
"url": "git://github.com/{N}/{Repo}"}
git:{URL} {"type": "git", "url": {URL}} (experimental)
+vam#install#CompleteAddonName *vam#install#CompleteAddonName()*
+ Function suitable to be a completion function for omni completion
+ ('omnifunc'). Completes addon names. See also |VAM-addon_completion_lhs|.
+
==============================================================================
4. Options *VAM-options*
*g:vim_addon_manager*
@@ -480,6 +484,9 @@ pool_fun *VAM-pool_fun*
{{plugin-name}: {repository}} ({repository} is described under
|addon-info-repository|) map.
Default is "vam#install#Pool".
+addon_completion_lhs *VAM-addon_completion_lhs*
+ {lhs} of the mapping that uses |vam#install#CompleteAddonName()| for
+ completion. Default: "<C-x><C-p>". Spaces and bars are escaped.
The following options are used by vim-addon-manager-known-repositories, not by
VAM itself. So if you set |vim-addon-manager-known| to another value they may

0 comments on commit e2c4c75

Please sign in to comment.
Something went wrong with that request. Please try again.