Skip to content

Commit

Permalink
Pull request #21: Allow module blacklisting in omni completion
Browse files Browse the repository at this point in the history
See also:
 - #12
 - #21
  • Loading branch information
xolox committed Jun 16, 2014
1 parent 96082b7 commit d85872c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -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]:
Expand Down
9 changes: 6 additions & 3 deletions autoload/xolox/lua.vim
@@ -1,9 +1,9 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
" 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('<sfile>:p:h:h:h') . '/misc/lua-ftplugin'
let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua'
let s:globals_script = s:miscdir . '/globals.lua'
Expand Down Expand Up @@ -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
Expand Down
25 changes: 22 additions & 3 deletions doc/ft_lua.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d85872c

Please sign in to comment.