Skip to content

Commit b01ff5e

Browse files
committed
Move version variable to autoload script
1 parent dc8a937 commit b01ff5e

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

autoload/xolox/lua.vim

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
" Last Change: August 27, 2011
44
" URL: http://peterodding.com/code/vim/lua-ftplugin
55

6+
let g:xolox#lua#version = '0.6.20'
67
let s:miscdir = expand('<sfile>:p:h:h:h') . '/misc/lua-ftplugin'
78
let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua'
89
let s:globals_script = s:miscdir . '/globals.lua'
@@ -22,9 +23,9 @@ function! xolox#lua#includeexpr(fname) " {{{1
2223
let module = substitute(a:fname, '\.', '/', 'g')
2324
for template in xolox#lua#getsearchpath('$LUA_PATH', 'package.path')
2425
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)
2627
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)
2829
return expanded
2930
endif
3031
endfor
@@ -40,21 +41,21 @@ function! xolox#lua#getsearchpath(envvar, luavar) " {{{1
4041
redir => path
4142
execute 'silent lua print(' . a:luavar . ')'
4243
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)
4445
catch
4546
redir END
4647
endtry
4748
endif
4849
if empty(path)
4950
let path = eval(a:envvar)
5051
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)
5253
else
5354
let path = system('lua -e "io.write(' . a:luavar . ')"')
5455
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)
5657
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)
5859
endif
5960
endif
6061
endif
@@ -81,7 +82,7 @@ function! xolox#lua#checksyntax() " {{{1
8182
let message .= " doesn't seem to be available! I'm disabling"
8283
let message .= " automatic syntax checking for Lua scripts."
8384
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)
8586
else
8687
let mp_save = &makeprg
8788
let efm_save = &errorformat
@@ -115,7 +116,7 @@ function! s:highlighterrors()
115116
let pattern = '^\%%%il.*\n\?'
116117
for entry in getqflist()
117118
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)
119120
endfor
120121
endfunction
121122

@@ -156,7 +157,7 @@ function! s:lookupmethod(cword, prefix, pattern)
156157
let method = matchstr(a:cword, a:pattern)
157158
if method != ''
158159
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)
160161
call s:lookuptopic(identifier)
161162
endif
162163
endfunction
@@ -335,7 +336,7 @@ function! xolox#lua#omnifunc(init, base) " {{{1
335336
if a:init
336337
return s:getcompletionprefix()
337338
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)
339340
endif
340341
if !exists('s:omnifunc_modules')
341342
let s:omnifunc_modules = xolox#lua#getomnimodules()
@@ -367,7 +368,7 @@ function! xolox#lua#getomnimodules() " {{{1
367368
let modules = keys(modulemap)
368369
call sort(modules)
369370
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)
371372
return modules
372373
endfunction
373374

@@ -377,32 +378,32 @@ function! s:expandsearchpath(searchpath, modules)
377378
let components = split(template, '?')
378379
if len(components) != 2
379380
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)
381382
continue
382383
endif
383384
let [prefix, suffix] = components
384385
" XXX Never recursively search current working directory because
385386
" it might be arbitrarily deep, e.g. when working directory is /
386387
if prefix =~ '^.[\\/]$'
387388
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)
389390
continue
390391
endif
391392
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)
393394
let msg = "lua.vim %s: Failed to convert pathname to module name, %s doesn't match! (%s: '%s', pathname: '%s')"
394395
for pathname in split(glob(pattern), "\n")
395396
if pathname[0 : len(prefix)-1] != prefix
396397
" 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)
398399
elseif pathname[-len(suffix) : -1] != suffix
399400
" 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)
401402
elseif pathname !~ 'test'
402403
let relative = pathname[len(prefix) : -len(suffix)-1]
403404
let modulename = substitute(relative, '[\\/]\+', '.', 'g')
404405
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)
406407
endif
407408
endfor
408409
endfor
@@ -414,7 +415,7 @@ function! xolox#lua#getomnivariables(modules) " {{{1
414415
let variables = eval('[' . substitute(output, '\_s\+', ',', 'g') . ']')
415416
call sort(variables, 1)
416417
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)
418419
return variables
419420
endfunction
420421

@@ -464,7 +465,7 @@ function! xolox#lua#dofile(pathname, arguments) " {{{1
464465
let output = xolox#misc#str#trim(system(join(['lua', a:pathname] + a:arguments)))
465466
if v:shell_error
466467
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)
468469
endif
469470
endif
470471
return xolox#misc#str#trim(output)

plugin/lua-ftplugin.vim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ if &cp || exists('g:loaded_lua_ftplugin')
1212
finish
1313
endif
1414

15-
let g:lua_ftplugin_version = '0.6.19'
16-
1715
" Commands to manually check for syntax errors and undefined globals.
1816
command! -bar LuaCheckSyntax call xolox#lua#checksyntax()
1917
command! -bar -bang LuaCheckGlobals call xolox#lua#checkglobals(<q-bang> == '!')

0 commit comments

Comments
 (0)