Home Explore Blog CI



neovim

33th chunk of `runtime/doc/lua.txt`
4210e5d2de95d00a99cf18ac85965f4b58198012b79e237a0000000100000fd2
 |loadfile()|
    • adds the Lua loader using the byte-compilation cache
    • adds the libs loader
    • removes the default Nvim loader

    Disable (`enable=false`):
    • removes the loaders
    • adds the default Nvim loader

    Parameters: ~
      • {enable}  (`boolean?`) true/nil to enable, false to disable

vim.loader.find({modname}, {opts})                         *vim.loader.find()*
    WARNING: This feature is experimental/unstable.

    Finds Lua modules for the given module name.

    Parameters: ~
      • {modname}  (`string`) Module name, or `"*"` to find the top-level
                   modules instead
      • {opts}     (`table?`) Options for finding a module:
                   • {rtp}? (`boolean`, default: `true`) Search for modname in
                     the runtime path.
                   • {paths}? (`string[]`, default: `{}`) Extra paths to
                     search for modname
                   • {patterns}? (`string[]`, default:
                     `{"/init.lua", ".lua"}`) List of patterns to use when
                     searching for modules. A pattern is a string added to the
                     basename of the Lua module being searched.
                   • {all}? (`boolean`, default: `false`) Search for all
                     matches.

    Return: ~
        (`table[]`) A list of objects with the following fields:
        • {modpath} (`string`) Path of the module
        • {modname} (`string`) Name of the module
        • {stat}? (`uv.fs_stat.result`) The fs_stat of the module path. Won't
          be returned for `modname="*"`

vim.loader.reset({path})                                  *vim.loader.reset()*
    WARNING: This feature is experimental/unstable.

    Resets the cache for the path, or all the paths if path is nil.

    Parameters: ~
      • {path}  (`string?`) path to reset


==============================================================================
Lua module: vim.uri                                                  *vim.uri*

vim.uri_decode({str})                                       *vim.uri_decode()*
    URI-decodes a string containing percent escapes.

    Parameters: ~
      • {str}  (`string`) string to decode

    Return: ~
        (`string`) decoded string

vim.uri_encode({str}, {rfc})                                *vim.uri_encode()*
    URI-encodes a string using percent escapes.

    Parameters: ~
      • {str}  (`string`) string to encode
      • {rfc}  (`"rfc2396"|"rfc2732"|"rfc3986"?`)

    Return: ~
        (`string`) encoded string

vim.uri_from_bufnr({bufnr})                             *vim.uri_from_bufnr()*
    Gets a URI from a bufnr.

    Parameters: ~
      • {bufnr}  (`integer`)

    Return: ~
        (`string`) URI

vim.uri_from_fname({path})                              *vim.uri_from_fname()*
    Gets a URI from a file path.

    Parameters: ~
      • {path}  (`string`) Path to file

    Return: ~
        (`string`) URI

vim.uri_to_bufnr({uri})                                   *vim.uri_to_bufnr()*
    Gets the buffer for a uri. Creates a new unloaded buffer if no buffer for
    the uri already exists.

    Parameters: ~
      • {uri}  (`string`)

    Return: ~
        (`integer`) bufnr

vim.uri_to_fname({uri})                                   *vim.uri_to_fname()*
    Gets a filename from a URI.

    Parameters: ~
      • {uri}  (`string`)

    Return: ~
        (`string`) filename or unchanged URI for non-file URIs


==============================================================================
Lua module: vim.ui                                                    *vim.ui*

vim.ui.input({opts}, {on_confirm})                            *vim.ui.input()*
    Prompts the user for input, allowing arbitrary (potentially asynchronous)
    work until `on_confirm`.

    Example: >lua
        vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, function(input)
            vim.o.shiftwidth = tonumber(input)
        end)
<

    Parameters: ~
      • {opts}

Title: Lua API: Module Loader Configuration, URI Encoding/Decoding, and User Input
Summary
This section covers `vim.loader` functions like `find` and `reset` that allow for module discovery and cache management. It details the `vim.uri` module for encoding/decoding URIs and converting between URIs, buffer numbers, and filenames. Finally, it introduces `vim.ui.input` for prompting users and executing code after input.