Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Define version as variable, include version in messages

  • Loading branch information...
commit 5e40f1cb387c11de47d37323ebe64f732c54f303 1 parent e15b7be
Peter Odding authored June 18, 2011
54  autoload/xolox/lua.vim
@@ -3,7 +3,7 @@
3 3
 " Last Change: June 18, 2011
4 4
 " URL: http://peterodding.com/code/vim/lua-ftplugin
5 5
 
6  
-let s:script = 'lua.vim'
  6
+let s:version = '0.6.11'
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'
@@ -23,9 +23,9 @@ function! xolox#lua#includeexpr(fname) " {{{1
23 23
   let module = substitute(a:fname, '\.', '/', 'g')
24 24
   for template in xolox#lua#getsearchpath('$LUA_PATH', 'package.path')
25 25
     let expanded = substitute(template, '?', module, 'g')
26  
-    call xolox#misc#msg#debug("%s: Expanded %s -> %s", s:script, template, expanded)
  26
+    call xolox#misc#msg#debug("lua.vim %s: Expanded %s -> %s", s:version, template, expanded)
27 27
     if filereadable(expanded)
28  
-      call xolox#misc#msg#debug("%s: Matched existing file %s", s:script, expanded)
  28
+      call xolox#misc#msg#debug("lua.vim %s: Matched existing file %s", s:version, expanded)
29 29
       return expanded
30 30
     endif
31 31
   endfor
@@ -41,7 +41,7 @@ function! xolox#lua#getsearchpath(envvar, luavar) " {{{1
41 41
       redir => path
42 42
       execute 'silent lua print(' . a:luavar . ')'
43 43
       redir END
44  
-      call xolox#misc#msg#debug("%s: Got %s from Lua Interface for Vim", s:script, a:luavar)
  44
+      call xolox#misc#msg#debug("lua.vim %s: Got %s from Lua Interface for Vim", s:version, a:luavar)
45 45
     catch
46 46
       redir END
47 47
     endtry
@@ -49,13 +49,13 @@ function! xolox#lua#getsearchpath(envvar, luavar) " {{{1
49 49
   if empty(path)
50 50
     let path = eval(a:envvar)
51 51
     if !empty(path)
52  
-      call xolox#misc#msg#debug("%s: Got %s from %s", s:script, a:luavar, a:envvar)
  52
+      call xolox#misc#msg#debug("lua.vim %s: Got %s from %s", s:version, a:luavar, a:envvar)
53 53
     else
54 54
       let path = system('lua -e "io.write(' . a:luavar . ')"')
55 55
       if v:shell_error
56  
-        call xolox#misc#msg#warn("%s: Failed to get %s from external Lua interpreter: %s", s:script, a:luavar, path)
  56
+        call xolox#misc#msg#warn("lua.vim %s: Failed to get %s from external Lua interpreter: %s", s:version, a:luavar, path)
57 57
       else
58  
-        call xolox#misc#msg#debug("%s: Got %s from external Lua interpreter", s:script, a:luavar)
  58
+        call xolox#misc#msg#debug("lua.vim %s: Got %s from external Lua interpreter", s:version, a:luavar)
59 59
       endif
60 60
     endif
61 61
   endif
@@ -75,11 +75,11 @@ function! xolox#lua#checksyntax() " {{{1
75 75
   let compiler_name = xolox#lua#getopt('lua_compiler_name', 'luac')
76 76
   let error_format = xolox#lua#getopt('lua_error_format', 'luac: %f:%l: %m')
77 77
   if !executable(compiler_name)
78  
-    let message = "%s: The configured Lua compiler"
  78
+    let message = "lua.vim %s: The configured Lua compiler"
79 79
     let message .= " doesn't seem to be available! I'm disabling"
80 80
     let message .= " automatic syntax checking for Lua scripts."
81 81
     let g:lua_check_syntax = 0
82  
-    call xolox#misc#msg#warn(message, s:script)
  82
+    call xolox#misc#msg#warn(message, s:version)
83 83
   else
84 84
     let mp_save = &makeprg
85 85
     let efm_save = &errorformat
@@ -108,7 +108,7 @@ function! s:highlighterrors()
108 108
   let pattern = '^\%%%il.*\n\?'
109 109
   for entry in getqflist()
110 110
     call matchadd(hlgroup, '\%' . min([entry.lnum, line('$')]) . 'l')
111  
-    call xolox#misc#msg#warn("%s: Syntax error on line %i: %s", s:script, entry.lnum, entry.text)
  111
+    call xolox#misc#msg#warn("lua.vim %s: Syntax error on line %i: %s", s:version, entry.lnum, entry.text)
112 112
   endfor
113 113
 endfunction
114 114
 
@@ -149,7 +149,7 @@ function! s:lookupmethod(cword, prefix, pattern)
149 149
   let method = matchstr(a:cword, a:pattern)
150 150
   if method != ''
151 151
     let identifier = a:prefix . method
152  
-    call xolox#misc#msg#debug("%s: Translating '%s' -> '%s'", s:script, a:cword, identifier)
  152
+    call xolox#misc#msg#debug("lua.vim %s: Translating '%s' -> '%s'", s:version, a:cword, identifier)
153 153
     call s:lookuptopic(identifier)
154 154
   endif
155 155
 endfunction
@@ -328,7 +328,7 @@ function! xolox#lua#omnifunc(init, base) " {{{1
328 328
   if a:init
329 329
     return s:get_completion_prefix()
330 330
   elseif !xolox#lua#getopt('lua_complete_omni', 0)
331  
-    throw printf("%s: omni completion needs to be explicitly enabled, see the readme!", s:script)
  331
+    throw printf("lua.vim %s: omni completion needs to be explicitly enabled, see the readme!", s:version)
332 332
   endif
333 333
   if !exists('s:omnifunc_modules')
334 334
     let s:omnifunc_modules = xolox#lua#getomnimodules()
@@ -360,8 +360,8 @@ function! xolox#lua#getomnimodules() " {{{1
360 360
   endfor
361 361
   let modules = keys(modulemap)
362 362
   call sort(modules)
363  
-  let msg = "%s: Collected %i module names for omni completion in %s"
364  
-  call xolox#misc#timer#stop(msg, s:script, len(modules), starttime)
  363
+  let msg = "lua.vim %s: Collected %i module names for omni completion in %s"
  364
+  call xolox#misc#timer#stop(msg, s:version, len(modules), starttime)
365 365
   return modules
366 366
 endfunction
367 367
 
@@ -370,33 +370,33 @@ function! s:expandsearchpath(searchpath, modules)
370 370
   for template in a:searchpath
371 371
     let components = split(template, '?')
372 372
     if len(components) != 2
373  
-      let msg = "%s: Failed to parse search path entry: %s"
374  
-      call xolox#misc#msg#debug(msg, s:script, template)
  373
+      let msg = "lua.vim %s: Failed to parse search path entry: %s"
  374
+      call xolox#misc#msg#debug(msg, s:version, template)
375 375
       continue
376 376
     endif
377 377
     let [prefix, suffix] = components
378 378
     " XXX Never recursively search current working directory because
379 379
     " it might be arbitrarily deep, e.g. when working directory is /
380 380
     if prefix =~ '^.[\\/]$'
381  
-      let msg = "%s: Refusing to expand dangerous search path entry: %s"
382  
-      call xolox#misc#msg#debug(msg, s:script, template)
  381
+      let msg = "lua.vim %s: Refusing to expand dangerous search path entry: %s"
  382
+      call xolox#misc#msg#debug(msg, s:version, template)
383 383
       continue
384 384
     endif
385 385
     let pattern = substitute(template, '?', '**/*', 'g')
386  
-    call xolox#misc#msg#debug("%s: Transformed %s -> %s", s:script, template, pattern)
387  
-    let msg = "%s: Failed to convert pathname to module name, %s doesn't match! (%s: '%s', pathname: '%s')"
  386
+    call xolox#misc#msg#debug("lua.vim %s: Transformed %s -> %s", s:version, template, pattern)
  387
+    let msg = "lua.vim %s: Failed to convert pathname to module name, %s doesn't match! (%s: '%s', pathname: '%s')"
388 388
     for pathname in split(glob(pattern), "\n")
389 389
       if pathname[0 : len(prefix)-1] != prefix
390 390
         " Validate prefix of resulting pathname.
391  
-        call xolox#misc#msg#warn(msg, s:script, 'prefix', 'prefix', prefix, pathname)
  391
+        call xolox#misc#msg#warn(msg, s:version, 'prefix', 'prefix', prefix, pathname)
392 392
       elseif pathname[-len(suffix) : -1] != suffix
393 393
         " Validate suffix of resulting pathname.
394  
-        call xolox#misc#msg#warn(msg, s:script, 'suffix', 'suffix', suffix, pathname)
  394
+        call xolox#misc#msg#warn(msg, s:version, 'suffix', 'suffix', suffix, pathname)
395 395
       elseif pathname !~ 'test'
396 396
         let relative = pathname[len(prefix) : -len(suffix)-1]
397 397
         let modulename = substitute(relative, '[\\/]\+', '.', 'g')
398 398
         let a:modules[modulename] = 1
399  
-        call xolox#misc#msg#debug("%s: Transformed '%s' -> '%s'", s:script, pathname, modulename)
  399
+        call xolox#misc#msg#debug("lua.vim %s: Transformed '%s' -> '%s'", s:version, pathname, modulename)
400 400
       endif
401 401
     endfor
402 402
   endfor
@@ -407,8 +407,8 @@ function! xolox#lua#getomnivariables(modules) " {{{1
407 407
   let output = xolox#lua#dofile(s:omnicomplete_script, a:modules)
408 408
   let variables = eval('[' . substitute(output, '\_s\+', ',', 'g') . ']')
409 409
   call sort(variables, 1)
410  
-  let msg = "%s: Collected %i variables for omni completion in %s"
411  
-  call xolox#misc#timer#stop(msg, s:script, len(variables), starttime)
  410
+  let msg = "lua.vim %s: Collected %i variables for omni completion in %s"
  411
+  call xolox#misc#timer#stop(msg, s:version, len(variables), starttime)
412 412
   return variables
413 413
 endfunction
414 414
 
@@ -448,8 +448,8 @@ function! xolox#lua#dofile(pathname, arguments) " {{{1
448 448
     " Use the command line Lua interpreter.
449 449
     let output = xolox#misc#str#trim(system(join(['lua', a:pathname] + a:arguments)))
450 450
     if v:shell_error
451  
-      let msg = "%s: Failed to retrieve omni completion candidates (output: '%s')"
452  
-      call xolox#misc#msg#warn(msg, s:script, output)
  451
+      let msg = "lua.vim %s: Failed to retrieve omni completion candidates (output: '%s')"
  452
+      call xolox#misc#msg#warn(msg, s:version, output)
453 453
     endif
454 454
   endif
455 455
   return xolox#misc#str#trim(output)
1  ftplugin/lua.vim
@@ -3,7 +3,6 @@
3 3
 " Author: Peter Odding <peter@peterodding.com>
4 4
 " Last Change: June 18, 2011
5 5
 " URL: http://peterodding.com/code/vim/lua-ftplugin
6  
-" Version: 0.6.10
7 6
 
8 7
 " Support for automatic update using the GLVS plug-in.
9 8
 " GetLatestVimScripts: 3625 1 :AutoInstall: lua.zip

0 notes on commit 5e40f1c

Please sign in to comment.
Something went wrong with that request. Please try again.