3
3
" Last Change: August 27, 2011
4
4
" URL: http://peterodding.com/code/vim/lua-ftplugin
5
5
6
+ let g: xolox #lua #version = ' 0.6.20'
6
7
let s: miscdir = expand (' <sfile>:p:h:h:h' ) . ' /misc/lua-ftplugin'
7
8
let s: omnicomplete_script = s: miscdir . ' /omnicomplete.lua'
8
9
let s: globals_script = s: miscdir . ' /globals.lua'
@@ -22,9 +23,9 @@ function! xolox#lua#includeexpr(fname) " {{{1
22
23
let module = substitute (a: fname , ' \.' , ' /' , ' g' )
23
24
for template in xolox#lua#getsearchpath (' $LUA_PATH' , ' package.path' )
24
25
let expanded = substitute (template, ' ?' , module, ' g' )
25
- call xolox#misc#msg#debug (" lua.vim %s: Expanded %s -> %s" , g: lua_ftplugin_version , template, expanded)
26
+ call xolox#misc#msg#debug (" lua.vim %s: Expanded %s -> %s" , g: xolox # lua # version , template, expanded)
26
27
if filereadable (expanded)
27
- call xolox#misc#msg#debug (" lua.vim %s: Matched existing file %s" , g: lua_ftplugin_version , expanded)
28
+ call xolox#misc#msg#debug (" lua.vim %s: Matched existing file %s" , g: xolox # lua # version , expanded)
28
29
return expanded
29
30
endif
30
31
endfor
@@ -40,21 +41,21 @@ function! xolox#lua#getsearchpath(envvar, luavar) " {{{1
40
41
redir = > path
41
42
execute ' silent lua print(' . a: luavar . ' )'
42
43
redir END
43
- call xolox#misc#msg#debug (" lua.vim %s: Got %s from Lua Interface for Vim" , g: lua_ftplugin_version , a: luavar )
44
+ call xolox#misc#msg#debug (" lua.vim %s: Got %s from Lua Interface for Vim" , g: xolox # lua # version , a: luavar )
44
45
catch
45
46
redir END
46
47
endtry
47
48
endif
48
49
if empty (path )
49
50
let path = eval (a: envvar )
50
51
if ! empty (path )
51
- call xolox#misc#msg#debug (" lua.vim %s: Got %s from %s" , g: lua_ftplugin_version , a: luavar , a: envvar )
52
+ call xolox#misc#msg#debug (" lua.vim %s: Got %s from %s" , g: xolox # lua # version , a: luavar , a: envvar )
52
53
else
53
54
let path = system (' lua -e "io.write(' . a: luavar . ' )"' )
54
55
if v: shell_error
55
- call xolox#misc#msg#warn (" lua.vim %s: Failed to get %s from external Lua interpreter: %s" , g: lua_ftplugin_version , a: luavar , path )
56
+ call xolox#misc#msg#warn (" lua.vim %s: Failed to get %s from external Lua interpreter: %s" , g: xolox # lua # version , a: luavar , path )
56
57
else
57
- call xolox#misc#msg#debug (" lua.vim %s: Got %s from external Lua interpreter" , g: lua_ftplugin_version , a: luavar )
58
+ call xolox#misc#msg#debug (" lua.vim %s: Got %s from external Lua interpreter" , g: xolox # lua # version , a: luavar )
58
59
endif
59
60
endif
60
61
endif
@@ -81,7 +82,7 @@ function! xolox#lua#checksyntax() " {{{1
81
82
let message .= " doesn't seem to be available! I'm disabling"
82
83
let message .= " automatic syntax checking for Lua scripts."
83
84
let g: lua_check_syntax = 0
84
- call xolox#misc#msg#warn (message, g: lua_ftplugin_version )
85
+ call xolox#misc#msg#warn (message, g: xolox # lua # version )
85
86
else
86
87
let mp_save = &makeprg
87
88
let efm_save = &errorformat
@@ -115,7 +116,7 @@ function! s:highlighterrors()
115
116
let pattern = ' ^\%%%il.*\n\?'
116
117
for entry in getqflist ()
117
118
call matchadd (hlgroup, ' \%' . min ([entry.lnum, line (' $' )]) . ' l' )
118
- call xolox#misc#msg#warn (" lua.vim %s: Syntax error on line %i: %s" , g: lua_ftplugin_version , entry.lnum, entry.text)
119
+ call xolox#misc#msg#warn (" lua.vim %s: Syntax error on line %i: %s" , g: xolox # lua # version , entry.lnum, entry.text)
119
120
endfor
120
121
endfunction
121
122
@@ -156,7 +157,7 @@ function! s:lookupmethod(cword, prefix, pattern)
156
157
let method = matchstr (a: cword , a: pattern )
157
158
if method != ' '
158
159
let identifier = a: prefix . method
159
- call xolox#misc#msg#debug (" lua.vim %s: Translating '%s' -> '%s'" , g: lua_ftplugin_version , a: cword , identifier )
160
+ call xolox#misc#msg#debug (" lua.vim %s: Translating '%s' -> '%s'" , g: xolox # lua # version , a: cword , identifier )
160
161
call s: lookuptopic (identifier )
161
162
endif
162
163
endfunction
@@ -335,7 +336,7 @@ function! xolox#lua#omnifunc(init, base) " {{{1
335
336
if a: init
336
337
return s: getcompletionprefix ()
337
338
elseif ! xolox#misc#option#get (' lua_complete_omni' , 0 )
338
- throw printf (" lua.vim %s: omni completion needs to be explicitly enabled, see the readme!" , g: lua_ftplugin_version )
339
+ throw printf (" lua.vim %s: omni completion needs to be explicitly enabled, see the readme!" , g: xolox # lua # version )
339
340
endif
340
341
if ! exists (' s:omnifunc_modules' )
341
342
let s: omnifunc_modules = xolox#lua#getomnimodules ()
@@ -367,7 +368,7 @@ function! xolox#lua#getomnimodules() " {{{1
367
368
let modules = keys (modulemap)
368
369
call sort (modules)
369
370
let msg = " lua.vim %s: Collected %i module names for omni completion in %s"
370
- call xolox#misc#timer#stop (msg, g: lua_ftplugin_version , len (modules), starttime)
371
+ call xolox#misc#timer#stop (msg, g: xolox # lua # version , len (modules), starttime)
371
372
return modules
372
373
endfunction
373
374
@@ -377,32 +378,32 @@ function! s:expandsearchpath(searchpath, modules)
377
378
let components = split (template, ' ?' )
378
379
if len (components) != 2
379
380
let msg = " lua.vim %s: Failed to parse search path entry: %s"
380
- call xolox#misc#msg#debug (msg, g: lua_ftplugin_version , template)
381
+ call xolox#misc#msg#debug (msg, g: xolox # lua # version , template)
381
382
continue
382
383
endif
383
384
let [prefix, suffix] = components
384
385
" XXX Never recursively search current working directory because
385
386
" it might be arbitrarily deep, e.g. when working directory is /
386
387
if prefix = ~ ' ^.[\\/]$'
387
388
let msg = " lua.vim %s: Refusing to expand dangerous search path entry: %s"
388
- call xolox#misc#msg#debug (msg, g: lua_ftplugin_version , template)
389
+ call xolox#misc#msg#debug (msg, g: xolox # lua # version , template)
389
390
continue
390
391
endif
391
392
let pattern = substitute (template, ' ?' , ' **/*' , ' g' )
392
- call xolox#misc#msg#debug (" lua.vim %s: Transformed %s -> %s" , g: lua_ftplugin_version , template, pattern)
393
+ call xolox#misc#msg#debug (" lua.vim %s: Transformed %s -> %s" , g: xolox # lua # version , template, pattern)
393
394
let msg = " lua.vim %s: Failed to convert pathname to module name, %s doesn't match! (%s: '%s', pathname: '%s')"
394
395
for pathname in split (glob (pattern), " \n " )
395
396
if pathname[0 : len (prefix)-1 ] != prefix
396
397
" Validate prefix of resulting pathname.
397
- call xolox#misc#msg#warn (msg, g: lua_ftplugin_version , ' prefix' , ' prefix' , prefix, pathname)
398
+ call xolox#misc#msg#warn (msg, g: xolox # lua # version , ' prefix' , ' prefix' , prefix, pathname)
398
399
elseif pathname[- len (suffix) : -1 ] != suffix
399
400
" Validate suffix of resulting pathname.
400
- call xolox#misc#msg#warn (msg, g: lua_ftplugin_version , ' suffix' , ' suffix' , suffix, pathname)
401
+ call xolox#misc#msg#warn (msg, g: xolox # lua # version , ' suffix' , ' suffix' , suffix, pathname)
401
402
elseif pathname !~ ' test'
402
403
let relative = pathname[len (prefix) : - len (suffix)-1 ]
403
404
let modulename = substitute (relative, ' [\\/]\+' , ' .' , ' g' )
404
405
let a: modules [modulename] = 1
405
- call xolox#misc#msg#debug (" lua.vim %s: Transformed '%s' -> '%s'" , g: lua_ftplugin_version , pathname, modulename)
406
+ call xolox#misc#msg#debug (" lua.vim %s: Transformed '%s' -> '%s'" , g: xolox # lua # version , pathname, modulename)
406
407
endif
407
408
endfor
408
409
endfor
@@ -414,7 +415,7 @@ function! xolox#lua#getomnivariables(modules) " {{{1
414
415
let variables = eval (' [' . substitute (output, ' \_s\+' , ' ,' , ' g' ) . ' ]' )
415
416
call sort (variables, 1 )
416
417
let msg = " lua.vim %s: Collected %i variables for omni completion in %s"
417
- call xolox#misc#timer#stop (msg, g: lua_ftplugin_version , len (variables), starttime)
418
+ call xolox#misc#timer#stop (msg, g: xolox # lua # version , len (variables), starttime)
418
419
return variables
419
420
endfunction
420
421
@@ -464,7 +465,7 @@ function! xolox#lua#dofile(pathname, arguments) " {{{1
464
465
let output = xolox#misc#str#trim (system (join ([' lua' , a: pathname ] + a: arguments )))
465
466
if v: shell_error
466
467
let msg = " lua.vim %s: Failed to retrieve omni completion candidates (output: '%s')"
467
- call xolox#misc#msg#warn (msg, g: lua_ftplugin_version , output)
468
+ call xolox#misc#msg#warn (msg, g: xolox # lua # version , output)
468
469
endif
469
470
endif
470
471
return xolox#misc#str#trim (output)
0 commit comments