From 96082b731ddb620c9b180316d8a708fefe06b7b9 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Mon, 16 Jun 2014 23:25:27 +0200 Subject: [PATCH] Use configured Lua compiler in globals.lua (reported in pull request #23) --- autoload/xolox/lua.vim | 5 +++-- misc/lua-ftplugin/globals.lua | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/autoload/xolox/lua.vim b/autoload/xolox/lua.vim index cef95e2..7634ffb 100644 --- a/autoload/xolox/lua.vim +++ b/autoload/xolox/lua.vim @@ -3,7 +3,7 @@ " Last Change: June 16, 2014 " URL: http://peterodding.com/code/vim/lua-ftplugin -let g:xolox#lua#version = '0.7.17' +let g:xolox#lua#version = '0.7.18' let s:miscdir = expand(':p:h:h:h') . '/misc/lua-ftplugin' let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua' let s:globals_script = s:miscdir . '/globals.lua' @@ -134,7 +134,8 @@ endfunction function! xolox#lua#checkglobals(verbose) " {{{1 let curfile = expand('%') call xolox#misc#msg#debug("lua.vim %s: Checking for undefined globals in '%s' using '%s' ..", g:xolox#lua#version, curfile, s:globals_script) - let output = xolox#lua#dofile(s:globals_script, [curfile, a:verbose]) + let compiler = xolox#misc#option#get('lua_compiler_name', 'luac') + let output = xolox#lua#dofile(s:globals_script, [compiler, curfile, a:verbose]) call setqflist(eval('[' . join(output, ',') . ']'), 'r') cwindow endfunction diff --git a/misc/lua-ftplugin/globals.lua b/misc/lua-ftplugin/globals.lua index bf2fe82..854b8a5 100755 --- a/misc/lua-ftplugin/globals.lua +++ b/misc/lua-ftplugin/globals.lua @@ -1,8 +1,16 @@ #!/usr/bin/env lua +-- Unpack arguments from Vim. +local compiler = arg[1] +local filename = arg[2] +local verbose = tonumber(arg[3]) ~= 0 + +local function quote(s) + return string.format('"%s"', (s:gsub('["\\]', '\\%0'))) +end + -- Parse output of "luac -l" for GETGLOBAL/SETGLOBAL instructions. -local command = string.format('luac -p -l "%s"', arg[1]) -local verbose = tonumber(arg[2]) ~= 0 +local command = string.format('%s -p -l %s', quote(compiler), quote(filename)) local compiler = io.popen(command) local matches = {} for line in compiler:lines() do