end func_with_opts :luado if bp:match(line) then return "->\t". Local func_with_opts = function(opts) local will_do_foo = opts.foo local filename = opts.filename. "keyword"-style arguments with a single dictionary. In Lua, it is also possible (when only one argument is passed) to call theįunction without any parentheses. For example:Įxample_func(1) - = Result = - A is: 1 - B is: nilĪdditionally, if any extra parameters are passed, they are discarded Not supplied are automatically set to `nil`. In Lua, it's important to understand that any function arguments that are This way of calling a function is familiar to most scripting languages. Local example_func = function(a, b) print("A is: ", a) print("B is: ", b) endĮxample_func(1, 2) - = Result = - A is: 1 - B is: 2 Lua functions can be called in multiple ways. Particularly when looking at the documentation above. While Lua has a simple syntax, there are a few things to understand, Lua Syntax Information * lua-syntax-help* Is better to not have them in 'runtimepath' at all. Plugins using shell which will not work with paths containing semicolons it Skipping paths from 'runtimepath' which contain semicolons applies both to Paths from there you can set 'runtimepath' to trigger an update: Values of `package.path` or `package.cpath`. Although adjustments happen automatically, Nvim does not track current Paths when path is removed from 'runtimepath', adding paths when they areĪdded and reordering `package.path`/`package.cpath` content if 'runtimepath' New 'runtimepath' are prepended as described above. Remembered and removed at the next update, while all paths derived from the
#Lua table insert associative array update
To track 'runtimepath' updates, paths added at previous update are `/foo/bar,/xxx yyy/baz,/abc` ('runtimepath') New paths are prepended to the original `package.cpath`. In each variant `/lua` path segment is insertedĦ. Leaving only `/foo/bar` and `/abc`, in order.ĥ. Second one contains semicolon which is a paths separator so it is out, 'runtimepath' has three paths: `/foo/bar`, `/xxx yyy/baz` and `/abc`. Leaves `/?.so` and `/a?d/j/g.elf`, in this order.Ĥ. The suffix of `/def/?.so`, namely `/?.so` is not unique, as it’s the sameĪs the suffix of the first path from `package.path` (i.e. Question mark and preceding path separator.ģ. Order: parts of the path starting from the first path component containing `$LUA_CPATH`/`$LUA_INIT`) `package.cpath` containsĢ. initial (defined at compile-time or derived from 'runtimepath' contains `/foo/bar,/xxx yyy/baz,/abc`
`/lua/?/a` to each runtimepath, all unique `?`-containing suffixes of In this case, instead of appending `/lua/?.lua` and Similarly to `package.path`, modified directories from 'runtimepath' are alsoĪdded to `package.cpath`. `/lua/?/a` to each directory from 'runtimepath' (`/` is actually the `package.path` is adjusted by simply appending `/lua/?.lua` and Adjustment happens whenever 'runtimepath' isĬhanged. Nvim automatically adjusts `package.path` and `package.cpath` according toĮffective 'runtimepath' value.
Vimscript | plugin| s, with some extra features. See | lua-require| to understand how Nvimįinds and loads Lua modules. Then `require('foo')` loads "~/.config/nvim/lua/foo.lua", and Module conflicts are resolved by "last wins". A good overview of using Lua in neovim is given by "editor stdlib" (| functions| and Ex commands) and the | API|, all of which canīe used from Lua code.
Nvim includes a "standard library" | lua-stdlib| for Lua. The Lua 5.1 language is builtin and always available.