|
3 | 3 | " Last Change: June 16, 2014 |
4 | 4 | " URL: http://peterodding.com/code/vim/lua-ftplugin |
5 | 5 |
|
6 | | -let g:xolox#lua#version = '0.7.13' |
| 6 | +let g:xolox#lua#version = '0.7.17' |
7 | 7 | let s:miscdir = expand('<sfile>:p:h:h:h') . '/misc/lua-ftplugin' |
8 | 8 | let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua' |
9 | 9 | let s:globals_script = s:miscdir . '/globals.lua' |
@@ -132,7 +132,9 @@ function! s:highlighterrors() |
132 | 132 | endfunction |
133 | 133 |
|
134 | 134 | function! xolox#lua#checkglobals(verbose) " {{{1 |
135 | | - let output = xolox#lua#dofile(s:globals_script, [expand('%'), a:verbose]) |
| 135 | + let curfile = expand('%') |
| 136 | + call xolox#misc#msg#debug("lua.vim %s: Checking for undefined globals in '%s' using '%s' ..", g:xolox#lua#version, curfile, s:globals_script) |
| 137 | + let output = xolox#lua#dofile(s:globals_script, [curfile, a:verbose]) |
136 | 138 | call setqflist(eval('[' . join(output, ',') . ']'), 'r') |
137 | 139 | cwindow |
138 | 140 | endfunction |
@@ -472,13 +474,31 @@ endfunction |
472 | 474 | function! xolox#lua#dofile(pathname, arguments) " {{{1 |
473 | 475 | if has('lua') |
474 | 476 | " Use the Lua Interface for Vim. |
| 477 | + call xolox#misc#msg#debug("lua.vim %s: Running '%s' using Lua Interface for Vim ..", g:xolox#lua#version, a:pathname) |
475 | 478 | redir => output |
476 | | - lua arg = vim.eval('a:arguments') |
477 | | - execute 'silent luafile' fnameescape(a:pathname) |
| 479 | + " https://github.com/xolox/vim-lua-ftplugin/pull/23 reports that somewhere |
| 480 | + " in the communication between Vim and Lua someone switches from one based |
| 481 | + " indexes to zero based indexes, breaking the Vim plug-in. I haven't been |
| 482 | + " able to reproduce this but the following code is intended to compensate |
| 483 | + " should the problem occur. As a bonus it's compatible with how the Lua |
| 484 | + " interpreter runs Lua scripts :-) |
| 485 | + silent lua << EOL |
| 486 | + local script = vim.eval('a:pathname') |
| 487 | + arg = vim.eval('a:arguments') |
| 488 | + if arg[0] == nil then |
| 489 | + -- Keep the list order, just set arg[0] to the pathname of the script. |
| 490 | + arg[0] = script |
| 491 | + else |
| 492 | + -- Insert the pathname of the script in arg[0], shifting up arguments. |
| 493 | + table.insert(arg, 0, script) |
| 494 | + end |
| 495 | + dofile(script) |
| 496 | +EOL |
478 | 497 | redir END |
479 | 498 | return split(output, "\n") |
480 | 499 | else |
481 | 500 | " Use the command line Lua interpreter. |
| 501 | + call xolox#misc#msg#debug("lua.vim %s: Running '%s' using command line Lua interpreter ..", g:xolox#lua#version, a:pathname) |
482 | 502 | let interpreter = xolox#misc#escape#shell(xolox#misc#option#get('lua_interpreter_path', 'lua')) |
483 | 503 | let pathname = xolox#misc#escape#shell(a:pathname) |
484 | 504 | let arguments = join(map(a:arguments, 'xolox#misc#escape#shell(v:val)')) |
|
0 commit comments