Skip to content

Commit

Permalink
Use configured Lua compiler in globals.lua (reported in pull request #23
Browse files Browse the repository at this point in the history
)
  • Loading branch information
xolox committed Jun 16, 2014
1 parent 9160dee commit 96082b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions autoload/xolox/lua.vim
Expand Up @@ -3,7 +3,7 @@
" Last Change: June 16, 2014 " Last Change: June 16, 2014
" URL: http://peterodding.com/code/vim/lua-ftplugin " 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('<sfile>:p:h:h:h') . '/misc/lua-ftplugin' let s:miscdir = expand('<sfile>:p:h:h:h') . '/misc/lua-ftplugin'
let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua' let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua'
let s:globals_script = s:miscdir . '/globals.lua' let s:globals_script = s:miscdir . '/globals.lua'
Expand Down Expand Up @@ -134,7 +134,8 @@ endfunction
function! xolox#lua#checkglobals(verbose) " {{{1 function! xolox#lua#checkglobals(verbose) " {{{1
let curfile = expand('%') 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) 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') call setqflist(eval('[' . join(output, ',') . ']'), 'r')
cwindow cwindow
endfunction endfunction
Expand Down
12 changes: 10 additions & 2 deletions misc/lua-ftplugin/globals.lua
@@ -1,8 +1,16 @@
#!/usr/bin/env lua #!/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. -- Parse output of "luac -l" for GETGLOBAL/SETGLOBAL instructions.
local command = string.format('luac -p -l "%s"', arg[1]) local command = string.format('%s -p -l %s', quote(compiler), quote(filename))
local verbose = tonumber(arg[2]) ~= 0
local compiler = io.popen(command) local compiler = io.popen(command)
local matches = {} local matches = {}
for line in compiler:lines() do for line in compiler:lines() do
Expand Down

0 comments on commit 96082b7

Please sign in to comment.