Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improve omni completion, add plugin/ script for autocmds

  • Loading branch information...
commit 63641c846c36a2cb3fef4c5fc5c7f725396404f7 1 parent 14d9067
Peter Odding authored June 18, 2011
2  README.md
Source Rendered
@@ -14,6 +14,8 @@ The [Lua][lua] file type plug-in for [Vim][vim] makes it easier to work with Lua
14 14
 
15 15
  * The ['omnifunc'][ofu] option is set to allow dynamic completion of the variables defined in all modules installed on the system using Control-X Control-O, however it needs to be explicitly enabled by setting the `lua_complete_omni` option because this functionality may have undesired side effects! When you invoke omni completion after typing `require '` or `require('` you get completion of module names
16 16
 
  17
+![Screenshot of omni completion](http://peterodding.com/code/vim/lua-ftplugin/screenshots/omni-completion.png)
  18
+
17 19
  * Several [text-objects][tob] are defined so you can jump between blocks and functions
18 20
 
19 21
  * A pretty nifty hack of the [matchit plug-in][mit] is included: When the cursor is on a `function` or `return` keyword the `%` mapping cycles between the relevant keywords (`function`, `return`, `end`), this also works for branching statements (`if`, `elseif`, `else`, `end`) and looping statements (`for`, `while`, `repeat`, `until`, `end`)
3  TODO.md
Source Rendered
... ...
@@ -1,5 +1,8 @@
1 1
 # To-do list for the Lua file type plug-in for Vim
2 2
 
  3
+ * `BufReadCmd` automatic command that converts `*.luac` files to byte code listings :-)
  4
+ * Make the globals checking smarter so it can be enabled by default without being too much of a nuisance?
  5
+
3 6
 ## Smarter completion
4 7
 
5 8
 Make completion smarter by supporting function arguments:
60  autoload/xolox/lua.vim
@@ -3,7 +3,6 @@
3 3
 " Last Change: June 18, 2011
4 4
 " URL: http://peterodding.com/code/vim/lua-ftplugin
5 5
 
6  
-let s:version = '0.6.14'
7 6
 let s:miscdir = expand('<sfile>:p:h:h:h') . '/misc/lua-ftplugin'
8 7
 let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua'
9 8
 let s:globals_script = s:miscdir . '/globals.lua'
@@ -23,9 +22,9 @@ function! xolox#lua#includeexpr(fname) " {{{1
23 22
   let module = substitute(a:fname, '\.', '/', 'g')
24 23
   for template in xolox#lua#getsearchpath('$LUA_PATH', 'package.path')
25 24
     let expanded = substitute(template, '?', module, 'g')
26  
-    call xolox#misc#msg#debug("lua.vim %s: Expanded %s -> %s", s:version, template, expanded)
  25
+    call xolox#misc#msg#debug("lua.vim %s: Expanded %s -> %s", g:lua_ftplugin_version, template, expanded)
27 26
     if filereadable(expanded)
28  
-      call xolox#misc#msg#debug("lua.vim %s: Matched existing file %s", s:version, expanded)
  27
+      call xolox#misc#msg#debug("lua.vim %s: Matched existing file %s", g:lua_ftplugin_version, expanded)
29 28
       return expanded
30 29
     endif
31 30
   endfor
@@ -41,7 +40,7 @@ function! xolox#lua#getsearchpath(envvar, luavar) " {{{1
41 40
       redir => path
42 41
       execute 'silent lua print(' . a:luavar . ')'
43 42
       redir END
44  
-      call xolox#misc#msg#debug("lua.vim %s: Got %s from Lua Interface for Vim", s:version, a:luavar)
  43
+      call xolox#misc#msg#debug("lua.vim %s: Got %s from Lua Interface for Vim", g:lua_ftplugin_version, a:luavar)
45 44
     catch
46 45
       redir END
47 46
     endtry
@@ -49,13 +48,13 @@ function! xolox#lua#getsearchpath(envvar, luavar) " {{{1
49 48
   if empty(path)
50 49
     let path = eval(a:envvar)
51 50
     if !empty(path)
52  
-      call xolox#misc#msg#debug("lua.vim %s: Got %s from %s", s:version, a:luavar, a:envvar)
  51
+      call xolox#misc#msg#debug("lua.vim %s: Got %s from %s", g:lua_ftplugin_version, a:luavar, a:envvar)
53 52
     else
54 53
       let path = system('lua -e "io.write(' . a:luavar . ')"')
55 54
       if v:shell_error
56  
-        call xolox#misc#msg#warn("lua.vim %s: Failed to get %s from external Lua interpreter: %s", s:version, a:luavar, path)
  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)
57 56
       else
58  
-        call xolox#misc#msg#debug("lua.vim %s: Got %s from external Lua interpreter", s:version, a:luavar)
  57
+        call xolox#misc#msg#debug("lua.vim %s: Got %s from external Lua interpreter", g:lua_ftplugin_version, a:luavar)
59 58
       endif
60 59
     endif
61 60
   endif
@@ -63,11 +62,13 @@ function! xolox#lua#getsearchpath(envvar, luavar) " {{{1
63 62
 endfunction
64 63
 
65 64
 function! xolox#lua#autocheck() " {{{1
66  
-  if xolox#lua#getopt('lua_check_syntax', 1)
67  
-    call xolox#lua#checksyntax()
68  
-  endif
69  
-  if xolox#lua#getopt('lua_check_globals', 0) && empty(getqflist())
70  
-    call xolox#lua#checkglobals(0)
  65
+  if &filetype == 'lua'
  66
+    if xolox#lua#getopt('lua_check_syntax', 1)
  67
+      call xolox#lua#checksyntax()
  68
+    endif
  69
+    if xolox#lua#getopt('lua_check_globals', 0) && empty(getqflist())
  70
+      call xolox#lua#checkglobals(0)
  71
+    endif
71 72
   endif
72 73
 endfunction
73 74
 
@@ -80,7 +81,7 @@ function! xolox#lua#checksyntax() " {{{1
80 81
     let message .= " doesn't seem to be available! I'm disabling"
81 82
     let message .= " automatic syntax checking for Lua scripts."
82 83
     let g:lua_check_syntax = 0
83  
-    call xolox#misc#msg#warn(message, s:version)
  84
+    call xolox#misc#msg#warn(message, g:lua_ftplugin_version)
84 85
   else
85 86
     let mp_save = &makeprg
86 87
     let efm_save = &errorformat
@@ -114,7 +115,7 @@ function! s:highlighterrors()
114 115
   let pattern = '^\%%%il.*\n\?'
115 116
   for entry in getqflist()
116 117
     call matchadd(hlgroup, '\%' . min([entry.lnum, line('$')]) . 'l')
117  
-    call xolox#misc#msg#warn("lua.vim %s: Syntax error on line %i: %s", s:version, entry.lnum, entry.text)
  118
+    call xolox#misc#msg#warn("lua.vim %s: Syntax error on line %i: %s", g:lua_ftplugin_version, entry.lnum, entry.text)
118 119
   endfor
119 120
 endfunction
120 121
 
@@ -155,7 +156,7 @@ function! s:lookupmethod(cword, prefix, pattern)
155 156
   let method = matchstr(a:cword, a:pattern)
156 157
   if method != ''
157 158
     let identifier = a:prefix . method
158  
-    call xolox#misc#msg#debug("lua.vim %s: Translating '%s' -> '%s'", s:version, a:cword, identifier)
  159
+    call xolox#misc#msg#debug("lua.vim %s: Translating '%s' -> '%s'", g:lua_ftplugin_version, a:cword, identifier)
159 160
     call s:lookuptopic(identifier)
160 161
   endif
161 162
 endfunction
@@ -334,7 +335,7 @@ function! xolox#lua#omnifunc(init, base) " {{{1
334 335
   if a:init
335 336
     return s:get_completion_prefix()
336 337
   elseif !xolox#lua#getopt('lua_complete_omni', 0)
337  
-    throw printf("lua.vim %s: omni completion needs to be explicitly enabled, see the readme!", s:version)
  338
+    throw printf("lua.vim %s: omni completion needs to be explicitly enabled, see the readme!", g:lua_ftplugin_version)
338 339
   endif
339 340
   if !exists('s:omnifunc_modules')
340 341
     let s:omnifunc_modules = xolox#lua#getomnimodules()
@@ -366,7 +367,7 @@ function! xolox#lua#getomnimodules() " {{{1
366 367
   let modules = keys(modulemap)
367 368
   call sort(modules)
368 369
   let msg = "lua.vim %s: Collected %i module names for omni completion in %s"
369  
-  call xolox#misc#timer#stop(msg, s:version, len(modules), starttime)
  370
+  call xolox#misc#timer#stop(msg, g:lua_ftplugin_version, len(modules), starttime)
370 371
   return modules
371 372
 endfunction
372 373
 
@@ -376,7 +377,7 @@ function! s:expandsearchpath(searchpath, modules)
376 377
     let components = split(template, '?')
377 378
     if len(components) != 2
378 379
       let msg = "lua.vim %s: Failed to parse search path entry: %s"
379  
-      call xolox#misc#msg#debug(msg, s:version, template)
  380
+      call xolox#misc#msg#debug(msg, g:lua_ftplugin_version, template)
380 381
       continue
381 382
     endif
382 383
     let [prefix, suffix] = components
@@ -384,24 +385,24 @@ function! s:expandsearchpath(searchpath, modules)
384 385
     " it might be arbitrarily deep, e.g. when working directory is /
385 386
     if prefix =~ '^.[\\/]$'
386 387
       let msg = "lua.vim %s: Refusing to expand dangerous search path entry: %s"
387  
-      call xolox#misc#msg#debug(msg, s:version, template)
  388
+      call xolox#misc#msg#debug(msg, g:lua_ftplugin_version, template)
388 389
       continue
389 390
     endif
390 391
     let pattern = substitute(template, '?', '**/*', 'g')
391  
-    call xolox#misc#msg#debug("lua.vim %s: Transformed %s -> %s", s:version, template, pattern)
  392
+    call xolox#misc#msg#debug("lua.vim %s: Transformed %s -> %s", g:lua_ftplugin_version, template, pattern)
392 393
     let msg = "lua.vim %s: Failed to convert pathname to module name, %s doesn't match! (%s: '%s', pathname: '%s')"
393 394
     for pathname in split(glob(pattern), "\n")
394 395
       if pathname[0 : len(prefix)-1] != prefix
395 396
         " Validate prefix of resulting pathname.
396  
-        call xolox#misc#msg#warn(msg, s:version, 'prefix', 'prefix', prefix, pathname)
  397
+        call xolox#misc#msg#warn(msg, g:lua_ftplugin_version, 'prefix', 'prefix', prefix, pathname)
397 398
       elseif pathname[-len(suffix) : -1] != suffix
398 399
         " Validate suffix of resulting pathname.
399  
-        call xolox#misc#msg#warn(msg, s:version, 'suffix', 'suffix', suffix, pathname)
  400
+        call xolox#misc#msg#warn(msg, g:lua_ftplugin_version, 'suffix', 'suffix', suffix, pathname)
400 401
       elseif pathname !~ 'test'
401 402
         let relative = pathname[len(prefix) : -len(suffix)-1]
402 403
         let modulename = substitute(relative, '[\\/]\+', '.', 'g')
403 404
         let a:modules[modulename] = 1
404  
-        call xolox#misc#msg#debug("lua.vim %s: Transformed '%s' -> '%s'", s:version, pathname, modulename)
  405
+        call xolox#misc#msg#debug("lua.vim %s: Transformed '%s' -> '%s'", g:lua_ftplugin_version, pathname, modulename)
405 406
       endif
406 407
     endfor
407 408
   endfor
@@ -413,7 +414,7 @@ function! xolox#lua#getomnivariables(modules) " {{{1
413 414
   let variables = eval('[' . substitute(output, '\_s\+', ',', 'g') . ']')
414 415
   call sort(variables, 1)
415 416
   let msg = "lua.vim %s: Collected %i variables for omni completion in %s"
416  
-  call xolox#misc#timer#stop(msg, s:version, len(variables), starttime)
  417
+  call xolox#misc#timer#stop(msg, g:lua_ftplugin_version, len(variables), starttime)
417 418
   return variables
418 419
 endfunction
419 420
 
@@ -442,6 +443,15 @@ function! xolox#lua#completedynamic(type) " {{{1
442 443
   return a:type
443 444
 endfunction
444 445
 
  446
+function! xolox#lua#tweakoptions() " {{{1
  447
+  if &filetype == 'lua'
  448
+    let s:completeopt_save = &cot
  449
+    set completeopt+=longest
  450
+  elseif exists('s:completeopt_save')
  451
+    let &completeopt = s:completeopt_save
  452
+  endif
  453
+endfunction
  454
+
445 455
 function! xolox#lua#dofile(pathname, arguments) " {{{1
446 456
   if has('lua')
447 457
     " Use the Lua Interface for Vim.
@@ -454,7 +464,7 @@ function! xolox#lua#dofile(pathname, arguments) " {{{1
454 464
     let output = xolox#misc#str#trim(system(join(['lua', a:pathname] + a:arguments)))
455 465
     if v:shell_error
456 466
       let msg = "lua.vim %s: Failed to retrieve omni completion candidates (output: '%s')"
457  
-      call xolox#misc#msg#warn(msg, s:version, output)
  467
+      call xolox#misc#msg#warn(msg, g:lua_ftplugin_version, output)
458 468
     endif
459 469
   endif
460 470
   return xolox#misc#str#trim(output)
195  doc/lua-ftplugin.txt
... ...
@@ -0,0 +1,195 @@
  1
+*lua-ftplugin.txt*  Lua file type plug-in for the Vim text editor
  2
+
  3
+The Lua [1] file type plug-in for Vim makes it easier to work with Lua source
  4
+code in Vim by providing the following features:
  5
+
  6
+ - The |'includeexpr'| option is set so that the |gf| (go to file) mapping knows
  7
+   how to resolve Lua module names using package.path [2]
  8
+
  9
+ - The |'include'| option is set so that Vim follows dofile() [3], loadfile() [4]
  10
+   and require() [5] calls when looking for identifiers in included files
  11
+   (this works together with the |'includeexpr'| option)
  12
+
  13
+ - An automatic command is installed that runs 'luac -p' when you save your Lua
  14
+   scripts. If 'luac' reports any errors they are shown in the quick-fix list
  15
+   and Vim jumps to the line of the first error. If 'luac -p' doesn't report
  16
+   any errors a check for undefined global variables is performed by parsing
  17
+   the output of 'luac -p -l'
  18
+
  19
+ - '<F1>' on a Lua function or 'method' call will try to open the relevant
  20
+   documentation in the Lua Reference for Vim [6]
  21
+
  22
+ - The |'completefunc'| option is set to allow completion of Lua 5.1 keywords,
  23
+   global variables and library members using Control-X Control-U
  24
+
  25
+ - The |'omnifunc'| option is set to allow dynamic completion of the variables
  26
+   defined in all modules installed on the system using Control-X Control-O,
  27
+   however it needs to be explicitly enabled by setting the
  28
+   |lua_complete_omni| option because this functionality may have undesired
  29
+   side effects! When you invoke omni completion after typing 'require '' or
  30
+   'require('' you get completion of module names
  31
+
  32
+    Screenshot of omni completion, see reference [7]
  33
+
  34
+ - Several |text-objects| are defined so you can jump between blocks and
  35
+   functions
  36
+
  37
+ - A pretty nifty hack of the matchit plug-in (see |matchit-install|) is
  38
+   included: When the cursor is on a 'function' or 'return' keyword the '%'
  39
+   mapping cycles between the relevant keywords ('function', 'return', 'end'),
  40
+   this also works for branching statements ('if', 'elseif', 'else', 'end')
  41
+   and looping statements ('for', 'while', 'repeat', 'until', 'end')
  42
+
  43
+===============================================================================
  44
+                                                     *lua-ftplugin-installation*
  45
+Installation ~
  46
+
  47
+Unzip the most recent ZIP archive [8] file inside your Vim profile directory
  48
+(usually this is '~/.vim' on UNIX and '%USERPROFILE%\vimfiles' on Windows),
  49
+restart Vim and execute the command ':helptags ~/.vim/doc' (use ':helptags
  50
+~\vimfiles\doc' instead on Windows). Now try it out: Edit a Lua script and try
  51
+any of the features documented above.
  52
+
  53
+===============================================================================
  54
+                                                          *lua-ftplugin-options*
  55
+Options ~
  56
+
  57
+The Lua file type plug-in handles options as follows: First it looks at buffer
  58
+local variables, then it looks at global variables and if neither exists a
  59
+default is chosen. This means you can change how the plug-in works for
  60
+individual buffers. For example to change the location of the Lua compiler
  61
+used to check the syntax:
  62
+>
  63
+    " This sets the default value for all buffers.
  64
+    :let g:lua_compiler_name = '/usr/local/bin/luac'
  65
+    
  66
+    " This is how you change the value for one buffer.
  67
+    :let b:lua_compiler_name = '/usr/local/bin/lualint'
  68
+
  69
+-------------------------------------------------------------------------------
  70
+The *lua_path* option
  71
+
  72
+This option contains the value of 'package.path' as a string. You shouldn't
  73
+need to change this because the plug-in is aware of $LUA_PATH [2] and if that
  74
+isn't set the plug-in will run a Lua interpreter to get the value of
  75
+package.path [2].
  76
+
  77
+-------------------------------------------------------------------------------
  78
+The *lua_check_syntax* option
  79
+
  80
+When you write a Lua script to disk the plug-in automatically runs the Lua
  81
+compiler to check for syntax errors. To disable this behavior you can set this
  82
+option to false (0):
  83
+>
  84
+    let g:lua_check_syntax = 0
  85
+
  86
+You can manually check the syntax using the ':CheckSyntax' command.
  87
+
  88
+-------------------------------------------------------------------------------
  89
+The *lua_check_globals* option
  90
+
  91
+When you write a Lua script to disk the plug-in automatically runs the Lua
  92
+compiler to check for undefined global variables. To disable this behavior you
  93
+can set this option to false (0):
  94
+>
  95
+    let g:lua_check_globals = 0
  96
+
  97
+You can manually check the globals using the ':CheckGlobals' command.
  98
+
  99
+-------------------------------------------------------------------------------
  100
+The *lua_compiler_name* option
  101
+
  102
+The name or path of the Lua compiler used to check for syntax errors (defaults
  103
+to 'luac'). You can set this option to run the Lua compiler from a
  104
+non-standard location or to run a dedicated syntax checker like lualint [9].
  105
+
  106
+-------------------------------------------------------------------------------
  107
+The *lua_compiler_args* option
  108
+
  109
+The argument(s) required by the compiler or syntax checker (defaults to '-p').
  110
+
  111
+-------------------------------------------------------------------------------
  112
+The *lua_error_format* option
  113
+
  114
+If you use a dedicated syntax checker you may need to change this option to
  115
+reflect the format of the messages printed by the syntax checker.
  116
+
  117
+-------------------------------------------------------------------------------
  118
+The *lua_complete_keywords* option
  119
+
  120
+To disable completion of keywords you can set this option to false (0).
  121
+
  122
+-------------------------------------------------------------------------------
  123
+The *lua_complete_globals* option
  124
+
  125
+To disable completion of global functions you can set this option to false
  126
+(0).
  127
+
  128
+-------------------------------------------------------------------------------
  129
+The *lua_complete_library* option
  130
+
  131
+To disable completion of library functions you can set this option to false
  132
+(0).
  133
+
  134
+-------------------------------------------------------------------------------
  135
+The *lua_complete_dynamic* option
  136
+
  137
+When you type a dot after a word the Lua file type plug-in will automatically
  138
+start completion. To disable this behavior you can set this option to false
  139
+(0).
  140
+
  141
+-------------------------------------------------------------------------------
  142
+The *lua_complete_omni* option
  143
+
  144
+This option is disabled by default for two reasons:
  145
+
  146
+ - The omni completion support works by enumerating and loading all installed
  147
+   modules. If module loading has side effects this can have unintended
  148
+   consequences!
  149
+
  150
+ - Because all modules installed on the system are loaded, collecting the
  151
+   completion candidates can be slow. After the first run the completion
  152
+   candidates are cached so this will only bother you once (until you restart
  153
+   Vim).
  154
+
  155
+If you want to use the omni completion despite the warnings above, execute the
  156
+following command:
  157
+>
  158
+    :let g:lua_complete_omni = 1
  159
+
  160
+Now when you type Control-X Control-O Vim will hang for a moment, after which
  161
+you should be presented with an enormous list of completion candidates :-)
  162
+
  163
+===============================================================================
  164
+                                                          *lua-ftplugin-contact*
  165
+Contact ~
  166
+
  167
+If you have questions, bug reports, suggestions, etc. the author can be
  168
+contacted at peter@peterodding.com. The latest version is available at
  169
+http://peterodding.com/code/vim/lua-ftplugin and http://github.com/xolox/vim-lua-ftplugin.
  170
+If you like this plug-in please vote for it on Vim Online [10].
  171
+
  172
+===============================================================================
  173
+                                                          *lua-ftplugin-license*
  174
+License ~
  175
+
  176
+This software is licensed under the MIT license [11]. Copyright 2011 Peter
  177
+Odding <peter@peterodding.com>.
  178
+
  179
+===============================================================================
  180
+                                                       *lua-ftplugin-references*
  181
+References ~
  182
+
  183
+[1] http://www.lua.org/
  184
+[2] http://www.lua.org/manual/5.1/manual.html#pdf-package.path
  185
+[3] http://www.lua.org/manual/5.1/manual.html#pdf-dofile
  186
+[4] http://www.lua.org/manual/5.1/manual.html#pdf-loadfile
  187
+[5] http://www.lua.org/manual/5.1/manual.html#pdf-require
  188
+[6] http://www.vim.org/scripts/script.php?script_id=1291
  189
+[7] http://peterodding.com/code/vim/lua-ftplugin/screenshots/omni-completion.png
  190
+[8] http://peterodding.com/code/vim/downloads/lua-ftplugin.zip
  191
+[9] http://lua-users.org/wiki/LuaLint
  192
+[10] http://www.vim.org/scripts/script.php?script_id=3625
  193
+[11] http://en.wikipedia.org/wiki/MIT_License
  194
+
  195
+vim: ft=help
9  ftplugin/lua.vim
@@ -4,9 +4,6 @@
4 4
 " Last Change: June 18, 2011
5 5
 " URL: http://peterodding.com/code/vim/lua-ftplugin
6 6
 
7  
-" Support for automatic update using the GLVS plug-in.
8  
-" GetLatestVimScripts: 3625 1 :AutoInstall: lua.zip
9  
-
10 7
 if exists('b:did_ftplugin')
11 8
   finish
12 9
 else
@@ -48,12 +45,6 @@ call add(s:undo_ftplugin, 'delcommand CheckSyntax')
48 45
 command! -bar -bang -buffer CheckGlobals call xolox#lua#checkglobals(<q-bang> == '!')
49 46
 call add(s:undo_ftplugin, 'delcommand CheckGlobals')
50 47
 
51  
-" Automatic commands to check for syntax errors and undefined globals. {{{1
52  
-augroup PluginFileTypeLua
53  
-  autocmd! BufWritePost <buffer> call xolox#lua#autocheck()
54  
-  call add(s:undo_ftplugin, 'autocmd! PluginFileTypeLua BufWritePost <buffer>')
55  
-augroup END
56  
-
57 48
 " Define mappings for context-sensitive help using Lua Reference for Vim. {{{1
58 49
 imap <buffer> <F1> <C-o>:call xolox#lua#help()<Cr>
59 50
 nmap <buffer> <F1>      :call xolox#lua#help()<Cr>
13  misc/lua-ftplugin/omnicomplete.lua
@@ -3,7 +3,7 @@
3 3
 --[[
4 4
 
5 5
 Author: Peter Odding <peter@peterodding.com>
6  
-Last Change: June 14, 2011
  6
+Last Change: June 18, 2011
7 7
 URL: http://peterodding.com/code/vim/lua-ftplugin
8 8
 
9 9
 This Lua script is executed by the Lua file type plug-in for Vim to provide
@@ -44,7 +44,16 @@ local function dump(table, path, cache)
44 44
         addmatch(path, 'f', path .. '()')
45 45
       elseif vtype ~= 'table' then
46 46
         printed = true
47  
-        addmatch(path, 'v', nil)
  47
+        if vtype == 'boolean' or vtype == 'number' then
  48
+          addmatch(path, 'v', tostring(value))
  49
+        elseif vtype == 'string' then
  50
+          if #value > 40 then
  51
+            value = value:sub(1, 40) .. '..'
  52
+          end
  53
+          addmatch(path, 'v', value)
  54
+        else
  55
+          addmatch(path, 'v', nil)
  56
+        end
48 57
       else
49 58
         if vtype == 'table' and not cache[value] then
50 59
           cache[value] = true
32  plugin/lua-ftplugin.vim
... ...
@@ -0,0 +1,32 @@
  1
+" Vim file type plug-in
  2
+" Language: Lua 5.1
  3
+" Author: Peter Odding <peter@peterodding.com>
  4
+" Last Change: June 18, 2011
  5
+" URL: http://peterodding.com/code/vim/lua-ftplugin
  6
+
  7
+" Support for automatic update using the GLVS plug-in.
  8
+" GetLatestVimScripts: 3625 1 :AutoInstall: lua.zip
  9
+
  10
+" Don't source the plug-in when it's already been loaded or &compatible is set.
  11
+if &cp || exists('g:loaded_lua_ftplugin')
  12
+  finish
  13
+endif
  14
+
  15
+let g:lua_ftplugin_version = '0.6.15'
  16
+
  17
+" Commands to manually check for syntax errors and undefined globals.
  18
+command! -bar LuaCheckSyntax call xolox#lua#checksyntax()
  19
+command! -bar -bang LuaCheckGlobals call xolox#lua#checkglobals(<q-bang> == '!')
  20
+
  21
+" Automatic commands to check for syntax errors and/or undefined globals
  22
+" and change Vim's "completeopt" setting on the fly for Lua buffers.
  23
+augroup PluginFileTypeLua
  24
+  autocmd!
  25
+  autocmd WinEnter * call xolox#lua#tweakoptions()
  26
+  autocmd BufWritePost * call xolox#lua#autocheck()
  27
+augroup END
  28
+
  29
+" Make sure the plug-in is only loaded once.
  30
+let g:loaded_lua_ftplugin = 1
  31
+
  32
+" vim: ts=2 sw=2 et

0 notes on commit 63641c8

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