[
  {
    "path": ".gitignore",
    "content": "doc/tags\n"
  },
  {
    "path": "INSTALL.md",
    "content": "*Please note that the vim-lua-ftplugin plug-in requires my vim-misc plug-in which is separately distributed.*\n\nUnzip the most recent ZIP archives of the [vim-lua-ftplugin] [download-lua-ftplugin] and [vim-misc] [download-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).\n\nIf you prefer you can also use [Pathogen] [pathogen], [Vundle] [vundle] or a similar tool to install & update the [vim-lua-ftplugin] [github-lua-ftplugin] and [vim-misc] [github-misc] plug-ins using a local clone of the git repository.\n\n\n[download-lua-ftplugin]: http://peterodding.com/code/vim/downloads/lua-ftplugin.zip\n[download-misc]: http://peterodding.com/code/vim/downloads/misc.zip\n[github-lua-ftplugin]: http://github.com/xolox/vim-lua-ftplugin\n[github-misc]: http://github.com/xolox/vim-misc\n[pathogen]: http://www.vim.org/scripts/script.php?script_id=2332\n[vundle]: https://github.com/gmarik/vundle\n"
  },
  {
    "path": "README.md",
    "content": "# Lua file type plug-in for the Vim text editor\n\nThe [Lua][lua] file type plug-in for [Vim][vim] makes it easier to work with Lua source code in Vim by providing the following features:\n\n * The ['includeexpr'][inex] option is set so that the [gf][gf] (go to file) mapping knows how to resolve Lua module names using [package.path][pp]\n\n * The ['include'][inc] option is set so that Vim follows [dofile()][dof], [loadfile()][lof] and [require()][req] calls when looking for identifiers in included files (this works together with the ['includeexpr'][inex] option)\n\n * 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`\n\n * `K` (normal mode) and `<F1>` (insert mode) on a Lua function or 'method' call will try to open the relevant documentation in the [Lua Reference for Vim][lrv]\n\n * The ['completefunc'][cfu] option is set to allow completion of Lua 5.2 keywords, global variables and library members using Control-X Control-U\n\n * 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\n\n![Screenshot of omni completion](http://peterodding.com/code/vim/lua-ftplugin/screenshots/omni-completion.png)\n\n * Several [text-objects][tob] are defined so you can jump between blocks and functions\n\n * 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`)\n\n## Installation\n\n*Please note that the vim-lua-ftplugin plug-in requires my vim-misc plug-in which is separately distributed.*\n\nUnzip the most recent ZIP archives of the [vim-lua-ftplugin] [download-lua-ftplugin] and [vim-misc] [download-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).\n\nIf you prefer you can also use [Pathogen] [pathogen], [Vundle] [vundle] or a similar tool to install & update the [vim-lua-ftplugin] [github-lua-ftplugin] and [vim-misc] [github-misc] plug-ins using a local clone of the git repository.\n\nNow try it out: Edit a Lua script and try any of the features documented above.\n\nNote 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][shell] plug-in which includes a [DLL][dll] that works around this issue. Once you've installed both plug-ins it should work out of the box!\n\n## Options\n\nThe Lua file type plug-in handles options as follows: First it looks at buffer local variables, then it looks at global variables and if neither exists a default is chosen. This means you can change how the plug-in works for individual buffers. For example to change the location of the Lua compiler used to check the syntax:\n\n    \" This sets the default value for all buffers.\n    :let g:lua_compiler_name = '/usr/local/bin/luac'\n\n    \" This is how you change the value for one buffer.\n    :let b:lua_compiler_name = '/usr/local/bin/lualint'\n\n### The `lua_path` option\n\nThis option contains the value of `package.path` as a string. You shouldn't need to change this because the plug-in is aware of [$LUA_PATH][pp] and if that isn't set the plug-in will run a Lua interpreter to get the value of [package.path][pp].\n\n### The `lua_check_syntax` option\n\nWhen you write a Lua script to disk the plug-in automatically runs the Lua compiler to check for syntax errors. To disable this behavior you can set this option to false (0):\n\n    let g:lua_check_syntax = 0\n\nYou can manually check the syntax using the `:CheckSyntax` command.\n\n### The `lua_check_globals` option\n\nWhen you write a Lua script to disk the plug-in automatically runs the Lua compiler to check for undefined global variables. To disable this behavior you can set this option to false (0):\n\n    let g:lua_check_globals = 0\n\nYou can manually check the globals using the `:CheckGlobals` command.\n\n### The `lua_interpreter_path` option\n\nThe name or path of the Lua interpreter used to evaluate Lua scripts used by the plug-in (for example the script that checks for undefined global variables, see `:LuaCheckGlobals`).\n\n### The `lua_internal` option\n\nIf you're running a version of Vim that supports the Lua Interface for Vim (see [if_lua.txt][if_lua.txt]) then all Lua code evaluated by the Lua file type plug-in is evaluated using the Lua Interface for Vim. If the Lua Interface for Vim is not available the plug-in falls back to using an external Lua interpreter. You can set this to false (0) to force the plug-in to use an external Lua interpreter.\n\n### The `lua_compiler_name` option\n\nThe name or path of the Lua compiler used to check for syntax errors (defaults to `luac`). You can set this option to run the Lua compiler from a non-standard location or to run a dedicated syntax checker like [lualint][ll].\n\n### The `lua_compiler_args` option\n\nThe argument(s) required by the compiler or syntax checker (defaults to `-p`).\n\n### The `lua_error_format` option\n\nIf you use a dedicated syntax checker you may need to change this option to reflect the format of the messages printed by the syntax checker.\n\n### The `lua_complete_keywords` option\n\nTo disable completion of keywords you can set this option to false (0).\n\n### The `lua_complete_globals` option\n\nTo disable completion of global functions you can set this option to false (0).\n\n### The `lua_complete_library` option\n\nTo disable completion of library functions you can set this option to false (0).\n\n### The `lua_complete_dynamic` option\n\nWhen you type a dot after a word the Lua file type plug-in will automatically start completion. To disable this behavior you can set this option to false (0).\n\n### The `lua_complete_omni` option\n\nThis option is disabled by default for two reasons:\n\n * The omni completion support works by enumerating and loading all installed modules. **If module loading has side effects this can have unintended consequences!**\n * Because all modules installed on the system are loaded, collecting the completion candidates can be slow. After the first run the completion candidates are cached so this will only bother you once (until you restart Vim).\n\nIf you want to use the omni completion despite the warnings above, execute the following command:\n\n    :let g:lua_complete_omni = 1\n\nNow when you type Control-X Control-O Vim will hang for a moment, after which you should be presented with an enormous list of completion candidates :-)\n\n### The `lua_omni_blacklist` option\n\nIf you like the omni completion mode but certain modules are giving you trouble (for example crashing Vim) you can exclude such modules from being loaded by the omni completion. You can do so by setting `lua_omni_blacklist` to a list of strings containing Vim regular expression patterns. The patterns are combined as follows:\n\n    \" Here's the black list:\n    let g:lua_omni_blacklist = ['pl\\.strict', 'lgi\\..']\n\n    \" Here's the resulting regular expression pattern:\n    '^\\(pl\\.strict\\|lgi\\..\\)$'\n\nThe example above prevents the module `pl.strict` and all modules with the prefix `lgi.` from being loaded.\n\n### The `lua_safe_omni_modules` option\n\nTo track down modules that cause side effects while loading, setting\n\n    :let g:lua_safe_omni_modules = 1\n\nrestricts the modules to be loaded to the standard Lua modules - which should be safe to load - and provides a list of modules that would have been loaded if this option was not set via the `:messages` command. With this list, the `lua_omni_blacklist` can be iteratively refined to exclude offending modules from omni completion module loading.\n\nNote that the ['verbose'] [] option has to be set to 1 or higher for the list to be recorded.\n\n### The `lua_define_completefunc` option\n\nBy default the Lua file type plug-in sets the ['completefunc'] [] option so that Vim can complete Lua keywords, global variables and library members using Control-X Control-U. If you don't want the 'completefunc' option to be changed by the plug-in, you can set this option to zero (false) in your [vimrc script] [vimrc]:\n\n    :let g:lua_define_completefunc = 0\n\n### The `lua_define_omnifunc` option\n\nBy default the Lua file type plug-in sets the ['omnifunc'] [] option so that Vim can complete the names of all Lua modules installed on the local system. If you don't want the 'omnifunc' option to be changed by the plug-in, you can set this option to zero (false) in your [vimrc script] [vimrc]:\n\n    :let g:lua_define_omnifunc = 0\n\n### The `lua_define_completion_mappings` option\n\nBy default the Lua file type plug-in defines insert mode mappings so that the plug-in is called whenever you type a single quote, double quote or a dot inside a Lua buffer. This enables context sensitive completion. If you don't like these mappings you can set this option to zero (false). In that case the mappings will not be defined.\n\n## Commands\n\n### The `:LuaCheckSyntax` command\n\nCheck the current file for syntax errors using the Lua compiler. This command is executed automatically when you write a Lua script to disk (i.e. when you save your changes) unless `lua_check_syntax` is false.\n\n### The `:LuaCheckGlobals` command\n\nCheck the current file for undefined global variables. This command is executed automatically when you write a Lua script to disk (i.e. when you save your changes) unless `lua_check_globals` is false or syntax errors were detected.\n\n## Contact\n\nIf you have questions, bug reports, suggestions, etc. the author can be contacted at <peter@peterodding.com>. The latest version is available at <http://peterodding.com/code/vim/lua-ftplugin> and <http://github.com/xolox/vim-lua-ftplugin>. If you like this plug-in please vote for it on [Vim Online][script].\n\n## License\n\nThis software is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).  \n© 2014 Peter Odding &lt;<peter@peterodding.com>&gt;.\n\nThanks go out to everyone who has helped to improve the Lua file type plug-in for Vim (whether through pull requests, bug reports or personal e-mails).\n\n\n['verbose']: http://vimdoc.sourceforge.net/htmldoc/options.html#'verbose'\n['completefunc']: http://vimdoc.sourceforge.net/htmldoc/options.html#'completefunc'\n['omnifunc']: http://vimdoc.sourceforge.net/htmldoc/options.html#'omnifunc'\n[cfu]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27completefunc%27\n[dll]: http://en.wikipedia.org/wiki/Dynamic-link_library\n[dof]: http://www.lua.org/manual/5.2/manual.html#pdf-dofile\n[download-lua-ftplugin]: http://peterodding.com/code/vim/downloads/lua-ftplugin.zip\n[download-misc]: http://peterodding.com/code/vim/downloads/misc.zip\n[gf]: http://vimdoc.sourceforge.net/htmldoc/editing.html#gf\n[github-lua-ftplugin]: http://github.com/xolox/vim-lua-ftplugin\n[github-misc]: http://github.com/xolox/vim-misc\n[if_lua.txt]: http://vimdoc.sourceforge.net/htmldoc/if_lua.html#if_lua.txt\n[inc]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27include%27\n[inex]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27includeexpr%27\n[ll]: http://lua-users.org/wiki/LuaLint\n[lof]: http://www.lua.org/manual/5.2/manual.html#pdf-loadfile\n[lrv]: http://www.vim.org/scripts/script.php?script_id=1291\n[lua]: http://www.lua.org/\n[mit]: http://vimdoc.sourceforge.net/htmldoc/usr_05.html#matchit-install\n[ofu]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27omnifunc%27\n[pathogen]: http://www.vim.org/scripts/script.php?script_id=2332\n[pp]: http://www.lua.org/manual/5.2/manual.html#pdf-package.path\n[req]: http://www.lua.org/manual/5.2/manual.html#pdf-require\n[script]: http://www.vim.org/scripts/script.php?script_id=3625\n[shell]: http://peterodding.com/code/vim/shell/\n[tob]: http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects\n[vim]: http://www.vim.org/\n[vimrc]: http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc\n[vundle]: https://github.com/gmarik/vundle\n"
  },
  {
    "path": "TODO.md",
    "content": "# To-do list for the Lua file type plug-in for Vim\n\n * `BufReadCmd` automatic command that converts `*.luac` files to byte code listings :-)\n * Make the globals checking smarter so it can be enabled by default without being too much of a nuisance?\n\n## Smarter completion\n\nMake completion smarter by supporting function arguments:\n\n * `collectgarbage()`: stop, restart, collect, count, step, setpause, setstepmul\n * `io.open()`, `io.popen()`: r, w, a, r+, w+, a+\n * `file:read()`: \\*n, \\*a, \\*l\n * `file:seek()`: set, cur, end\n * `file:setvbuf()`: no, full, line\n * `debug.sethook()`: c, r, l\n"
  },
  {
    "path": "addon-info.json",
    "content": "{\"vim_script_nr\": 3625, \"dependencies\": {\"vim-misc\": {}}, \"homepage\": \"http://peterodding.com/code/vim/lua-ftplugin\", \"name\": \"vim-lua-ftplugin\"}"
  },
  {
    "path": "autoload/xolox/lua.vim",
    "content": "\" Vim auto-load script\n\" Author: Peter Odding <peter@peterodding.com>\n\" Last Change: September 14, 2014\n\" URL: http://peterodding.com/code/vim/lua-ftplugin\n\nlet g:xolox#lua#version = '0.8'\nlet s:miscdir = expand('<sfile>:p:h:h:h') . '/misc/lua-ftplugin'\nlet s:omnicomplete_script = s:miscdir . '/omnicomplete.lua'\nlet s:globals_script = s:miscdir . '/globals.lua'\n\nfunction! xolox#lua#includeexpr(fname) \" {{{1\n  \" Search module path for matching Lua scripts.\n  let module = substitute(a:fname, '\\.', '/', 'g')\n  for template in xolox#lua#getsearchpath('$LUA_PATH', 'package.path')\n    let expanded = substitute(template, '?', module, 'g')\n    call xolox#misc#msg#debug(\"lua.vim %s: Expanded %s -> %s\", g:xolox#lua#version, template, expanded)\n    if filereadable(expanded)\n      call xolox#misc#msg#debug(\"lua.vim %s: Matched existing file %s\", g:xolox#lua#version, expanded)\n      return expanded\n    endif\n  endfor\n  \" Default to given name.\n  return a:fname\nendfunction\n\nfunction! xolox#lua#getsearchpath(envvar, luavar) \" {{{1\n  let path = ''\n  if xolox#misc#option#get('lua_internal', has('lua'))\n    \" Try to get the search path using the Lua Interface for Vim.\n    try\n      redir => path\n      execute 'silent lua print(' . a:luavar . ')'\n      redir END\n      call xolox#misc#msg#debug(\"lua.vim %s: Got %s from Lua Interface for Vim\", g:xolox#lua#version, a:luavar)\n    catch\n      redir END\n    endtry\n  endif\n  if empty(path)\n    let path = eval(a:envvar)\n    if !empty(path)\n      call xolox#misc#msg#debug(\"lua.vim %s: Got %s from %s\", g:xolox#lua#version, a:luavar, a:envvar)\n    else\n      try\n        let interpreter = xolox#misc#escape#shell(xolox#misc#option#get('lua_interpreter_path', 'lua'))\n        let command = printf('%s -e \"io.write(%s)\"', interpreter, a:luavar)\n        let path = xolox#misc#os#exec({'command': command})['stdout'][0]\n        call xolox#misc#msg#debug(\"lua.vim %s: Got %s from external Lua interpreter\", g:xolox#lua#version, a:luavar)\n      catch\n        call xolox#misc#msg#warn(\"lua.vim %s: Failed to get %s from external Lua interpreter: %s\", g:xolox#lua#version, a:luavar, v:exception)\n      endtry\n    endif\n  endif\n  return split(xolox#misc#str#trim(path), ';')\nendfunction\n\nfunction! xolox#lua#autocheck() \" {{{1\n  if &filetype == 'lua'\n    let success = 1\n    if xolox#misc#option#get('lua_check_syntax', 1)\n      let success = xolox#lua#checksyntax()\n    endif\n    if xolox#misc#option#get('lua_check_globals', 0) && success\n      call xolox#lua#checkglobals(0)\n    endif\n  endif\nendfunction\n\nfunction! xolox#lua#checksyntax() \" {{{1\n  let compiler_name = xolox#misc#option#get('lua_compiler_name', 'luac')\n  let compiler_args = xolox#misc#option#get('lua_compiler_args', '-p')\n  let error_format = xolox#misc#option#get('lua_error_format', 'luac: %f:%l: %m')\n  if !executable(compiler_name)\n    let message = \"lua.vim %s: The configured Lua compiler\"\n    let message .= \" doesn't seem to be available! I'm disabling\"\n    let message .= \" automatic syntax checking for Lua scripts.\"\n    let g:lua_check_syntax = 0\n    call xolox#misc#msg#warn(message, g:xolox#lua#version)\n    return 1\n  endif\n  \" Check for errors using my shell.vim plug-in so that executing\n  \" luac.exe on Windows doesn't pop up the nasty console window.\n  call xolox#misc#msg#debug(\"lua.vim %s: Checking syntax of '%s' using Lua compiler ..\", g:xolox#lua#version, expand('%'))\n  let command = [compiler_name, compiler_args, xolox#misc#escape#shell(expand('%'))]\n  let output = xolox#misc#os#exec({'command': join(command) . ' 2>&1', 'check': 0})['stdout']\n  if empty(output)\n    \" Clear location list.\n    call setloclist(winnr(), [], 'r')\n    lclose\n    return 1\n  endif\n  \" Save the errors to a file we can load with :lgetfile.\n  let errorfile = tempname()\n  call writefile(output, errorfile)\n  \" Remember the original values of these options.\n  let mp_save = &makeprg\n  let efm_save = &errorformat\n  try\n    \" Temporarily change the options.\n    let &makeprg = compiler_name\n    let &errorformat = error_format\n    let winnr = winnr()\n    let filename = expand('%:t')\n    execute 'lgetfile' fnameescape(errorfile)\n    lwindow\n    if winnr() != winnr\n      let message = ['Syntax errors reported by', compiler_name, compiler_args, filename]\n      let w:quickfix_title = join(message)\n      execute winnr . 'wincmd w'\n    endif\n    call s:highlighterrors()\n  finally\n    \" Restore the options.\n    let &makeprg = mp_save\n    let &errorformat = efm_save\n    \" Cleanup the file with errors.\n    call delete(errorfile)\n  endtry\n  return 0\nendfunction\n\nfunction! s:highlighterrors()\n  let hlgroup = 'luaCompilerError'\n  if !hlexists(hlgroup)\n    execute 'highlight def link' hlgroup 'Error'\n  else\n    call clearmatches()\n  endif\n  let pattern = '^\\%%%il.*\\n\\?'\n  for entry in getqflist()\n    call matchadd(hlgroup, '\\%' . min([entry.lnum, line('$')]) . 'l')\n    call xolox#misc#msg#warn(\"lua.vim %s: Syntax error on line %i: %s\", g:xolox#lua#version, entry.lnum, entry.text)\n  endfor\nendfunction\n\nfunction! xolox#lua#checkglobals(verbose) \" {{{1\n  let curfile = expand('%')\n  call xolox#misc#msg#debug(\"lua.vim %s: Checking for undefined globals in '%s' using '%s' ..\", g:xolox#lua#version, curfile, s:globals_script)\n  let compiler = xolox#misc#option#get('lua_compiler_name', 'luac')\n  let output = xolox#lua#dofile(s:globals_script, [compiler, curfile, a:verbose])\n  call setqflist(eval('[' . join(output, ',') . ']'), 'r')\n  cwindow\nendfunction\n\nfunction! xolox#lua#help() \" {{{1\n  \" Get the expression under the cursor.\n  let cword = ''\n  try\n    let isk_save = &isk\n    set iskeyword+=.,:\n    let cword = expand('<cword>')\n  finally\n    let &isk = isk_save\n  endtry\n  if cword != ''\n    try\n      call s:lookupmethod(cword, 'lrv-string.', '\\v<(byte|char|dump|g?find|format|len|lower|g?match|rep|reverse|g?sub|upper)>')\n      call s:lookupmethod(cword, 'lrv-file:', '\\v<(close|flush|lines|read|seek|setvbuf|write)>')\n      call s:lookupmethod(cword, '', '\\v:\\w+>')\n      call s:lookuptopic('lrv-' . cword)\n      call s:lookuptopic(cword)\n      call s:lookuptopic('luarefvim.txt')\n      help\n    catch /^done$/\n      return\n    endtry\n  endif\n  help\nendfunction\n\nfunction! s:lookupmethod(cword, prefix, pattern)\n  let method = matchstr(a:cword, a:pattern)\n  if method != ''\n    let identifier = a:prefix . method\n    call xolox#misc#msg#debug(\"lua.vim %s: Translating '%s' -> '%s'\", g:xolox#lua#version, a:cword, identifier)\n    call s:lookuptopic(identifier)\n  endif\nendfunction\n\nfunction! s:lookuptopic(topic)\n  try\n    \" Lookup the given topic in Vim's help files.\n    execute 'help' escape(a:topic, ' []*?')\n    \" Abuse exceptions for non local jumping.\n    throw 'done'\n  catch /^Vim\\%((\\a\\+)\\)\\=:E149/\n    \" Ignore E149: Sorry, no help for <keyword>.\n    return\n  endtry\nendfunction\n\nfunction! xolox#lua#jumpblock(forward) \" {{{1\n  let start = '\\<\\%(for\\|function\\|if\\|repeat\\|while\\)\\>'\n  let middle = '\\<\\%(elseif\\|else\\)\\>'\n  let end = '\\<\\%(end\\|until\\)\\>'\n  let flags = a:forward ? '' : 'b'\n  return searchpair(start, middle, end, flags, '!xolox#lua#tokeniscode()')\nendfunction\n\nfunction! s:getfunscope()\n  let firstpos = [0, 1, 1, 0]\n  let lastpos = getpos('$')\n  while search('\\<function\\>', 'bW')\n    if xolox#lua#tokeniscode()\n      let firstpos = getpos('.')\n      break\n    endif\n  endwhile\n  if xolox#lua#jumpblock(1)\n    let lastpos = getpos('.')\n  endif\n  return [firstpos, lastpos]\nendfunction\n\nfunction! xolox#lua#jumpthisfunc(forward) \" {{{1\n  let cpos = [line('.'), col('.')]\n  let fpos = [1, 1]\n  let lpos = [line('$'), 1]\n  while search('\\<function\\>', a:forward ? 'W' : 'bW')\n    if xolox#lua#tokeniscode()\n      break\n    endif\n  endwhile\n  let cursorline = line('.')\n  let [firstpos, lastpos] = s:getfunscope()\n  if cursorline == (a:forward ? lastpos : firstpos)[1]\n    \" make the mapping repeatable (line wise at least)\n    execute a:forward ? (lastpos[1] + 1) : (firstpos[1] - 1)\n    let [firstpos, lastpos] = s:getfunscope()\n  endif\n  call setpos('.', a:forward ? lastpos : firstpos)\nendfunction\n\nfunction! xolox#lua#jumpotherfunc(forward) \" {{{1\n  let view = winsaveview()\n  \" jump to the start/end of the function\n  call xolox#lua#jumpthisfunc(a:forward)\n  \" search for the previous/next function\n  while search('\\<function\\>', a:forward ? 'W' : 'bW')\n    \" ignore strings and comments containing 'function'\n    if xolox#lua#tokeniscode()\n      return 1\n    endif\n  endwhile\n  call winrestview(view)\nendfunction\n\nfunction! xolox#lua#tokeniscode() \" {{{1\n  return s:getsynid(0) !~? 'string\\|comment'\nendfunction\n\nfunction! s:getsynid(transparent)\n  let id = synID(line('.'), col('.') - 1, 1)\n  if a:transparent\n    let id = synIDtrans(id)\n  endif\n  return synIDattr(id, 'name')\nendfunction\n\nif exists('loaded_matchit')\n\n  function! xolox#lua#matchit() \" {{{1\n    let cword = expand('<cword>')\n    if cword == 'end'\n      let s = ['function', 'if', 'for', 'while']\n      let e = ['end']\n      unlet! b:match_skip\n    elseif cword =~ '^\\(function\\|return\\|yield\\)$'\n      let s = ['function']\n      let m = ['return', 'yield']\n      let e = ['end']\n      let b:match_skip = \"xolox#lua#matchit_ignore('^luaCond$')\"\n      let b:match_skip .= \" || (expand('<cword>') == 'end' && xolox#lua#matchit_ignore('^luaStatement$'))\"\n    elseif cword =~ '^\\(for\\|in\\|while\\|do\\|repeat\\|until\\|break\\)$'\n      let s = ['for', 'repeat', 'while']\n      let m = ['break']\n      let e = ['end', 'until']\n      let b:match_skip = \"xolox#lua#matchit_ignore('^\\\\(luaCond\\\\|luaFunction\\\\)$')\"\n    elseif cword =~ '\\(if\\|then\\|elseif\\|else\\)$'\n      let s = ['if']\n      let m = ['elseif', 'else']\n      let e = ['end']\n      let b:match_skip = \"xolox#lua#matchit_ignore('^\\\\(luaFunction\\\\|luaStatement\\\\)$')\"\n    else\n      let s = ['for', 'function', 'if', 'repeat', 'while']\n      let m = ['break', 'elseif', 'else', 'return']\n      let e = ['eend', 'until']\n      unlet! b:match_skip\n    endif\n    let p = '\\<\\(' . join(s, '\\|') . '\\)\\>'\n    if exists('m')\n      let p .=  ':\\<\\(' . join(m, '\\|') . '\\)\\>'\n    endif\n    return p . ':\\<\\(' . join(e, '\\|') . '\\)\\>'\n  endfunction\n\n  function! xolox#lua#matchit_ignore(ignored) \" {{{1\n    let word = expand('<cword>')\n    let type = s:getsynid(0)\n    return type =~? a:ignored || type =~? 'string\\|comment'\n  endfunction\n\nendif\n\nfunction! xolox#lua#completefunc(init, base) \" {{{1\n  if a:init\n    return s:getcompletionprefix()\n  endif\n  let items = []\n  if xolox#misc#option#get('lua_complete_keywords', 1)\n    call extend(items, g:xolox#lua_data#keywords)\n  endif\n  if xolox#misc#option#get('lua_complete_globals', 1)\n    call extend(items, g:xolox#lua_data#globals)\n  endif\n  if xolox#misc#option#get('lua_complete_library', 1)\n    call extend(items, g:xolox#lua_data#library)\n  endif\n  let pattern = '^' . xolox#misc#escape#pattern(a:base)\n  call filter(items, 'v:val.word =~ pattern')\n  return s:addsignatures(items)\nendfunction\n\nfunction! s:getcompletionprefix()\n  let text_before_cursor = strpart(getline('.'), 0, col('.') - 1)\n  let completion_prefix = matchstr(text_before_cursor, '\\w\\+\\.\\?\\w*$')\n  call xolox#misc#msg#debug(\"lua.vim %s: Matched completion prefix %s.\", g:xolox#lua#version, string(completion_prefix))\n  return col('.') - len(completion_prefix) - 1\nendfunction\n\nfunction! s:addsignatures(entries)\n  for entry in a:entries\n    let signature = xolox#lua#getsignature(entry.word)\n    if !empty(signature) && signature != entry.word\n      let entry.menu = signature\n    endif\n  endfor\n  return a:entries\nendfunction\n\nfunction! xolox#lua#getsignature(identifier) \" {{{1\n  let identifier = substitute(a:identifier, '()$', '', '')\n  let signature = get(g:xolox#lua_data#signatures, identifier, '')\n  if empty(signature)\n    let signature = get(g:xolox#lua_data#signatures, 'string.' . identifier, '')\n  endif\n  if empty(signature)\n    let signature = get(g:xolox#lua_data#signatures, 'file:' . identifier, '')\n  endif\n  return signature\nendfunction\n\nfunction! xolox#lua#omnifunc(init, base) \" {{{1\n  if a:init\n    return s:getcompletionprefix()\n  elseif !xolox#misc#option#get('lua_complete_omni', 0)\n    throw printf(\"lua.vim %s: omni completion needs to be explicitly enabled, see the readme!\", g:xolox#lua#version)\n  endif\n  if !exists('s:omnifunc_modules')\n    let s:omnifunc_modules = xolox#lua#getomnimodules()\n  endif\n  if !exists('s:omnifunc_variables')\n    let s:omnifunc_variables = xolox#lua#getomnivariables(s:omnifunc_modules)\n    call s:addsignatures(s:omnifunc_variables)\n  endif\n  \" FIXME When you type \"require'\" without a space in between\n  \" the getline('.') call below returns an empty string?!\n  let pattern = '^' . xolox#misc#escape#pattern(a:base)\n  if getline('.') =~ 'require[^''\"]*[''\"]'\n    let candidates = filter(copy(s:omnifunc_modules), 'v:val =~ pattern')\n    call xolox#misc#msg#debug(\"lua.vim %s: Completing %i module name(s).\", g:xolox#lua#version, len(candidates))\n  elseif a:base == ''\n    let candidates = s:omnifunc_variables\n    call xolox#misc#msg#debug(\"lua.vim %s: Completing all %i omni variable(s).\", g:xolox#lua#version, len(candidates))\n  else\n    let candidates = filter(copy(s:omnifunc_variables), 'v:val.word =~ pattern')\n    call xolox#misc#msg#debug(\"lua.vim %s: Completing %i omni variable(s) matching filter.\", g:xolox#lua#version, len(candidates))\n  endif\n  return candidates\nendfunction\n\nfunction! xolox#lua#getomnimodules() \" {{{1\n  let starttime = xolox#misc#timer#start()\n  \" Find all source & binary modules available on the module search path.\n  let modulemap = {}\n  let luapath = xolox#lua#getsearchpath('$LUA_PATH', 'package.path')\n  let luacpath = xolox#lua#getsearchpath('$LUA_CPATH', 'package.cpath')\n  for searchpath in [luapath, luacpath]\n    call s:expandsearchpath(searchpath, modulemap)\n  endfor\n  let modules = keys(modulemap)\n  \" Always include the standard library modules.\n  call extend(modules, ['bit32', 'coroutine', 'debug', 'io', 'math', 'os', 'package', 'string', 'table'])\n  call sort(modules, 1)\n  let blacklist = xolox#misc#option#get('lua_omni_blacklist', [])\n  let pattern = printf('^\\(%s\\)$', join(blacklist, '\\|'))\n  call filter(modules, 'v:val !~ pattern')\n  let msg = \"lua.vim %s: Collected %i module names for omni completion in %s.\"\n  call xolox#misc#timer#stop(msg, g:xolox#lua#version, len(modules), starttime)\n  if xolox#misc#option#get('lua_safe_omni_modules', 0) == 1\n    call xolox#misc#msg#debug(\"lua.vim %s: Loading Lua standard library modules only because g:lua_safe_omni_modules is set.\", g:xolox#lua#version)\n    call xolox#misc#msg#debug(\"lua.vim %s: Would have loaded the following modules: %s\", g:xolox#lua#version, join(modules, ' '))\n    return ['bit32', 'coroutine', 'debug', 'io', 'math', 'os', 'package', 'string', 'table']\n  endif\n  return modules\nendfunction\n\nfunction! s:expandsearchpath(searchpath, modules)\n  \" Collect the names of all installed modules by traversing the search paths.\n  for template in a:searchpath\n    let components = split(template, '?')\n    if len(components) != 2\n      let msg = \"lua.vim %s: Failed to parse search path entry: %s\"\n      call xolox#misc#msg#debug(msg, g:xolox#lua#version, template)\n      continue\n    endif\n    let [prefix, suffix] = components\n    \" XXX Never recursively search current working directory because\n    \" it might be arbitrarily deep, e.g. when working directory is /\n    if prefix =~ '^.[\\\\/]$'\n      let msg = \"lua.vim %s: Refusing to expand dangerous search path entry: %s\"\n      call xolox#misc#msg#debug(msg, g:xolox#lua#version, template)\n      continue\n    endif\n    let pattern = substitute(template, '?', '**/*', 'g')\n    call xolox#misc#msg#debug(\"lua.vim %s: Transformed %s -> %s\", g:xolox#lua#version, template, pattern)\n    let msg = \"lua.vim %s: Failed to convert pathname to module name, %s doesn't match! (%s: '%s', pathname: '%s')\"\n    for pathname in split(glob(pattern), \"\\n\")\n      if pathname[0 : len(prefix)-1] != prefix\n        \" Validate prefix of resulting pathname.\n        call xolox#misc#msg#warn(msg, g:xolox#lua#version, 'prefix', 'prefix', prefix, pathname)\n      elseif pathname[-len(suffix) : -1] != suffix\n        \" Validate suffix of resulting pathname.\n        call xolox#misc#msg#warn(msg, g:xolox#lua#version, 'suffix', 'suffix', suffix, pathname)\n      elseif pathname !~ 'test'\n        let relative = pathname[len(prefix) : -len(suffix)-1]\n        let modulename = substitute(relative, '[\\\\/]\\+', '.', 'g')\n        let a:modules[modulename] = 1\n        call xolox#misc#msg#debug(\"lua.vim %s: Transformed '%s' -> '%s'\", g:xolox#lua#version, pathname, modulename)\n      endif\n    endfor\n  endfor\nendfunction\n\nfunction! xolox#lua#getomnivariables(modules) \" {{{1\n  let starttime = xolox#misc#timer#start()\n  let output = xolox#lua#dofile(s:omnicomplete_script, a:modules)\n  let variables = eval('[' . join(output, ',') . ']')\n  call sort(variables, 1)\n  let msg = \"lua.vim %s: Collected %i variables for omni completion in %s.\"\n  call xolox#misc#timer#stop(msg, g:xolox#lua#version, len(variables), starttime)\n  return variables\nendfunction\n\nfunction! xolox#lua#completedynamic(type) \" {{{1\n  if xolox#misc#option#get('lua_complete_dynamic', 1) && s:getsynid(1) !~? 'string\\|comment\\|keyword'\n    if (a:type == \"'\" || a:type == '\"')\n      let prefix = strpart(getline('.'), 0, col('.') - 1)\n      if xolox#misc#option#get('lua_complete_omni', 0) && prefix =~ '\\<require\\s*(\\?\\s*$'\n        return a:type . \"\\<C-x>\\<C-o>\"\n      elseif prefix =~ '\\<\\(dofile\\|loadfile\\|io\\.open\\|io\\.lines\\|os\\.remove\\)\\s*(\\?\\s*$'\n        return a:type . \"\\<C-x>\\<C-f>\"\n      endif\n    elseif a:type == '.'\n      let column = col('.') - 1\n      \" Gotcha: even though '.' is remapped it counts as a column?\n      if column && getline('.')[column - 1] =~ '\\w'\n        \" This results in \"Pattern not found\" when no completion candidates\n        \" are available, which is kind of annoying. But I don't know of an\n        \" alternative to :silent that can be used inside of <expr>\n        \" mappings?!\n        if xolox#misc#option#get('lua_complete_omni', 0)\n          return a:type . \"\\<C-x>\\<C-o>\"\n        else\n          return a:type . \"\\<C-x>\\<C-u>\"\n        endif\n      endif\n    endif\n  endif\n  return a:type\nendfunction\n\nfunction! xolox#lua#tweakoptions() \" {{{1\n  if &filetype == 'lua'\n    let s:completeopt_save = &cot\n    set completeopt+=longest\n  elseif exists('s:completeopt_save')\n    let &completeopt = s:completeopt_save\n  endif\nendfunction\n\nfunction! xolox#lua#dofile(pathname, arguments) \" {{{1\n  if xolox#misc#option#get('lua_internal', has('lua'))\n    \" Use the Lua Interface for Vim.\n    call xolox#misc#msg#debug(\"lua.vim %s: Running '%s' using Lua Interface for Vim ..\", g:xolox#lua#version, a:pathname)\n    redir => output\n    silent lua << EOL\n      local script = vim.eval('a:pathname')\n      local arguments = vim.eval('a:arguments')\n      if type(arguments) == 'userdata' then\n        -- At some point the Lua Interface for Vim started using userdata proxy\n        -- objects for Vim lists and dictionaries (refer to :help lua-list).\n        -- The Lua file type plug-in for Vim wasn't expecting this so broke\n        -- with errors like:\n        --\n        --  * bad argument #1 to 'insert' (table expected, got userdata)\n        --  * bad argument #1 to 'ipairs' (table expected, got userdata)\n        --\n        -- The switch to userdata makes sense but these userdata objects don't\n        -- behave like Lua tables at all (they're not intended to) which is bad\n        -- for us, so we translate the userdata objects back into proper Lua\n        -- tables (e.g. with one based indices).\n        local arguments_as_lua_table = {}\n        -- Userdata proxies for Vim lists start at index zero.\n        for i = 0, #arguments - 1 do\n          table.insert(arguments_as_lua_table, arguments[i])\n        end\n        arguments = arguments_as_lua_table\n      end\n      arguments[0] = script\n      arg = arguments\n      dofile(script)\nEOL\n    redir END\n    return split(output, \"\\n\")\n  else\n    \" Use the command line Lua interpreter.\n    call xolox#misc#msg#debug(\"lua.vim %s: Running '%s' using command line Lua interpreter ..\", g:xolox#lua#version, a:pathname)\n    let interpreter = xolox#misc#escape#shell(xolox#misc#option#get('lua_interpreter_path', 'lua'))\n    let pathname = xolox#misc#escape#shell(a:pathname)\n    let arguments = join(map(a:arguments, 'xolox#misc#escape#shell(v:val)'))\n    let command = printf('%s %s %s', interpreter, pathname, arguments)\n    return xolox#misc#os#exec({'command': command})['stdout']\n  endif\nendfunction\n\n\" vim: ts=2 sw=2 et\n"
  },
  {
    "path": "autoload/xolox/lua_data.vim",
    "content": "\" Vim auto-load script\n\" Author: Peter Odding <peter@peterodding.com>\n\" Last Change: July 6, 2014\n\" URL: http://peterodding.com/code/vim/lua-ftplugin\n\n\" This script contains static user completion data based on the Lua 5.2\n\" reference manual and implementation.\n\n\" Enable line continuation.\nlet s:cpo_save = &cpo\nset cpoptions-=C\n\n\" Keywords. {{{1\nlet g:xolox#lua_data#keywords = [\n      \\ { 'word': 'and', 'kind': 'k' },\n      \\ { 'word': 'break', 'kind': 'k' },\n      \\ { 'word': 'do', 'kind': 'k' },\n      \\ { 'word': 'else', 'kind': 'k' },\n      \\ { 'word': 'elseif', 'kind': 'k' },\n      \\ { 'word': 'end', 'kind': 'k' },\n      \\ { 'word': 'false', 'kind': 'k' },\n      \\ { 'word': 'for', 'kind': 'k' },\n      \\ { 'word': 'function', 'kind': 'k' },\n      \\ { 'word': 'goto', 'kind': 'k' },\n      \\ { 'word': 'if', 'kind': 'k' },\n      \\ { 'word': 'in', 'kind': 'k' },\n      \\ { 'word': 'local', 'kind': 'k' },\n      \\ { 'word': 'nil', 'kind': 'k' },\n      \\ { 'word': 'not', 'kind': 'k' },\n      \\ { 'word': 'or', 'kind': 'k' },\n      \\ { 'word': 'repeat', 'kind': 'k' },\n      \\ { 'word': 'return', 'kind': 'k' },\n      \\ { 'word': 'then', 'kind': 'k' },\n      \\ { 'word': 'true', 'kind': 'k' },\n      \\ { 'word': 'until', 'kind': 'k' },\n      \\ { 'word': 'while', 'kind': 'k' },\n      \\ ]\n\n\" Global variables. {{{1\nlet g:xolox#lua_data#globals = [\n      \\ { 'word': '_G', 'kind': 'v' },\n      \\ { 'word': '_ENV', 'kind': 'v' },\n      \\ { 'word': '_VERSION', 'kind': 'v' },\n      \\ { 'word': 'arg', 'kind': 'v' },\n      \\ { 'word': 'assert()', 'kind': 'f' },\n      \\ { 'word': 'bit32', 'kind': 'v' },\n      \\ { 'word': 'collectgarbage()', 'kind': 'f' },\n      \\ { 'word': 'coroutine', 'kind': 'v' },\n      \\ { 'word': 'debug', 'kind': 'v' },\n      \\ { 'word': 'dofile()', 'kind': 'f' },\n      \\ { 'word': 'error()', 'kind': 'f' },\n      \\ { 'word': 'getmetatable()', 'kind': 'f' },\n      \\ { 'word': 'io', 'kind': 'v' },\n      \\ { 'word': 'ipairs()', 'kind': 'f' },\n      \\ { 'word': 'load()', 'kind': 'f' },\n      \\ { 'word': 'loadfile()', 'kind': 'f' },\n      \\ { 'word': 'math', 'kind': 'v' },\n      \\ { 'word': 'next()', 'kind': 'f' },\n      \\ { 'word': 'os', 'kind': 'v' },\n      \\ { 'word': 'package', 'kind': 'v' },\n      \\ { 'word': 'pairs()', 'kind': 'f' },\n      \\ { 'word': 'pcall()', 'kind': 'f' },\n      \\ { 'word': 'print()', 'kind': 'f' },\n      \\ { 'word': 'rawequal()', 'kind': 'f' },\n      \\ { 'word': 'rawget()', 'kind': 'f' },\n      \\ { 'word': 'rawlen()', 'kind': 'f' },\n      \\ { 'word': 'rawset()', 'kind': 'f' },\n      \\ { 'word': 'require()', 'kind': 'f' },\n      \\ { 'word': 'select()', 'kind': 'f' },\n      \\ { 'word': 'setmetatable()', 'kind': 'f' },\n      \\ { 'word': 'string', 'kind': 'v' },\n      \\ { 'word': 'table', 'kind': 'v' },\n      \\ { 'word': 'tonumber()', 'kind': 'f' },\n      \\ { 'word': 'tostring()', 'kind': 'f' },\n      \\ { 'word': 'type()', 'kind': 'f' },\n      \\ { 'word': 'xpcall()', 'kind': 'f' },\n      \\ ]\n\n\" Standard library identifiers. {{{1\nlet g:xolox#lua_data#library = [\n      \\ { 'word': 'bit32.arshift()', 'kind': 'f'},\n      \\ { 'word': 'bit32.band()', 'kind': 'f' },\n      \\ { 'word': 'bit32.bnot()', 'kind': 'f' },\n      \\ { 'word': 'bit32.bor()', 'kind': 'f' },\n      \\ { 'word': 'bit32.btest()', 'kind': 'f' },\n      \\ { 'word': 'bit32.bxor()', 'kind': 'f' },\n      \\ { 'word': 'bit32.extract()', 'kind': 'f' },\n      \\ { 'word': 'bit32.replace()', 'kind': 'f' },\n      \\ { 'word': 'bit32.lrotate()', 'kind': 'f' },\n      \\ { 'word': 'bit32.lshift()', 'kind': 'f' },\n      \\ { 'word': 'bit32.rrotate()', 'kind': 'f' },\n      \\ { 'word': 'bit32.rshift()', 'kind': 'f' },\n      \\ { 'word': 'coroutine.create()', 'kind': 'f' },\n      \\ { 'word': 'coroutine.resume()', 'kind': 'f' },\n      \\ { 'word': 'coroutine.running()', 'kind': 'f' },\n      \\ { 'word': 'coroutine.status()', 'kind': 'f' },\n      \\ { 'word': 'coroutine.wrap()', 'kind': 'f' },\n      \\ { 'word': 'coroutine.yield()', 'kind': 'f' },\n      \\ { 'word': 'debug.debug()', 'kind': 'f' },\n      \\ { 'word': 'debug.gethook()', 'kind': 'f' },\n      \\ { 'word': 'debug.getinfo()', 'kind': 'f' },\n      \\ { 'word': 'debug.getlocal()', 'kind': 'f' },\n      \\ { 'word': 'debug.getmetatable()', 'kind': 'f' },\n      \\ { 'word': 'debug.getregistry()', 'kind': 'f' },\n      \\ { 'word': 'debug.getupvalue()', 'kind': 'f' },\n      \\ { 'word': 'debug.getuservalue()', 'kind': 'f' },\n      \\ { 'word': 'debug.sethook()', 'kind': 'f' },\n      \\ { 'word': 'debug.setlocal()', 'kind': 'f' },\n      \\ { 'word': 'debug.setmetatable()', 'kind': 'f' },\n      \\ { 'word': 'debug.setupvalue()', 'kind': 'f' },\n      \\ { 'word': 'debug.setuservalue()', 'kind': 'f' },\n      \\ { 'word': 'debug.traceback()', 'kind': 'f' },\n      \\ { 'word': 'debug.upvalueid()', 'kind': 'f' },\n      \\ { 'word': 'debug.upvaluejoin()', 'kind': 'f' },\n      \\ { 'word': 'io.close()', 'kind': 'f' },\n      \\ { 'word': 'io.flush()', 'kind': 'f' },\n      \\ { 'word': 'io.input()', 'kind': 'f' },\n      \\ { 'word': 'io.lines()', 'kind': 'f' },\n      \\ { 'word': 'io.open()', 'kind': 'f' },\n      \\ { 'word': 'io.output()', 'kind': 'f' },\n      \\ { 'word': 'io.popen()', 'kind': 'f' },\n      \\ { 'word': 'io.read()', 'kind': 'f' },\n      \\ { 'word': 'io.stderr', 'kind': 'm' },\n      \\ { 'word': 'io.stdin', 'kind': 'm' },\n      \\ { 'word': 'io.stdout', 'kind': 'm' },\n      \\ { 'word': 'io.tmpfile()', 'kind': 'f' },\n      \\ { 'word': 'io.type()', 'kind': 'f' },\n      \\ { 'word': 'io.write()', 'kind': 'f' },\n      \\ { 'word': 'math.abs()', 'kind': 'f' },\n      \\ { 'word': 'math.acos()', 'kind': 'f' },\n      \\ { 'word': 'math.asin()', 'kind': 'f' },\n      \\ { 'word': 'math.atan()', 'kind': 'f' },\n      \\ { 'word': 'math.atan2()', 'kind': 'f' },\n      \\ { 'word': 'math.ceil()', 'kind': 'f' },\n      \\ { 'word': 'math.cos()', 'kind': 'f' },\n      \\ { 'word': 'math.cosh()', 'kind': 'f' },\n      \\ { 'word': 'math.deg()', 'kind': 'f' },\n      \\ { 'word': 'math.exp()', 'kind': 'f' },\n      \\ { 'word': 'math.floor()', 'kind': 'f' },\n      \\ { 'word': 'math.fmod()', 'kind': 'f' },\n      \\ { 'word': 'math.frexp()', 'kind': 'f' },\n      \\ { 'word': 'math.huge', 'kind': 'm' },\n      \\ { 'word': 'math.ldexp()', 'kind': 'f' },\n      \\ { 'word': 'math.log()', 'kind': 'f' },\n      \\ { 'word': 'math.max()', 'kind': 'f' },\n      \\ { 'word': 'math.min()', 'kind': 'f' },\n      \\ { 'word': 'math.modf()', 'kind': 'f' },\n      \\ { 'word': 'math.pi', 'kind': 'm' },\n      \\ { 'word': 'math.pow()', 'kind': 'f' },\n      \\ { 'word': 'math.rad()', 'kind': 'f' },\n      \\ { 'word': 'math.random()', 'kind': 'f' },\n      \\ { 'word': 'math.randomseed()', 'kind': 'f' },\n      \\ { 'word': 'math.sin()', 'kind': 'f' },\n      \\ { 'word': 'math.sinh()', 'kind': 'f' },\n      \\ { 'word': 'math.sqrt()', 'kind': 'f' },\n      \\ { 'word': 'math.tan()', 'kind': 'f' },\n      \\ { 'word': 'math.tanh()', 'kind': 'f' },\n      \\ { 'word': 'os.clock()', 'kind': 'f' },\n      \\ { 'word': 'os.date()', 'kind': 'f' },\n      \\ { 'word': 'os.difftime()', 'kind': 'f' },\n      \\ { 'word': 'os.execute()', 'kind': 'f' },\n      \\ { 'word': 'os.exit()', 'kind': 'f' },\n      \\ { 'word': 'os.getenv()', 'kind': 'f' },\n      \\ { 'word': 'os.remove()', 'kind': 'f' },\n      \\ { 'word': 'os.rename()', 'kind': 'f' },\n      \\ { 'word': 'os.setlocale()', 'kind': 'f' },\n      \\ { 'word': 'os.time()', 'kind': 'f' },\n      \\ { 'word': 'os.tmpname()', 'kind': 'f' },\n      \\ { 'word': 'package.config', 'kind': 'm' },\n      \\ { 'word': 'package.cpath', 'kind': 'm' },\n      \\ { 'word': 'package.loaded', 'kind': 'm' },\n      \\ { 'word': 'package.loadlib()', 'kind': 'f' },\n      \\ { 'word': 'package.path', 'kind': 'm' },\n      \\ { 'word': 'package.preload', 'kind': 'm' },\n      \\ { 'word': 'package.searchers', 'kind': 'm' },\n      \\ { 'word': 'package.searchpath()', 'kind': 'f' },\n      \\ { 'word': 'string.byte()', 'kind': 'f' },\n      \\ { 'word': 'string.char()', 'kind': 'f' },\n      \\ { 'word': 'string.dump()', 'kind': 'f' },\n      \\ { 'word': 'string.find()', 'kind': 'f' },\n      \\ { 'word': 'string.format()', 'kind': 'f' },\n      \\ { 'word': 'string.gmatch()', 'kind': 'f' },\n      \\ { 'word': 'string.gsub()', 'kind': 'f' },\n      \\ { 'word': 'string.len()', 'kind': 'f' },\n      \\ { 'word': 'string.lower()', 'kind': 'f' },\n      \\ { 'word': 'string.match()', 'kind': 'f' },\n      \\ { 'word': 'string.rep()', 'kind': 'f' },\n      \\ { 'word': 'string.reverse()', 'kind': 'f' },\n      \\ { 'word': 'string.sub()', 'kind': 'f' },\n      \\ { 'word': 'string.upper()', 'kind': 'f' },\n      \\ { 'word': 'table.concat()', 'kind': 'f' },\n      \\ { 'word': 'table.insert()', 'kind': 'f' },\n      \\ { 'word': 'table.pack()', 'kind': 'f' },\n      \\ { 'word': 'table.remove()', 'kind': 'f' },\n      \\ { 'word': 'table.sort()', 'kind': 'f' },\n      \\ { 'word': 'table.unpack()', 'kind': 'f' },\n      \\ ]\n\n\" Function signatures. {{{1\n\" Sources:\n\"  - http://www.lua.org/manual/5.2/manual.html#6\n\"  - http://smherwig.org/lua/proc/index.html\n\"  - http://w3.impa.br/~diego/software/luasocket/reference.html\nlet g:xolox#lua_data#signatures = {\n      \\ 'assert': 'assert(v [, message])',\n      \\ 'collectgarbage': 'collectgarbage([opt [, arg]])',\n      \\ 'dofile': 'dofile([filename])',\n      \\ 'error': 'error(message [, level])',\n      \\ 'getmetatable': 'getmetatable(object)',\n      \\ 'ipairs': 'ipairs(t)',\n      \\ 'load': 'load(ld [, source [, mode [, env]]])',\n      \\ 'loadfile': 'loadfile([filename [, mode [, env]]])',\n      \\ 'next': 'next(table [, index])',\n      \\ 'pairs': 'pairs(t)',\n      \\ 'pcall': 'pcall(f [, arg1, ...])',\n      \\ 'print': 'print(...)',\n      \\ 'rawequal': 'rawequal(v1, v2)',\n      \\ 'rawget': 'rawget(table, index)',\n      \\ 'rawlen': 'rawlen(v)',\n      \\ 'rawset': 'rawset(table, index, value)',\n      \\ 'select': 'select(index, ...)',\n      \\ 'setmetatable': 'setmetatable(table, metatable)',\n      \\ 'tonumber': 'tonumber(e [, base])',\n      \\ 'tostring': 'tostring(v)',\n      \\ 'type': 'type(v)',\n      \\ 'xpcall': 'xpcall(f, msgh [, arg1, ...])',\n      \\ 'coroutine.create': 'coroutine.create(f)',\n      \\ 'coroutine.resume': 'coroutine.resume(co [, val1, ...])',\n      \\ 'coroutine.running': 'coroutine.running()',\n      \\ 'coroutine.status': 'coroutine.status(co)',\n      \\ 'coroutine.wrap': 'coroutine.wrap(f)',\n      \\ 'coroutine.yield': 'coroutine.yield(...)',\n      \\ 'require': 'require(modname)',\n      \\ 'package.loadlib': 'package.loadlib(libname, funcname)',\n      \\ 'package.searchpath': 'package.searchpath(name, path [, sep [, rep]])',\n      \\ 'string.byte': 'string.byte(s [, i [, j]])',\n      \\ 'string.char': 'string.char(...)',\n      \\ 'string.dump': 'string.dump(function)',\n      \\ 'string.find': 'string.find(s, pattern [, init [, plain]])',\n      \\ 'string.format': 'string.format(formatstring, ...)',\n      \\ 'string.gmatch': 'string.gmatch(s, pattern)',\n      \\ 'string.gsub': 'string.gsub(s, pattern, repl [, n])',\n      \\ 'string.len': 'string.len(s)',\n      \\ 'string.lower': 'string.lower(s)',\n      \\ 'string.match': 'string.match(s, pattern [, init])',\n      \\ 'string.rep': 'string.rep(s, n [, sep])',\n      \\ 'string.reverse': 'string.reverse(s)',\n      \\ 'string.sub': 'string.sub(s, i [, j])',\n      \\ 'string.upper': 'string.upper(s)',\n      \\ 'table.concat': 'table.concat(table [, sep [, i [, j]]])',\n      \\ 'table.insert': 'table.insert(table, [pos,] value)',\n      \\ 'table.pack': 'table.pack(...)',\n      \\ 'table.remove': 'table.remove(table [, pos])',\n      \\ 'table.sort': 'table.sort(table [, comp])',\n      \\ 'table.unpack': 'table.unpack(list [, i [, j]])',\n      \\ 'math.abs': 'math.abs(x)',\n      \\ 'math.acos': 'math.acos(x)',\n      \\ 'math.asin': 'math.asin(x)',\n      \\ 'math.atan': 'math.atan(x)',\n      \\ 'math.atan2': 'math.atan2(y, x)',\n      \\ 'math.ceil': 'math.ceil(x)',\n      \\ 'math.cos': 'math.cos(x)',\n      \\ 'math.cosh': 'math.cosh(x)',\n      \\ 'math.deg': 'math.deg(x)',\n      \\ 'math.exp': 'math.exp(x)',\n      \\ 'math.floor': 'math.floor(x)',\n      \\ 'math.fmod': 'math.fmod(x, y)',\n      \\ 'math.frexp': 'math.frexp(x)',\n      \\ 'math.ldexp': 'math.ldexp(m, e)',\n      \\ 'math.log': 'math.log(x [, base])',\n      \\ 'math.max': 'math.max(x, ...)',\n      \\ 'math.min': 'math.min(x, ...)',\n      \\ 'math.modf': 'math.modf(x)',\n      \\ 'math.pow': 'math.pow(x, y)',\n      \\ 'math.rad': 'math.rad(x)',\n      \\ 'math.random': 'math.random([m [, n]])',\n      \\ 'math.randomseed': 'math.randomseed(x)',\n      \\ 'math.sin': 'math.sin(x)',\n      \\ 'math.sinh': 'math.sinh(x)',\n      \\ 'math.sqrt': 'math.sqrt(x)',\n      \\ 'math.tan': 'math.tan(x)',\n      \\ 'math.tanh': 'math.tanh(x)',\n      \\ 'bit32.arshift': 'bit32.arshift(x, disp)',\n      \\ 'bit32.band': 'bit32.band(expr)',\n      \\ 'bit32.bnot': 'bit32.bnot(x)',\n      \\ 'bit32.bor': 'bit32.bor(expr)',\n      \\ 'bit32.btest': 'bit32.btest(expr)',\n      \\ 'bit32.bxor': 'bit32.bxor(expr)',\n      \\ 'bit32.extract': 'bit32.extract(n, field [, width])',\n      \\ 'bit32.replace': 'bit32.replace(n, v, field [, width])',\n      \\ 'bit32.lrotate': 'bit32.lrotate(x, disp)',\n      \\ 'bit32.lshift': 'bit32.lshift(x, disp)',\n      \\ 'bit32.rrotate': 'bit32.rrotate(x, disp)',\n      \\ 'bit32.rshift': 'bit32.rshift(x, disp)',\n      \\ 'io.close': 'io.close([file])',\n      \\ 'io.flush': 'io.flush()',\n      \\ 'io.input': 'io.input([file])',\n      \\ 'io.lines': 'io.lines([filename ...])',\n      \\ 'io.open': 'io.open(filename [, mode])',\n      \\ 'io.output': 'io.output([file])',\n      \\ 'io.popen': 'io.popen(prog [, mode])',\n      \\ 'io.read': 'io.read(...)',\n      \\ 'io.tmpfile': 'io.tmpfile()',\n      \\ 'io.type': 'io.type(obj)',\n      \\ 'io.write': 'io.write(...)',\n      \\ 'file:close': 'file:close()',\n      \\ 'file:flush': 'file:flush()',\n      \\ 'file:lines': 'file:lines(...)',\n      \\ 'file:read': 'file:read(...)',\n      \\ 'file:seek': 'file:seek([whence [, offset]])',\n      \\ 'file:setvbuf': 'file:setvbuf(mode [, size])',\n      \\ 'file:write': 'file:write(...)',\n      \\ 'os.clock': 'os.clock()',\n      \\ 'os.date': 'os.date([format [, time]])',\n      \\ 'os.difftime': 'os.difftime(t2, t1)',\n      \\ 'os.execute': 'os.execute([command])',\n      \\ 'os.exit': 'os.exit([code [, close])',\n      \\ 'os.getenv': 'os.getenv(varname)',\n      \\ 'os.remove': 'os.remove(filename)',\n      \\ 'os.rename': 'os.rename(oldname, newname)',\n      \\ 'os.setlocale': 'os.setlocale(locale [, category])',\n      \\ 'os.time': 'os.time([table])',\n      \\ 'os.tmpname': 'os.tmpname()',\n      \\ 'debug.debug': 'debug.debug()',\n      \\ 'debug.gethook': 'debug.gethook([thread])',\n      \\ 'debug.getinfo': 'debug.getinfo([thread,] f [, what])',\n      \\ 'debug.getlocal': 'debug.getlocal([thread,] f, local)',\n      \\ 'debug.getmetatable': 'debug.getmetatable(value)',\n      \\ 'debug.getregistry': 'debug.getregistry()',\n      \\ 'debug.getupvalue': 'debug.getupvalue(f, up)',\n      \\ 'debug.getuservalue': 'debug.getuservalue(u)',\n      \\ 'debug.sethook': 'debug.sethook([thread,] hook, mask [, count])',\n      \\ 'debug.setlocal': 'debug.setlocal([thread,] level, local, value)',\n      \\ 'debug.setmetatable': 'debug.setmetatable(value, table)',\n      \\ 'debug.setupvalue': 'debug.setupvalue(f, up, value)',\n      \\ 'debug.setuservalue': 'debug.setuservalue(udata, value)',\n      \\ 'debug.traceback': 'debug.traceback([thread,] [message [, level]])',\n      \\ 'debug.upvalueid': 'debug.upvalueid(f, n)',\n      \\ 'debug.upvaluejoin': 'debug.upvaluejoin(f1, n1, f2, n2)',\n      \\\n      \\ 'proc.kill': 'proc.kill(pid, [signal])',\n      \\ 'proc.killall': 'proc.killall(name, [signal])',\n      \\ 'proc.list': 'proc.list()',\n      \\ 'proc.pidof': 'proc.pidof(name)',\n      \\\n      \\ 'ftp.get': 'ftp.get(url)',\n      \\ 'ftp.put': 'ftp.put(url, content)',\n      \\ 'http.request': 'http.request(url [, body])',\n      \\ 'ltn12.filter.chain': 'ltn12.filter.chain(filter1, filter2 [, ... filterN])',\n      \\ 'ltn12.filter.cycle': 'ltn12.filter.cycle(low [, ctx, extra])',\n      \\ 'ltn12.pump.all': 'ltn12.pump.all(source, sink)',\n      \\ 'ltn12.pump.step': 'ltn12.pump.step(source, sink)',\n      \\ 'ltn12.sink.chain': 'ltn12.sink.chain(filter, sink)',\n      \\ 'ltn12.sink.error': 'ltn12.sink.error(message)',\n      \\ 'ltn12.sink.file': 'ltn12.sink.file(handle, message)',\n      \\ 'ltn12.sink.simplify': 'ltn12.sink.simplify(sink)',\n      \\ 'ltn12.sink.table': 'ltn12.sink.table([table])',\n      \\ 'ltn12.source.cat': 'ltn12.source.cat(source1 [, source2, ..., sourceN])',\n      \\ 'ltn12.source.chain': 'ltn12.source.chain(source, filter)',\n      \\ 'ltn12.source.empty': 'ltn12.source.empty()',\n      \\ 'ltn12.source.error': 'ltn12.source.error(message)',\n      \\ 'ltn12.source.file': 'ltn12.source.file(handle, message)',\n      \\ 'ltn12.source.simplify': 'ltn12.source.simplify(source)',\n      \\ 'ltn12.source.string': 'ltn12.source.string(string)',\n      \\ 'mime.decode': \"mime.decode('base64' or 'quoted-printable')\",\n      \\ 'mime.encode': \"mime.encode('base64' or 'quoted-printable' [, mode])\",\n      \\ 'mime.normalize': 'mime.normalize([marker])',\n      \\ 'mime.wrap': \"mime.wrap('base64' or 'quoted-printable' or 'text' [, length])\",\n      \\ 'smtp.message': 'smtp.message(mesgt)',\n      \\ 'socket.bind': 'socket.bind(address, port [, backlog])',\n      \\ 'socket.connect': 'socket.connect(address, port [, locaddr, locport])',\n      \\ 'socket.newtry': 'socket.newtry(finalizer)',\n      \\ 'socket.protect': 'socket.protect(func)',\n      \\ 'socket.select': 'socket.select(recvt, sendt [, timeout])',\n      \\ 'socket.sink': 'socket.sink(mode, socket)',\n      \\ 'socket.skip': 'socket.skip(d [, ret1, ret2 ... retN])',\n      \\ 'socket.sleep': 'socket.sleep(time)',\n      \\ 'socket.source': 'socket.source(mode, socket [, length])',\n      \\ 'socket.gettime': 'socket.gettime()',\n      \\ 'socket.dns.gethostname': 'socket.dns.gethostname()',\n      \\ 'socket.dns.tohostname': 'socket.dns.tohostname(address)',\n      \\ 'socket.dns.toip': 'socket.dns.toip(address)',\n      \\ 'socket.try': 'socket.try(ret1 [, ret2 ... retN])',\n      \\ 'url.absolute': 'url.absolute(base, relative)',\n      \\ 'url.build': 'url.build(parsed_url)',\n      \\ 'url.build_path': 'url.build_path(segments, unsafe)',\n      \\ 'url.escape': 'url.escape(content)',\n      \\ 'url.parse': 'url.parse(url, default)',\n      \\ 'url.parse_path': 'url.parse_path(path)',\n      \\ 'url.unescape': 'url.unescape(content)' }\n\n\" }}}\n\n\" Restore compatibility options.\nlet &cpo = s:cpo_save\nunlet s:cpo_save\n\n\" vim: ts=2 sw=2 et\n"
  },
  {
    "path": "doc/ft_lua.txt",
    "content": "*ft_lua.txt*  Lua file type plug-in for the Vim text editor\n\n===============================================================================\nContents ~\n\n 1. Introduction                                          |ft_lua-introduction|\n 2. Installation                                          |ft_lua-installation|\n 3. Options                                                    |ft_lua-options|\n  1. The |lua_path| option\n  2. The |lua_check_syntax| option\n  3. The |lua_check_globals| option\n  4. The |lua_interpreter_path| option\n  5. The |lua_internal| option\n  6. The |lua_compiler_name| option\n  7. The |lua_compiler_args| option\n  8. The |lua_error_format| option\n  9. The |lua_complete_keywords| option\n  10. The |lua_complete_globals| option\n  11. The |lua_complete_library| option\n  12. The |lua_complete_dynamic| option\n  13. The |lua_complete_omni| option\n  14. The |lua_omni_blacklist| option\n  15. The |lua_safe_omni_modules| option\n  16. The |lua_define_completefunc| option\n  17. The |lua_define_omnifunc| option\n  18. The |lua_define_completion_mappings| option\n 4. Commands                                                  |ft_lua-commands|\n  1. The |:LuaCheckSyntax| command\n  2. The |:LuaCheckGlobals| command\n 5. Contact                                                    |ft_lua-contact|\n 6. License                                                    |ft_lua-license|\n 7. References                                              |ft_lua-references|\n\n===============================================================================\n                                                          *ft_lua-introduction*\nIntroduction ~\n\nThe Lua [1] file type plug-in for Vim makes it easier to work with Lua source\ncode in Vim by providing the following features:\n\n- The |'includeexpr'| option is set so that the |gf| (go to file) mapping\n  knows how to resolve Lua module names using package.path [2]\n\n- The |'include'| option is set so that Vim follows dofile() [3], loadfile()\n  [4] and require() [5] calls when looking for identifiers in included files\n  (this works together with the |'includeexpr'| option)\n\n- An automatic command is installed that runs 'luac -p' when you save your\n  Lua scripts. If 'luac' reports any errors they are shown in the quick-fix\n  list and Vim jumps to the line of the first error. If 'luac -p' doesn't\n  report any errors a check for undefined global variables is performed by\n  parsing the output of 'luac -p -l'\n\n- 'K' (normal mode) and '<F1>' (insert mode) on a Lua function or 'method'\n  call will try to open the relevant documentation in the Lua Reference for\n  Vim [6]\n\n- The |'completefunc'| option is set to allow completion of Lua 5.2 keywords,\n  global variables and library members using Control-X Control-U\n\n- The |'omnifunc'| option is set to allow dynamic completion of the variables\n  defined in all modules installed on the system using Control-X Control-O,\n  however it needs to be explicitly enabled by setting the\n  |lua_complete_omni| option because this functionality may have undesired\n  side effects! When you invoke omni completion after typing \"require '\" or\n  \"require('\" you get completion of module names\n\n  Image: Screenshot of omni completion (see reference [7])\n\n- Several |text-objects| are defined so you can jump between blocks and\n  functions\n\n- A pretty nifty hack of the matchit plug-in (see |matchit-install|) is\n  included: When the cursor is on a 'function' or 'return' keyword the '%'\n  mapping cycles between the relevant keywords ('function', 'return', 'end'),\n  this also works for branching statements ('if', 'elseif', 'else', 'end')\n  and looping statements ('for', 'while', 'repeat', 'until', 'end')\n\n===============================================================================\n                                                          *ft_lua-installation*\nInstallation ~\n\n_Please note that the vim-lua-ftplugin plug-in requires my vim-misc plug-in\nwhich is separately distributed._\n\nUnzip the most recent ZIP archives of the vim-lua-ftplugin [8] and vim-misc [9]\nplug-ins inside your Vim profile directory (usually this is '~/.vim' on UNIX\nand '%USERPROFILE%\\vimfiles' on Windows), restart Vim and execute the command\n':helptags ~/.vim/doc' (use ':helptags ~\\vimfiles\\doc' instead on Windows).\n\nIf you prefer you can also use Pathogen [10], Vundle [11] or a similar tool to\ninstall & update the vim-lua-ftplugin [12] and vim-misc [13] plug-ins using a\nlocal clone of the git repository.\n\nNow try it out: Edit a Lua script and try any of the features documented above.\n\nNote that on Windows a command prompt window pops up whenever Lua is run as an\nexternal process. If this bothers you then you can install my shell.vim [14]\nplug-in which includes a DLL [15] that works around this issue. Once you've\ninstalled both plug-ins it should work out of the box!\n\n===============================================================================\n                                                               *ft_lua-options*\nOptions ~\n\nThe Lua file type plug-in handles options as follows: First it looks at buffer\nlocal variables, then it looks at global variables and if neither exists a\ndefault is chosen. This means you can change how the plug-in works for\nindividual buffers. For example to change the location of the Lua compiler used\nto check the syntax:\n>\n  \" This sets the default value for all buffers.\n  :let g:lua_compiler_name = '/usr/local/bin/luac'\n  \n  \" This is how you change the value for one buffer.\n  :let b:lua_compiler_name = '/usr/local/bin/lualint'\n<\n-------------------------------------------------------------------------------\nThe *lua_path* option\n\nThis option contains the value of 'package.path' as a string. You shouldn't\nneed to change this because the plug-in is aware of $LUA_PATH [2] and if that\nisn't set the plug-in will run a Lua interpreter to get the value of\npackage.path [2].\n\n-------------------------------------------------------------------------------\nThe *lua_check_syntax* option\n\nWhen you write a Lua script to disk the plug-in automatically runs the Lua\ncompiler to check for syntax errors. To disable this behavior you can set this\noption to false (0):\n>\n  let g:lua_check_syntax = 0\n<\nYou can manually check the syntax using the ':CheckSyntax' command.\n\n-------------------------------------------------------------------------------\nThe *lua_check_globals* option\n\nWhen you write a Lua script to disk the plug-in automatically runs the Lua\ncompiler to check for undefined global variables. To disable this behavior you\ncan set this option to false (0):\n>\n  let g:lua_check_globals = 0\n<\nYou can manually check the globals using the ':CheckGlobals' command.\n\n-------------------------------------------------------------------------------\nThe *lua_interpreter_path* option\n\nThe name or path of the Lua interpreter used to evaluate Lua scripts used by\nthe plug-in (for example the script that checks for undefined global variables,\nsee |:LuaCheckGlobals|).\n\n-------------------------------------------------------------------------------\nThe *lua_internal* option\n\nIf you're running a version of Vim that supports the Lua Interface for Vim (see\n|if_lua.txt|) then all Lua code evaluated by the Lua file type plug-in is\nevaluated using the Lua Interface for Vim. If the Lua Interface for Vim is not\navailable the plug-in falls back to using an external Lua interpreter. You can\nset this to false (0) to force the plug-in to use an external Lua interpreter.\n\n-------------------------------------------------------------------------------\nThe *lua_compiler_name* option\n\nThe name or path of the Lua compiler used to check for syntax errors (defaults\nto 'luac'). You can set this option to run the Lua compiler from a non-standard\nlocation or to run a dedicated syntax checker like lualint [16].\n\n-------------------------------------------------------------------------------\nThe *lua_compiler_args* option\n\nThe argument(s) required by the compiler or syntax checker (defaults to '-p').\n\n-------------------------------------------------------------------------------\nThe *lua_error_format* option\n\nIf you use a dedicated syntax checker you may need to change this option to\nreflect the format of the messages printed by the syntax checker.\n\n-------------------------------------------------------------------------------\nThe *lua_complete_keywords* option\n\nTo disable completion of keywords you can set this option to false (0).\n\n-------------------------------------------------------------------------------\nThe *lua_complete_globals* option\n\nTo disable completion of global functions you can set this option to false (0).\n\n-------------------------------------------------------------------------------\nThe *lua_complete_library* option\n\nTo disable completion of library functions you can set this option to false\n(0).\n\n-------------------------------------------------------------------------------\nThe *lua_complete_dynamic* option\n\nWhen you type a dot after a word the Lua file type plug-in will automatically\nstart completion. To disable this behavior you can set this option to false\n(0).\n\n-------------------------------------------------------------------------------\nThe *lua_complete_omni* option\n\nThis option is disabled by default for two reasons:\n\n- The omni completion support works by enumerating and loading all installed\n  modules. **If module loading has side effects this can have unintended\n  consequences!**\n\n- Because all modules installed on the system are loaded, collecting the\n  completion candidates can be slow. After the first run the completion\n  candidates are cached so this will only bother you once (until you restart\n  Vim).\n\nIf you want to use the omni completion despite the warnings above, execute the\nfollowing command:\n>\n  :let g:lua_complete_omni = 1\n<\nNow when you type Control-X Control-O Vim will hang for a moment, after which\nyou should be presented with an enormous list of completion candidates :-)\n\n-------------------------------------------------------------------------------\nThe *lua_omni_blacklist* option\n\nIf you like the omni completion mode but certain modules are giving you trouble\n(for example crashing Vim) you can exclude such modules from being loaded by\nthe omni completion. You can do so by setting |lua_omni_blacklist| to a list of\nstrings containing Vim regular expression patterns. The patterns are combined\nas follows:\n>\n  \" Here's the black list:\n  let g:lua_omni_blacklist = ['pl\\.strict', 'lgi\\..']\n  \n  \" Here's the resulting regular expression pattern:\n  '^\\(pl\\.strict\\|lgi\\..\\)$'\n<\nThe example above prevents the module 'pl.strict' and all modules with the\nprefix 'lgi.' from being loaded.\n\n-------------------------------------------------------------------------------\nThe *lua_safe_omni_modules* option\n\nTo track down modules that cause side effects while loading, setting\n>\n  :let g:lua_safe_omni_modules = 1\n<\nrestricts the modules to be loaded to the standard Lua modules - which should\nbe safe to load - and provides a list of modules that would have been loaded if\nthis option was not set via the ':messages' command. With this list, the\n|lua_omni_blacklist| can be iteratively refined to exclude offending modules\nfrom omni completion module loading.\n\nNote that the |'verbose'| option has to be set to 1 or higher for the list to\nbe recorded.\n\n-------------------------------------------------------------------------------\nThe *lua_define_completefunc* option\n\nBy default the Lua file type plug-in sets the |'completefunc'| option so that\nVim can complete Lua keywords, global variables and library members using\nControl-X Control-U. If you don't want the 'completefunc' option to be changed\nby the plug-in, you can set this option to zero (false) in your |vimrc| script:\n>\n  :let g:lua_define_completefunc = 0\n<\n-------------------------------------------------------------------------------\nThe *lua_define_omnifunc* option\n\nBy default the Lua file type plug-in sets the |'omnifunc'| option so that Vim\ncan complete the names of all Lua modules installed on the local system. If you\ndon't want the 'omnifunc' option to be changed by the plug-in, you can set this\noption to zero (false) in your |vimrc| script:\n>\n  :let g:lua_define_omnifunc = 0\n<\n-------------------------------------------------------------------------------\nThe *lua_define_completion_mappings* option\n\nBy default the Lua file type plug-in defines insert mode mappings so that the\nplug-in is called whenever you type a single quote, double quote or a dot\ninside a Lua buffer. This enables context sensitive completion. If you don't\nlike these mappings you can set this option to zero (false). In that case the\nmappings will not be defined.\n\n===============================================================================\n                                                              *ft_lua-commands*\nCommands ~\n\n-------------------------------------------------------------------------------\nThe *:LuaCheckSyntax* command\n\nCheck the current file for syntax errors using the Lua compiler. This command\nis executed automatically when you write a Lua script to disk (i.e. when you\nsave your changes) unless |lua_check_syntax| is false.\n\n-------------------------------------------------------------------------------\nThe *:LuaCheckGlobals* command\n\nCheck the current file for undefined global variables. This command is executed\nautomatically when you write a Lua script to disk (i.e. when you save your\nchanges) unless |lua_check_globals| is false or syntax errors were detected.\n\n===============================================================================\n                                                               *ft_lua-contact*\nContact ~\n\nIf you have questions, bug reports, suggestions, etc. the author can be\ncontacted at peter@peterodding.com. The latest version is available at\nhttp://peterodding.com/code/vim/lua-ftplugin and http://github.com/xolox/vim-\nlua-ftplugin. If you like this plug-in please vote for it on Vim Online [17].\n\n===============================================================================\n                                                               *ft_lua-license*\nLicense ~\n\nThis software is licensed under the MIT license [18]. ÂŠ 2014 Peter Odding\n<peter@peterodding.com>.\n\nThanks go out to everyone who has helped to improve the Lua file type plug-in\nfor Vim (whether through pull requests, bug reports or personal e-mails).\n\n===============================================================================\n                                                            *ft_lua-references*\nReferences ~\n\n[1] http://www.lua.org/\n[2] http://www.lua.org/manual/5.2/manual.html#pdf-package.path\n[3] http://www.lua.org/manual/5.2/manual.html#pdf-dofile\n[4] http://www.lua.org/manual/5.2/manual.html#pdf-loadfile\n[5] http://www.lua.org/manual/5.2/manual.html#pdf-require\n[6] http://www.vim.org/scripts/script.php?script_id=1291\n[7] http://peterodding.com/code/vim/lua-ftplugin/screenshots/omni-completion.png\n[8] http://peterodding.com/code/vim/downloads/lua-ftplugin.zip\n[9] http://peterodding.com/code/vim/downloads/misc.zip\n[10] http://www.vim.org/scripts/script.php?script_id=2332\n[11] https://github.com/gmarik/vundle\n[12] http://github.com/xolox/vim-lua-ftplugin\n[13] http://github.com/xolox/vim-misc\n[14] http://peterodding.com/code/vim/shell/\n[15] http://en.wikipedia.org/wiki/Dynamic-link_library\n[16] http://lua-users.org/wiki/LuaLint\n[17] http://www.vim.org/scripts/script.php?script_id=3625\n[18] http://en.wikipedia.org/wiki/MIT_License\n\nvim: ft=help\n"
  },
  {
    "path": "ftplugin/lua.vim",
    "content": "\" Vim file type plug-in\n\" Language: Lua 5.2\n\" Author: Peter Odding <peter@peterodding.com>\n\" Last Change: June 17, 2014\n\" URL: http://peterodding.com/code/vim/lua-ftplugin\n\nif exists('b:did_ftplugin')\n  finish\nelse\n  let b:did_ftplugin = 1\nendif\n\n\" A list of commands that undo buffer local changes made below.\nlet s:undo_ftplugin = []\n\n\" Set comment (formatting) related options. {{{1\nsetlocal fo-=t fo+=c fo+=r fo+=o fo+=q fo+=l\nsetlocal cms=--%s com=s:--[[,m:\\ ,e:]],:--\ncall add(s:undo_ftplugin, 'setlocal fo< cms< com<')\n\n\" Tell Vim how to follow dofile(), loadfile() and require() calls. {{{1\nlet &l:include = '\\v<((do|load)file|require)[^''\"]*[''\"]\\zs[^''\"]+'\nlet &l:includeexpr = 'xolox#lua#includeexpr(v:fname)'\ncall add(s:undo_ftplugin, 'setlocal inc< inex<')\n\n\" Enable completion of Lua keywords, globals and library members. {{{1\nif xolox#misc#option#get('lua_define_completefunc', 1)\n  setlocal completefunc=xolox#lua#completefunc\n  call add(s:undo_ftplugin, 'setlocal completefunc<')\nendif\n\n\" Enable dynamic completion by searching \"package.path\" and \"package.cpath\". {{{1\nif xolox#misc#option#get('lua_define_omnifunc', 1)\n  setlocal omnifunc=xolox#lua#omnifunc\n  call add(s:undo_ftplugin, 'setlocal omnifunc<')\nendif\n\n\" Set a filename filter for the Windows file open/save dialogs. {{{1\nif has('gui_win32') && !exists('b:browsefilter')\n  let b:browsefilter = \"Lua Files (*.lua)\\t*.lua\\nAll Files (*.*)\\t*.*\\n\"\n  call add(s:undo_ftplugin, 'unlet! b:browsefilter')\nendif\n\n\" Define a buffer local command to manually check the syntax.\ncommand! -bar -buffer CheckSyntax call xolox#lua#checksyntax()\ncall add(s:undo_ftplugin, 'delcommand CheckSyntax')\n\n\" Define a buffer local command to manually check for global variables.\ncommand! -bar -bang -buffer CheckGlobals call xolox#lua#checkglobals(<q-bang> == '!')\ncall add(s:undo_ftplugin, 'delcommand CheckGlobals')\n\n\" Define mappings for context-sensitive help using Lua Reference for Vim. {{{1\nimap <buffer> <F1> <C-o>:call xolox#lua#help()<Cr>\nnmap <buffer> <F1>      :call xolox#lua#help()<Cr>\nnmap <buffer> K         :call xolox#lua#help()<Cr>\ncall add(s:undo_ftplugin, 'iunmap <buffer> <F1>')\ncall add(s:undo_ftplugin, 'nunmap <buffer> <F1>')\ncall add(s:undo_ftplugin, 'nunmap <buffer> K')\n\n\" Define custom text objects to navigate Lua source code. {{{1\nnoremap <buffer> <silent> [{ m':call xolox#lua#jumpblock(0)<Cr>\nnoremap <buffer> <silent> ]} m':call xolox#lua#jumpblock(1)<Cr>\nnoremap <buffer> <silent> [[ m':call xolox#lua#jumpthisfunc(0)<Cr>\nnoremap <buffer> <silent> ][ m':call xolox#lua#jumpthisfunc(1)<Cr>\nnoremap <buffer> <silent> [] m':call xolox#lua#jumpotherfunc(0)<Cr>\nnoremap <buffer> <silent> ]] m':call xolox#lua#jumpotherfunc(1)<Cr>\ncall add(s:undo_ftplugin, 'unmap <buffer> [{')\ncall add(s:undo_ftplugin, 'unmap <buffer> ]}')\ncall add(s:undo_ftplugin, 'unmap <buffer> [[')\ncall add(s:undo_ftplugin, 'unmap <buffer> ][')\ncall add(s:undo_ftplugin, 'unmap <buffer> []')\ncall add(s:undo_ftplugin, 'unmap <buffer> ]]')\n\n\" Enable extended matching with \"%\" using the \"matchit\" plug-in. {{{1\nif exists('loaded_matchit')\n  let b:match_ignorecase = 0\n  let b:match_words = 'xolox#lua#matchit()'\n  call add(s:undo_ftplugin, 'unlet! b:match_ignorecase b:match_words b:match_skip')\nendif\n\n\" Enable dynamic completion on typing \"require('\" or \"variable.\"? {{{1\nif xolox#misc#option#get('lua_define_completion_mappings', 1)\n  inoremap <buffer> <silent> <expr> . xolox#lua#completedynamic('.')\n  call add(s:undo_ftplugin, 'iunmap <buffer> .')\n  inoremap <buffer> <silent> <expr> ' xolox#lua#completedynamic(\"'\")\n  call add(s:undo_ftplugin, \"iunmap <buffer> '\")\n  inoremap <buffer> <silent> <expr> \" xolox#lua#completedynamic('\"')\n  call add(s:undo_ftplugin, 'iunmap <buffer> \"')\nendif\n\n\" Enable tool tips with function signatures? {{{1\nif has('balloon_eval')\n  setlocal ballooneval balloonexpr=xolox#lua#getsignature(v:beval_text)\n  call add(s:undo_ftplugin, 'setlocal ballooneval< balloonexpr<')\nendif\n\n\" }}}1\n\n\" Let Vim know how to disable the plug-in.\ncall map(s:undo_ftplugin, \"'execute ' . string(v:val)\")\nlet b:undo_ftplugin = join(s:undo_ftplugin, ' | ')\nunlet s:undo_ftplugin\n\n\" vim: ts=2 sw=2 et\n"
  },
  {
    "path": "misc/lua-ftplugin/complete.lua",
    "content": "#!/usr/bin/env lua\n\n--[[\n\nAuthor: Peter Odding <peter@peterodding.com>\nLast Change: July 6, 2014\nURL: http://peterodding.com/code/vim/lua-ftplugin\n\nThis Lua script prints a few hundred lines of Vim script to standard output.\nThese lines are used by my Lua file type plug-in for the Vim text editor to\nprovide completion of Lua keywords, globals and library identifiers.\n\n]]\n\nlocal indent = '      \\\\ '\n\nlocal function sorted(input)\n  local keys = {}\n  for key in pairs(input) do table.insert(keys, key) end\n  table.sort(keys)\n  local index = 1\n  return function()\n    local key = keys[index]\n    index = index + 1\n    return key, input[key]\n  end\nend\n\nlocal keywords = {\n  ['and'] = true, ['break'] = true, ['do'] = true, ['else'] = true,\n  ['elseif'] = true, ['end'] = true, ['false'] = true, ['for'] = true,\n  ['function'] = true, ['goto'] = true, ['if'] = true, ['in'] = true,\n  ['local'] = true, ['nil'] = true, ['not'] = true, ['or'] = true,\n  ['repeat'] = true, ['return'] = true, ['then'] = true, ['true'] = true,\n  ['until'] = true, ['while'] = true,\n}\n\nio.write '\" Keywords. {{{1\\n'\nio.write 'let g:xolox#lua_data#keywords = [\\n'\nfor keyword in sorted(keywords) do\n  io.write(indent, (\"{ 'word': '%s', 'kind': 'k' },\\n\"):format(keyword))\nend\nio.write(indent, ']\\n\\n')\n\nlocal function identifier(value)\n  -- TODO This pattern does *not* match identifiers outside of the C locale\n  local pattern = '^[A-Za-z_][A-Za-z_0-9]*$'\n  return type(value) == 'string' and value:find(pattern) and not keywords[value]\nend\n\nlocal globals = {}\nlocal libraries = {}\n\nfor global, value in pairs(_G) do\n  if identifier(global) then\n    globals[global .. (type(value) == 'function' and '()' or '')] = type(value) == 'function' and 'f' or 'v'\n    if type(value) == 'table' and value ~= _G then\n      for member, value in pairs(value) do\n        if identifier(member) then\n          member = global .. '.' .. member\n          libraries[member .. (type(value) == 'function' and '()' or '')] = type(value) == 'function' and 'f' or 'm'\n        end\n      end\n    end\n  end\nend\n\nio.write '\" Global variables. {{{1\\n'\nio.write 'let g:xolox#lua_data#globals = [\\n'\nfor global, kind in sorted(globals) do\n  io.write(indent, (\"{ 'word': '%s', 'kind': '%s' },\\n\"):format(global, kind))\nend\nio.write(indent, ']\\n\\n')\n\nio.write '\" Standard library identifiers. {{{1\\n'\nio.write 'let g:xolox#lua_data#library = [\\n'\nfor member, kind in sorted(libraries) do\n  io.write(indent, (\"{ 'word': '%s', 'kind': '%s' },\\n\"):format(member, kind))\nend\nio.write(indent, ']\\n')\n\n-- vim: ts=2 sw=2 et\n"
  },
  {
    "path": "misc/lua-ftplugin/getsignatures.lua",
    "content": "#!/usr/bin/env lua\n\nlocal http = require 'socket.http'\nlocal webpage = http.request 'http://www.lua.org/manual/5.2/manual.html'\nlocal matches = {}\nfor anchor, signature in webpage:gmatch '<h3>%s*<a%s+name=\"pdf%-(.-)\">%s*<code>%s*(.-)%s*</code>%s*</a>%s*</h3>' do\n  if anchor ~= signature then\n    signature = signature:gsub('&middot;', '.')\n    signature = signature:gsub('%s+%(', '(')\n    table.insert(matches, string.format(\"'%s': '%s'\", anchor, signature))\n  end\nend\nlocal newline = '\\n    \\\\ '\nprint(string.format('let g:xolox#lua_data#signatures = {%s%s }', newline, table.concat(matches, ',' .. newline)))\n"
  },
  {
    "path": "misc/lua-ftplugin/globals.lua",
    "content": "#!/usr/bin/env lua\n\n-- Unpack arguments from Vim.\nlocal compiler = arg[1]\nlocal filename = arg[2]\nlocal verbose = tonumber(arg[3]) ~= 0\n\nlocal function quote(s)\n  return string.format('\"%s\"', (s:gsub('[\"\\\\]', '\\\\%0')))\nend\n\n-- Parse output of \"luac -l\" for GETGLOBAL/SETGLOBAL instructions.\nlocal command = string.format('%s -p -l %s', quote(compiler), quote(filename))\nlocal compiler = io.popen(command)\nlocal matches = {}\nfor line in compiler:lines() do\n  local inst = line:match '%]%s+([GS]ETGLOBAL)'\n  if inst then\n    local lnum = tonumber(line:match '%[(%d+)%]') or 0\n    local varname = line:match '(%S+)$' or ''\n    if lnum > 0 and varname ~= '' then\n      matches[#matches + 1] = {inst=inst, lnum=lnum, varname=varname}\n    end\n  end\nend\n\n-- Sort matched globals by ascending line numbers.\ntable.sort(matches, function(a, b) return a.lnum < b.lnum end)\n\n-- Pass results to vim.\nlocal template = \"{'filename': '%s', 'lnum': %i, 'text': '%s %s global %s', 'type': '%s'}\"\nfor _, match in ipairs(matches) do\n  local read = match.inst == 'GETGLOBAL'\n  local operation = read and 'Read of' or 'Write to'\n  local status, severity = 'known', 'I'\n  local varname = match.varname\n  local value = _G[varname]\n  if value == nil then\n    status = 'unknown'\n    severity = read and 'E' or 'W'\n  elseif type(value) == 'function' then\n    varname = varname .. '()'\n  end\n  if severity == 'E' or severity == 'W' or verbose then\n    print(template:format(arg[1], match.lnum, operation, status, varname, severity))\n  end\nend\n"
  },
  {
    "path": "misc/lua-ftplugin/omnicomplete.lua",
    "content": "#!/usr/bin/env lua\n\n--[[\n\nAuthor: Peter Odding <peter@peterodding.com>\nLast Change: July 12, 2014\nURL: http://peterodding.com/code/vim/lua-ftplugin\n\nThis Lua script is executed by the Lua file type plug-in for Vim to provide\ndynamic completion of function names defined by installed Lua modules. This\nworks by expanding package.path and package.cpath in Vim script, loading every\nmodule found on the search path into this Lua script and then dumping the\nglobal state.\n\n]]\n\nlocal keywords = { ['and'] = true, ['break'] = true, ['do'] = true,\n  ['else'] = true, ['elseif'] = true, ['end'] = true, ['false'] = true,\n  ['for'] = true, ['function'] = true, ['goto'] = true, ['if'] = true, ['in'] = true,\n  ['local'] = true, ['nil'] = true, ['not'] = true, ['or'] = true,\n  ['repeat'] = true, ['return'] = true, ['then'] = true, ['true'] = true,\n  ['until'] = true, ['while'] = true }\n\nlocal function isident(s)\n  return type(s) == 'string' and s:find('^[A-Za-z_][A-Za-z_0-9]*$') and not keywords[s]\nend\n\nlocal function addmatch(word, kind, desc)\n  if not desc then\n    print(string.format(\"{'word':'%s','kind':'%s'}\", word, kind))\n  else\n    -- Make sure we generate valid Vim script expressions (this is probably\n    -- still not right).\n    desc = desc:gsub('\\n', '\\\\n')\n               :gsub('\\r', '\\\\r')\n               :gsub(\"'\", \"''\")\n    print(string.format(\"{'word':'%s','kind':'%s','menu':'%s'}\", word, kind, desc))\n  end\nend\n\nlocal function dump(table, path, cache)\n  local printed = false\n  for key, value in pairs(table) do\n    if isident(key) then\n      local path = path and (path .. '.' .. key) or key\n      local vtype = type(value)\n      if vtype == 'function' then\n        printed = true\n        addmatch(path, 'f', path .. '()')\n      elseif vtype ~= 'table' then\n        printed = true\n        if vtype == 'boolean' or vtype == 'number' then\n          addmatch(path, 'v', tostring(value))\n        elseif vtype == 'string' then\n          if #value > 40 then\n            value = value:sub(1, 40) .. '..'\n          end\n          addmatch(path, 'v', value)\n        else\n          addmatch(path, 'v', nil)\n        end\n      elseif not cache[value] then\n        cache[value] = true\n        if dump(value, path, cache) then\n          printed = true\n        else\n          addmatch(path, 't', path .. '[]')\n        end\n      end\n    end\n  end\n  return printed\nend\n\n-- Add keywords to completion candidates.\nfor kw, _ in pairs(keywords) do\n  addmatch(kw, 'k', nil)\nend\n\nlocal function global_exists(name)\n  -- Don't crash on strict.lua.\n  return pcall(function()\n    if not _G[name] then\n      -- Simulate strict.lua when it isn't active so that we can stick to a\n      -- single code path.\n      error(\"variable \" .. name .. \" is not declared\")\n    end\n  end)\nend\n\n-- Load installed modules.\n-- XXX What if module loading has side effects? It shouldn't, but still...\nfor i = 1, #arg do\n  local modulename = arg[i]\n  local status, module = pcall(require, modulename)\n  if status and module and not global_exists(modulename) then\n    _G[modulename] = module\n  end\nend\n\n-- Generate completion candidates from global state.\nlocal cache = { [_G] = true, [package.loaded] = true }\nlocal output = {}\ndump(_G, nil, cache, output)\n"
  },
  {
    "path": "plugin/lua-ftplugin.vim",
    "content": "\" Vim file type plug-in\n\" Language: Lua 5.2\n\" Author: Peter Odding <peter@peterodding.com>\n\" Last Change: August 19, 2013\n\" URL: http://peterodding.com/code/vim/lua-ftplugin\n\n\" Support for automatic update using the GLVS plug-in.\n\" GetLatestVimScripts: 3625 1 :AutoInstall: lua.zip\n\n\" Don't source the plug-in when it's already been loaded or &compatible is set.\nif &cp || exists('g:loaded_lua_ftplugin')\n  finish\nendif\n\n\" Make sure vim-misc is installed.\ntry\n  \" The point of this code is to do something completely innocent while making\n  \" sure the vim-misc plug-in is installed. We specifically don't use Vim's\n  \" exists() function because it doesn't load auto-load scripts that haven't\n  \" already been loaded yet (last tested on Vim 7.3).\n  call type(g:xolox#misc#version)\ncatch\n  echomsg \"Warning: The vim-lua-ftplugin plug-in requires the vim-misc plug-in which seems not to be installed! For more information please review the installation instructions in the readme (also available on the homepage and on GitHub). The vim-lua-ftplugin plug-in will now be disabled.\"\n  let g:loaded_lua_ftplugin = 1\n  finish\nendtry\n\n\" Commands to manually check for syntax errors and undefined globals.\ncommand! -bar LuaCheckSyntax call xolox#lua#checksyntax()\ncommand! -bar -bang LuaCheckGlobals call xolox#lua#checkglobals(<q-bang> == '!')\n\n\" Automatic commands to check for syntax errors and/or undefined globals\n\" and change Vim's \"completeopt\" setting on the fly for Lua buffers.\naugroup PluginFileTypeLua\n  autocmd!\n  autocmd WinEnter * call xolox#lua#tweakoptions()\n  autocmd BufWritePost * call xolox#lua#autocheck()\naugroup END\n\n\" Make sure the plug-in is only loaded once.\nlet g:loaded_lua_ftplugin = 1\n\n\" vim: ts=2 sw=2 et\n"
  }
]