Skip to content

Commit d85872c

Browse files
committed
Pull request #21: Allow module blacklisting in omni completion
See also: - #12 - #21
1 parent 96082b7 commit d85872c

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ If you want to use the omni completion despite the warnings above, execute the f
107107

108108
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 :-)
109109

110+
### The `lua_omni_blacklist` option
111+
112+
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:
113+
114+
" Here's the black list:
115+
let g:lua_omni_blacklist = ['pl\.strict', 'lgi\..']
116+
117+
" Here's the resulting regular expression pattern:
118+
'^\(pl\.strict\|lgi\..\)$'
119+
120+
The example above prevents the module `pl.strict` and all modules with the prefix `lgi.` from being loaded.
121+
110122
### The `lua_define_completefunc` option
111123

112124
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]:

autoload/xolox/lua.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim auto-load script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 16, 2014
3+
" Last Change: June 17, 2014
44
" URL: http://peterodding.com/code/vim/lua-ftplugin
55

6-
let g:xolox#lua#version = '0.7.18'
6+
let g:xolox#lua#version = '0.7.19'
77
let s:miscdir = expand('<sfile>:p:h:h:h') . '/misc/lua-ftplugin'
88
let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua'
99
let s:globals_script = s:miscdir . '/globals.lua'
@@ -383,7 +383,10 @@ function! xolox#lua#getomnimodules() " {{{1
383383
" Always include the standard library modules.
384384
call extend(modules, ['coroutine', 'debug', 'io', 'math', 'os', 'package', 'string', 'table'])
385385
call sort(modules, 1)
386-
let msg = "lua.vim %s: Collected %i module names for omni completion in %s"
386+
let blacklist = xolox#misc#option#get('lua_omni_blacklist', [])
387+
let pattern = printf('^\(%s\)$', join(blacklist, '\|'))
388+
call filter(modules, 'v:val !~ pattern')
389+
let msg = "lua.vim %s: Collected %i module names for omni completion in %s."
387390
call xolox#misc#timer#stop(msg, g:xolox#lua#version, len(modules), starttime)
388391
return modules
389392
endfunction

doc/ft_lua.txt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ Contents ~
1818
10. The |lua_complete_library| option
1919
11. The |lua_complete_dynamic| option
2020
12. The |lua_complete_omni| option
21-
13. The |lua_define_completefunc| option
22-
14. The |lua_define_omnifunc| option
23-
15. The |lua_define_completion_mappings| option
21+
13. The |lua_omni_blacklist| option
22+
14. The |lua_define_completefunc| option
23+
15. The |lua_define_omnifunc| option
24+
16. The |lua_define_completion_mappings| option
2425
4. Commands |ft_lua-commands|
2526
1. The |:LuaCheckSyntax| command
2627
2. The |:LuaCheckGlobals| command
@@ -211,6 +212,24 @@ following command:
211212
Now when you type Control-X Control-O Vim will hang for a moment, after which
212213
you should be presented with an enormous list of completion candidates :-)
213214

215+
-------------------------------------------------------------------------------
216+
The *lua_omni_blacklist* option
217+
218+
If you like the omni completion mode but certain modules are giving you trouble
219+
(for example crashing Vim) you can exclude such modules from being loaded by
220+
the omni completion. You can do so by setting 'lua_omni_module_blacklist' to a
221+
list of strings containing Vim regular expression patterns. The patterns are
222+
combined as follows:
223+
>
224+
" Here's the black list:
225+
let g:lua_omni_blacklist = ['pl\.strict', 'lgi\..']
226+
227+
" Here's the resulting regular expression pattern:
228+
'^\(pl\.strict\|lgi\..\)$'
229+
<
230+
The example above prevents the module 'pl.strict' and all modules with the
231+
prefix 'lgi.' from being loaded.
232+
214233
-------------------------------------------------------------------------------
215234
The *lua_define_completefunc* option
216235

0 commit comments

Comments
 (0)