Skip to content

Commit 0544e6f

Browse files
committed
Option lua_define_completion_mappings (issue #13)
Issue #13 on GitHub: #13
1 parent 6e0c4b7 commit 0544e6f

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ If you want to use the omni completion despite the warnings above, execute the f
9797

9898
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 :-)
9999

100+
101+
### The `lua_define_completion_mappings` option
102+
103+
By default the Lua file type plug-in defines insert mode mappings so that the plug-in is called whenever you type a single quote, double quote or a dot inside a Lua buffer. This enables context sensitive completion. If you don't like these mappings you can set this option to zero (false). In that case the mappings will not be defined.
104+
100105
## Contact
101106

102107
If you have questions, bug reports, suggestions, etc. the author can be contacted at <peter@peterodding.com>. The latest version is available at <http://peterodding.com/code/vim/lua-ftplugin> and <http://github.com/xolox/vim-lua-ftplugin>. If you like this plug-in please vote for it on [Vim Online][script].

autoload/xolox/lua.vim

Lines changed: 2 additions & 2 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: May 13, 2013
3+
" Last Change: May 15, 2013
44
" URL: http://peterodding.com/code/vim/lua-ftplugin
55

6-
let g:xolox#lua#version = '0.7.5'
6+
let g:xolox#lua#version = '0.7.6'
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'

doc/ft_lua.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Contents ~
1818
9. The |lua_complete_library| option
1919
10. The |lua_complete_dynamic| option
2020
11. The |lua_complete_omni| option
21+
12. The |lua_define_completion_mappings| option
2122
4. Contact |ft_lua-contact|
2223
5. License |ft_lua-license|
2324

@@ -190,6 +191,15 @@ following command:
190191
Now when you type Control-X Control-O Vim will hang for a moment, after which
191192
you should be presented with an enormous list of completion candidates :-)
192193

194+
-------------------------------------------------------------------------------
195+
The *lua_define_completion_mappings* option
196+
197+
By default the Lua file type plug-in defines insert mode mappings so that the
198+
plug-in is called whenever you type a single quote, double quote or a dot
199+
inside a Lua buffer. This enables context sensitive completion. If you don't
200+
like these mappings you can set this option to zero (false). In that case the
201+
mappings will not be defined.
202+
193203
===============================================================================
194204
*ft_lua-contact*
195205
Contact ~

ftplugin/lua.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim file type plug-in
22
" Language: Lua 5.1
33
" Author: Peter Odding <peter@peterodding.com>
4-
" Last Change: June 18, 2011
4+
" Last Change: May 15, 2013
55
" URL: http://peterodding.com/code/vim/lua-ftplugin
66

77
if exists('b:did_ftplugin')
@@ -73,12 +73,14 @@ if exists('loaded_matchit')
7373
endif
7474

7575
" Enable dynamic completion on typing "require('" or "variable."? {{{1
76-
inoremap <buffer> <silent> <expr> . xolox#lua#completedynamic('.')
77-
call add(s:undo_ftplugin, 'iunmap <buffer> .')
78-
inoremap <buffer> <silent> <expr> ' xolox#lua#completedynamic("'")
79-
call add(s:undo_ftplugin, "iunmap <buffer> '")
80-
inoremap <buffer> <silent> <expr> " xolox#lua#completedynamic('"')
81-
call add(s:undo_ftplugin, 'iunmap <buffer> "')
76+
if xolox#misc#option#get('lua_define_completion_mappings', 1)
77+
inoremap <buffer> <silent> <expr> . xolox#lua#completedynamic('.')
78+
call add(s:undo_ftplugin, 'iunmap <buffer> .')
79+
inoremap <buffer> <silent> <expr> ' xolox#lua#completedynamic("'")
80+
call add(s:undo_ftplugin, "iunmap <buffer> '")
81+
inoremap <buffer> <silent> <expr> " xolox#lua#completedynamic('"')
82+
call add(s:undo_ftplugin, 'iunmap <buffer> "')
83+
endif
8284

8385
" Enable tool tips with function signatures? {{{1
8486
if has('balloon_eval')

0 commit comments

Comments
 (0)