From 2257ade3dc2daab5ee12d27807c0b3bcf103cd29 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 26 Mar 2023 12:42:15 +0200 Subject: feat(lua): add `vim.loader` feat: new faster lua loader using byte-compilation --- runtime/doc/lua.txt | 47 +++++++++++++++++++++++++++++++++++++++++++++++ runtime/doc/news.txt | 4 ++++ 2 files changed, 51 insertions(+) (limited to 'runtime/doc') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 0bea2819c9..58522ac1f3 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -2024,6 +2024,53 @@ validate({opt}) *vim.validate()* • msg: (optional) error string if validation fails +============================================================================== +Lua module: loader *lua-loader* + +disable() *vim.loader.disable()* + Disables the experimental Lua module loader: + • removes the loaders + • adds the default Neovim loader + +enable() *vim.loader.enable()* + Enables the experimental Lua module loader: + • overrides loadfile + • adds the lua loader using the byte-compilation cache + • adds the libs loader + • removes the default Neovim loader + +find({modname}, {opts}) *vim.loader.find()* + Finds lua modules for the given module name. + + Parameters: ~ + • {modname} (string) Module name, or `"*"` to find the top-level + modules instead + • {opts} (table|nil) Options for finding a module: + • rtp: (boolean) Search for modname in the runtime path + (defaults to `true`) + • paths: (string[]) Extra paths to search for modname + (defaults to `{}`) + • patterns: (string[]) List of patterns to use when + searching for modules. A pattern is a string added to the + basename of the Lua module being searched. (defaults to + `{"/init.lua", ".lua"}`) + • all: (boolean) Return all matches instead of just the + first one (defaults to `false`) + + Return: ~ + (list) A list of results with the following properties: + • modpath: (string) the path to the module + • modname: (string) the name of the module + • stat: (table|nil) the fs_stat of the module path. Won't be returned + for `modname="*"` + +reset({path}) *vim.loader.reset()* + Resets the topmods cache for the path, or all the paths if path is nil. + + Parameters: ~ + • {path} string? path to reset + + ============================================================================== Lua module: uri *lua-uri* diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 20af29430a..890a033268 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -67,6 +67,10 @@ NEW FEATURES *news-features* The following new APIs or features were added. +• Added a new experimental |lua-loader| that byte-compiles and caches lua files. + To enable the new loader, add the following at the top of your |init.lua|: >lua + vim.loader.enable() + • Added |lua-version| for parsing and comparing version strings conforming to the semver specification. -- cgit