diff --git a/README.md b/README.md index d2bf282..fc1dd16 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,18 @@ If you want to use the omni completion despite the warnings above, execute the f Now when you type Control-X Control-O Vim will hang for a moment, after which you should be presented with an enormous list of completion candidates :-) +### The `lua_omni_blacklist` option + +If you like the omni completion mode but certain modules are giving you trouble (for example crashing Vim) you can exclude such modules from being loaded by the omni completion. You can do so by setting `lua_omni_module_blacklist` to a list of strings containing Vim regular expression patterns. The patterns are combined as follows: + + " Here's the black list: + let g:lua_omni_blacklist = ['pl\.strict', 'lgi\..'] + + " Here's the resulting regular expression pattern: + '^\(pl\.strict\|lgi\..\)$' + +The example above prevents the module `pl.strict` and all modules with the prefix `lgi.` from being loaded. + ### The `lua_define_completefunc` option By default the Lua file type plug-in sets the ['completefunc'] [] option so that Vim can complete Lua keywords, global variables and library members using Control-X Control-U. If you don't want the 'completefunc' option to be changed by the plug-in, you can set this option to zero (false) in your [vimrc script] [vimrc]: diff --git a/autoload/xolox/lua.vim b/autoload/xolox/lua.vim index 7634ffb..273f115 100644 --- a/autoload/xolox/lua.vim +++ b/autoload/xolox/lua.vim @@ -1,9 +1,9 @@ " Vim auto-load script " Author: Peter Odding -" Last Change: June 16, 2014 +" Last Change: June 17, 2014 " URL: http://peterodding.com/code/vim/lua-ftplugin -let g:xolox#lua#version = '0.7.18' +let g:xolox#lua#version = '0.7.19' let s:miscdir = expand(':p:h:h:h') . '/misc/lua-ftplugin' let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua' let s:globals_script = s:miscdir . '/globals.lua' @@ -383,7 +383,10 @@ function! xolox#lua#getomnimodules() " {{{1 " Always include the standard library modules. call extend(modules, ['coroutine', 'debug', 'io', 'math', 'os', 'package', 'string', 'table']) call sort(modules, 1) - let msg = "lua.vim %s: Collected %i module names for omni completion in %s" + let blacklist = xolox#misc#option#get('lua_omni_blacklist', []) + let pattern = printf('^\(%s\)$', join(blacklist, '\|')) + call filter(modules, 'v:val !~ pattern') + let msg = "lua.vim %s: Collected %i module names for omni completion in %s." call xolox#misc#timer#stop(msg, g:xolox#lua#version, len(modules), starttime) return modules endfunction diff --git a/doc/ft_lua.txt b/doc/ft_lua.txt index 8b12447..789b9f8 100644 --- a/doc/ft_lua.txt +++ b/doc/ft_lua.txt @@ -18,9 +18,10 @@ Contents ~ 10. The |lua_complete_library| option 11. The |lua_complete_dynamic| option 12. The |lua_complete_omni| option - 13. The |lua_define_completefunc| option - 14. The |lua_define_omnifunc| option - 15. The |lua_define_completion_mappings| option + 13. The |lua_omni_blacklist| option + 14. The |lua_define_completefunc| option + 15. The |lua_define_omnifunc| option + 16. The |lua_define_completion_mappings| option 4. Commands |ft_lua-commands| 1. The |:LuaCheckSyntax| command 2. The |:LuaCheckGlobals| command @@ -211,6 +212,24 @@ following command: Now when you type Control-X Control-O Vim will hang for a moment, after which you should be presented with an enormous list of completion candidates :-) +------------------------------------------------------------------------------- +The *lua_omni_blacklist* option + +If you like the omni completion mode but certain modules are giving you trouble +(for example crashing Vim) you can exclude such modules from being loaded by +the omni completion. You can do so by setting 'lua_omni_module_blacklist' to a +list of strings containing Vim regular expression patterns. The patterns are +combined as follows: +> + " Here's the black list: + let g:lua_omni_blacklist = ['pl\.strict', 'lgi\..'] + + " Here's the resulting regular expression pattern: + '^\(pl\.strict\|lgi\..\)$' +< +The example above prevents the module 'pl.strict' and all modules with the +prefix 'lgi.' from being loaded. + ------------------------------------------------------------------------------- The *lua_define_completefunc* option