sponsor Vim development Vim logo Vim Book Ad

lua.vim : Lua file type plug-in for the Vim text editor

 script karma  Rating 152/63, Downloaded by 17143  Comments, bugs, improvements  Vim wiki

created by
Peter Odding
 
script type
ftplugin
 
description
The Lua file type plug-in for Vim makes it easier to work with Lua source code in Vim by providing the following features:

• The 'includeexpr' option is set so that the gf (go to file) mapping knows how to resolve Lua module names using package.path
• The 'include' option is set so that Vim follows dofile(), loadfile() and require() calls when looking for identifiers in included files (this works together with the 'includeexpr' option)
• An automatic command is installed that runs "luac -p" when you save your Lua scripts. If luac reports any errors they are shown in the quick-fix list and Vim jumps to the line of the first error. If "luac -p" doesn’t report any errors a check for undefined global variables is performed by parsing the output of "luac -p -l"
• <F1> on a Lua function or 'method' call will try to open the relevant documentation in the Lua Reference for Vim
• The 'completefunc' option is set to allow completion of Lua 5.1 keywords, global variables and library members using Control-X Control-U
• Several text-objects are defined so you can jump between blocks and functions
• A pretty nifty hack of the matchit plug-in 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)

For more information about the plug-in please refer to its homepage or the project page on GitHub:

http://peterodding.com/code/vim/lua-ftplugin
http://github.com/xolox/vim-lua-ftplugin

If you have questions, bug reports, suggestions, etc. the author can be contacted at [email protected]. If you like this plug-in please vote for it below!
 
install details
Please note that the vim-lua-ftplugin plug-in requires my vim-misc plug-in which is separately distributed (see vimscript #4597).

Unzip the most recent ZIP archives of the vim-lua-ftplugin and vim-misc plug-ins inside your Vim profile directory (usually this is ~/.vim on UNIX and %USERPROFILE%\vimfiles on Windows), restart Vim and execute the command :helptags ~/.vim/doc (use :helptags ~\vimfiles\doc instead on Windows).

If you prefer you can also use Pathogen, Vundle or a similar tool to install & update the vim-lua-ftplugin and vim-misc plug-ins using a local clone of the git repository.

Now try it out: Edit a Lua script and try any of the features documented above.

Note that on Windows a command prompt window pops up whenever Lua is run as an external process. If this bothers you then you can install my shell.vim plug-in (vimscript #3123) which includes a DLL that works around this issue. Once you’ve installed both plug-ins it should work out of the box!
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
lua-ftplugin.zip 0.8 2014-09-14 7.0 Peter Odding • Make issues like #28 easier to debug:
   http://github.com/xolox/vim-lua-ftplugin/commit/5527820
> • Update docs to refer to correct option lua_omni_blacklist:
  
http://github.com/xolox/vim-lua-ftplugin/commit/c9ee830
> • Provide option to inspect omni completion module loading list:
  
http://github.com/xolox/vim-lua-ftplugin/commit/2c69923
> • Update to Lua 5.2 keywords and standard libraries:
  
http://github.com/xolox/vim-lua-ftplugin/commit/50c7fc1
lua-ftplugin.zip 0.7.23 2014-07-12 7.0 Peter Odding • Make omni completion compatible with strict.lua (issue #27 on GitHub):
   http://github.com/xolox/vim-lua-ftplugin/commit/e7d3ce7
lua-ftplugin.zip 0.7.22 2014-07-06 7.0 Peter Odding • Add Lua 5.2 goto keyword to keyword completion candidates:
   http://github.com/xolox/vim-lua-ftplugin/commit/5d55a11
> • Reliably fix userdata errors that have been bugging users for a while:
  
http://github.com/xolox/vim-lua-ftplugin/commit/4746f4d
lua-ftplugin.zip 0.7.21 2014-06-17 7.0 Peter Odding • Map K for help lookup (in normal mode):
   http://github.com/xolox/vim-lua-ftplugin/commit/e3e7ab4
> • Pull request #19: Map K for help lookup (in normal mode):
  
http://github.com/xolox/vim-lua-ftplugin/commit/090371f
> • Bug fix: Respect 'lua_interpreter_path' during search path discovery:
  
http://github.com/xolox/vim-lua-ftplugin/commit/aa7a642
> • Make it possible to disable use of Lua Interface for Vim:
  
http://github.com/xolox/vim-lua-ftplugin/commit/5d0ec87
lua-ftplugin.zip 0.7.19 2014-06-16 7.0 Peter Odding • Pull request #21: Allow module blacklisting in omni completion:
   http://github.com/xolox/vim-lua-ftplugin/commit/d85872c
lua-ftplugin.zip 0.7.18 2014-06-16 7.0 Peter Odding • Use configured Lua compiler in globals.lua (reported in pull request #23):
   http://github.com/xolox/vim-lua-ftplugin/commit/96082b7
lua-ftplugin.zip 0.7.17 2014-06-16 7.0 Peter Odding • Document the global :LuaCheckSyntax and :LuaCheckGlobals commands:
   http://github.com/xolox/vim-lua-ftplugin/commit/624ee70
> • Make name/path of Lua interpreter configurable:
  
http://github.com/xolox/vim-lua-ftplugin/commit/47123ba
> • Add parentheses to functions in overview of known globals:
  
http://github.com/xolox/vim-lua-ftplugin/commit/7f4bbd9
> • Improve interaction between automatic syntax/globals checks:
  
http://github.com/xolox/vim-lua-ftplugin/commit/1d7aaec
> • Try to resolve pull request #23 (workaround for table indexes in globals.lua):
  
http://github.com/xolox/vim-lua-ftplugin/commit/9160dee
lua-ftplugin.zip 0.7.13 2013-08-31 7.0 Peter Odding • Make setting of completefunc/omnifunc optional:
   http://github.com/xolox/vim-lua-ftplugin/commit/17e9003
lua-ftplugin.zip 0.7.12 2013-08-19 7.0 Peter Odding • Always include standard library modules in module name completion:
   http://github.com/xolox/vim-lua-ftplugin/commit/5157b16
> • Make sure vim-misc is installed, politely complain if it isn't:
  
http://github.com/xolox/vim-lua-ftplugin/commit/73736ad
lua-ftplugin.zip 0.7.10 2013-05-25 7.0 Peter Odding • Document vim-misc as external dependency (needs to be installed separately from now on):
   http://github.com/xolox/vim-lua-ftplugin/commit/a959a1b
lua-ftplugin.zip 0.7.8 2013-05-20 7.0 Peter Odding • Updated miscellaneous scripts:
   http://github.com/xolox/vim-lua-ftplugin/commit/3e26c8a
lua-ftplugin.zip 0.7.7 2013-05-19 7.0 Peter Odding • Updated miscellaneous scripts:
   http://github.com/xolox/vim-lua-ftplugin/commit/f7399b9
lua-ftplugin.zip 0.7.6 2013-05-15 7.0 Peter Odding • Option lua_define_completion_mappings (suggested by Daniel Fort):
   http://github.com/xolox/vim-lua-ftplugin/commit/0544e6f
lua-ftplugin.zip 0.7.5 2013-05-13 7.0 Peter Odding • Updated miscellaneous scripts:
   http://github.com/xolox/vim-lua-ftplugin/commit/6e0c4b7
  
; http://github.com/xolox/vim-lua-ftplugin/commit/9c88b0e
lua-ftplugin.zip 0.7.4 2013-05-12 7.0 Peter Odding • Make omni completion compatible with the latest Lua Interface for Vim (contributed by Daniel Fort):
   http://github.com/xolox/vim-lua-ftplugin/commit/6caa0da
  
; http://github.com/xolox/vim-lua-ftplugin/commit/2f29afe
> • Bug fix: Properly escape Vim script strings in omnicomplete.lua:
  
http://github.com/xolox/vim-lua-ftplugin/commit/b4f29a5
lua-ftplugin.zip 0.7.3 2013-05-02 7.0 Peter Odding • Updated miscellaneous scripts:
   http://github.com/xolox/vim-lua-ftplugin/commit/d956287
lua-ftplugin.zip 0.7.2 2013-04-28 7.0 Peter Odding • Updated miscellaneous scripts:
   http://github.com/xolox/vim-lua-ftplugin/commit/5c60686
lua-ftplugin.zip 0.7.1 2013-04-20 7.0 Peter Odding • Remove old documentation (sorry about that):
   http://github.com/xolox/vim-lua-ftplugin/commit/46466bb
> • Make compatibility with miscellaneous scripts explicit:
  
http://github.com/xolox/vim-lua-ftplugin/commit/fbeb973
lua-ftplugin.zip 0.7 2011-11-25 7.0 Peter Odding • Bug fix for omnicomplete.lua: Strip newlines from generated output:
   http://github.com/xolox/vim-lua-ftplugin/commit/b14088c
> • Use shell.vim plug-in to execute Lua subprocesses (issue #2 on GitHub):
  
http://github.com/xolox/vim-lua-ftplugin/commit/9b4c774
  
; http://github.com/xolox/vim-lua-ftplugin/commit/0814a1b
  
; http://github.com/xolox/vim-lua-ftplugin/commit/bccf110
lua-ftplugin.zip 0.6.28 2011-11-21 7.0 Peter Odding • Work around &shellslash setting on Windows:
   http://github.com/xolox/vim-lua-ftplugin/commit/8e1812a
lua-ftplugin.zip 0.6.27 2011-11-15 7.0 Peter Odding • Bug fix for dynamic completion after typing require(':
   http://github.com/xolox/vim-lua-ftplugin/commit/3e3d3dc
> • Make dofile(), loadfile(), ... trigger filename completion:
  
http://github.com/xolox/vim-lua-ftplugin/commit/8cff1bd
lua-ftplugin.zip 0.6.25 2011-10-23 7.0 Peter Odding • Bug fix: Don't perform automatic completion in strings/comments:
   http://github.com/xolox/vim-lua-ftplugin/commit/5cf57e0
lua-ftplugin.zip 0.6.24 2011-10-16 7.0 Peter Odding • Support Lua modules that don't create a global (omni completion):
   http://github.com/xolox/vim-lua-ftplugin/commit/3c49c27
lua-ftplugin.zip 0.6.23 2011-09-25 7.0 Peter Odding • Updated miscellaneous scripts:
   http://github.com/xolox/vim-lua-ftplugin/commit/50a844e
lua-ftplugin.zip 0.6.22 2011-09-04 7.0 Peter Odding • Updated miscellaneous scripts:
   http://github.com/xolox/vim-lua-ftplugin/commit/048c493
lua-ftplugin.zip 0.6.21 2011-08-28 7.0 Peter Odding • Option handling with xolox#misc#option#get({name}, {default}) (this one took me some time to get right..):
   http://github.com/xolox/vim-lua-ftplugin/commit/e228b0e
  
; http://github.com/xolox/vim-lua-ftplugin/commit/0b1c06e
  
; http://github.com/xolox/vim-lua-ftplugin/commit/dc8a937
  
; http://github.com/xolox/vim-lua-ftplugin/commit/05d45ea
> • Minor refactoring of omnicomplete.lua:
  
http://github.com/xolox/vim-lua-ftplugin/commit/5bb59a2
> • Move version variable to autoload script:
  
http://github.com/xolox/vim-lua-ftplugin/commit/b01ff5e
lua-ftplugin.zip 0.6.17 2011-06-18 7.0 Peter Odding • Completion bug fix: Off by one in prefix selection:
   http://github.com/xolox/vim-lua-ftplugin/commit/865c32f
lua-ftplugin.zip 0.6.16 2011-06-18 7.0 Peter Odding • Delete old Vim help files (never even noticed them :-S):
   http://github.com/xolox/vim-lua-ftplugin/commit/5d0ad12
lua-ftplugin.zip 0.6.15 2011-06-18 7.0 Peter Odding • F1: Fall back to Lua reference for Vim if it exists, :help otherwise:
   http://github.com/xolox/vim-lua-ftplugin/commit/feecf0d
> • Disable automatic checking of global variables (for now):
  
http://github.com/xolox/vim-lua-ftplugin/commit/e15b7be
> • Define version as variable, include version in messages:
  
http://github.com/xolox/vim-lua-ftplugin/commit/5e40f1c
> • Enable overriding of compiler arguments:
  
http://github.com/xolox/vim-lua-ftplugin/commit/3c1ca42
> • Set quick-fix window title after syntax check:
  
http://github.com/xolox/vim-lua-ftplugin/commit/b5ea380
> • Make completion use prefix matching instead of substring matching:
  
http://github.com/xolox/vim-lua-ftplugin/commit/14d9067
> • Improve omni completion, add plugin/ script for autocmds:
  
http://github.com/xolox/vim-lua-ftplugin/commit/63641c8
lua.zip 0.6.8 2011-06-15 7.0 Peter Odding • Add signatures of LuaSocket functions:
   http://github.com/xolox/vim-lua-ftplugin/commit/972cac7
lua.zip 0.6.7 2011-06-14 7.0 Peter Odding • Check for undefined global variables (automatically):
   http://github.com/xolox/vim-lua-ftplugin/commit/5466b62
lua.zip 0.6.6 2011-06-14 7.0 Peter Odding • Move static user completion data to separate auto-load script:
   http://github.com/xolox/vim-lua-ftplugin/commit/3aafd93
> • Several bug fixes and support for function signatures:
  
http://github.com/xolox/vim-lua-ftplugin/commit/79a5476
> • Highlight syntax errors to make them stand out:
  
http://github.com/xolox/vim-lua-ftplugin/commit/9e42b06
> • Improve omni completion: support for keywords, less clutter:
  
http://github.com/xolox/vim-lua-ftplugin/commit/bfd5701
lua.zip 0.6.2 2011-06-14 7.0 Peter Odding • Completion of module names after typing require(':
   http://github.com/xolox/vim-lua-ftplugin/commit/ffaf36b
lua.zip 0.6.1 2011-06-14 7.0 Peter Odding • Refactor search path handling, use Lua Interface for Vim when available:
   http://github.com/xolox/vim-lua-ftplugin/commit/6d68f3d
lua.zip 0.6 2011-06-14 7.0 Peter Odding • Link to release on vim.org, support automatic update using GLVS plug-in:
   http://github.com/xolox/vim-lua-ftplugin/commit/9d68e7b
> • Support for omni completion by searching package.path and package.cpath:
  
http://github.com/xolox/vim-lua-ftplugin/commit/6ee6a69
lua.zip 0.5.6 2011-06-14 7.0 Peter Odding Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github