Skip to content

Commit

Permalink
Make setting of completefunc/omnifunc optional (issue #15)
Browse files Browse the repository at this point in the history
See issue #15 on GitHub:
  #15
  • Loading branch information
xolox committed Aug 31, 2013
1 parent 73736ad commit 17e9003
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -103,6 +103,17 @@ 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_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]:

:let g:lua_define_completefunc = 0

### The `lua_define_omnifunc` option

By default the Lua file type plug-in sets the ['omnifunc'] [] option so that Vim can complete the names of all Lua modules installed on the local system. If you don't want the 'omnifunc' option to be changed by the plug-in, you can set this option to zero (false) in your [vimrc script] [vimrc]:

:let g:lua_define_omnifunc = 0

### The `lua_define_completion_mappings` option

Expand All @@ -118,6 +129,8 @@ This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/M
© 2013 Peter Odding &lt;<peter@peterodding.com>&gt;.


['completefunc']: http://vimdoc.sourceforge.net/htmldoc/options.html#'completefunc'
['omnifunc']: http://vimdoc.sourceforge.net/htmldoc/options.html#'omnifunc'
[cfu]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27completefunc%27
[dll]: http://en.wikipedia.org/wiki/Dynamic-link_library
[dof]: http://www.lua.org/manual/5.1/manual.html#pdf-dofile
Expand All @@ -141,4 +154,5 @@ This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/M
[shell]: http://peterodding.com/code/vim/shell/
[tob]: http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects
[vim]: http://www.vim.org/
[vimrc]: http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc
[vundle]: https://github.com/gmarik/vundle
4 changes: 2 additions & 2 deletions autoload/xolox/lua.vim
@@ -1,9 +1,9 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 19, 2013
" Last Change: August 31, 2013
" URL: http://peterodding.com/code/vim/lua-ftplugin

let g:xolox#lua#version = '0.7.12'
let g:xolox#lua#version = '0.7.13'
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
24 changes: 23 additions & 1 deletion doc/ft_lua.txt
Expand Up @@ -17,7 +17,9 @@ Contents ~
9. The |lua_complete_library| option
10. The |lua_complete_dynamic| option
11. The |lua_complete_omni| option
12. The |lua_define_completion_mappings| option
12. The |lua_define_completefunc| option
13. The |lua_define_omnifunc| option
14. The |lua_define_completion_mappings| option
4. Contact |ft_lua-contact|
5. License |ft_lua-license|
6. References |ft_lua-references|
Expand Down Expand Up @@ -198,6 +200,26 @@ 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_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:
>
:let g:lua_define_completefunc = 0
<
-------------------------------------------------------------------------------
The *lua_define_omnifunc* option

By default the Lua file type plug-in sets the |'omnifunc'| option so that Vim
can complete the names of all Lua modules installed on the local system. If you
don't want the 'omnifunc' option to be changed by the plug-in, you can set this
option to zero (false) in your |vimrc| script:
>
:let g:lua_define_omnifunc = 0
<
-------------------------------------------------------------------------------
The *lua_define_completion_mappings* option

Expand Down
14 changes: 9 additions & 5 deletions ftplugin/lua.vim
@@ -1,7 +1,7 @@
" Vim file type plug-in
" Language: Lua 5.1
" Author: Peter Odding <peter@peterodding.com>
" Last Change: May 15, 2013
" Last Change: August 31, 2013
" URL: http://peterodding.com/code/vim/lua-ftplugin

if exists('b:did_ftplugin')
Expand All @@ -24,12 +24,16 @@ let &l:includeexpr = 'xolox#lua#includeexpr(v:fname)'
call add(s:undo_ftplugin, 'setlocal inc< inex<')

" Enable completion of Lua keywords, globals and library members. {{{1
setlocal completefunc=xolox#lua#completefunc
call add(s:undo_ftplugin, 'setlocal completefunc<')
if xolox#misc#option#get('lua_define_completefunc', 1)
setlocal completefunc=xolox#lua#completefunc
call add(s:undo_ftplugin, 'setlocal completefunc<')
endif

" Enable dynamic completion by searching "package.path" and "package.cpath". {{{1
setlocal omnifunc=xolox#lua#omnifunc
call add(s:undo_ftplugin, 'setlocal omnifunc<')
if xolox#misc#option#get('lua_define_omnifunc', 1)
setlocal omnifunc=xolox#lua#omnifunc
call add(s:undo_ftplugin, 'setlocal omnifunc<')
endif

" Set a filename filter for the Windows file open/save dialogs. {{{1
if has('gui_win32') && !exists('b:browsefilter')
Expand Down

0 comments on commit 17e9003

Please sign in to comment.