Skip to content

Commit

Permalink
Support Lua modules that don't create a global (omni completion)
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Oct 16, 2011
1 parent 3855093 commit 3c49c27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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: September 26, 2011
" Last Change: October 16, 2011
" URL: http://peterodding.com/code/vim/lua-ftplugin

let g:xolox#lua#version = '0.6.23'
let g:xolox#lua#version = '0.6.24'
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
7 changes: 5 additions & 2 deletions misc/lua-ftplugin/omnicomplete.lua
Expand Up @@ -3,7 +3,7 @@
--[[
Author: Peter Odding <peter@peterodding.com>
Last Change: July 29, 2011
Last Change: October 16, 2011
URL: http://peterodding.com/code/vim/lua-ftplugin
This Lua script is executed by the Lua file type plug-in for Vim to provide
Expand Down Expand Up @@ -75,7 +75,10 @@ end
-- Load installed modules.
-- XXX What if module loading has side effects? It shouldn't, but still...
for _, modulename in ipairs(arg) do
pcall(require, modulename)
local status, module = pcall(require, modulename)
if status and module and not _G[modulename] then
_G[modulename] = module
end
end

-- Generate completion candidates from global state.
Expand Down

0 comments on commit 3c49c27

Please sign in to comment.