Home Explore Blog CI



neovim

34th chunk of `runtime/doc/lua.txt`
57b042e2a7a426227e5ffa893ec81cd5f2b7561f6c92f6460000000100000fc8
         *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}        (`table?`) Additional options. See |input()|
                      • prompt (string|nil) Text of the prompt
                      • default (string|nil) Default reply to the input
                      • completion (string|nil) Specifies type of completion
                        supported for input. Supported types are the same that
                        can be supplied to a user-defined command using the
                        "-complete=" argument. See |:command-completion|
                      • highlight (function) Function that will be used for
                        highlighting user inputs.
      • {on_confirm}  (`function`) ((input|nil) -> ()) Called once the user
                      confirms or abort the input. `input` is what the user
                      typed (it might be an empty string if nothing was
                      entered), or `nil` if the user aborted the dialog.

vim.ui.open({path}, {opt})                                     *vim.ui.open()*
    Opens `path` with the system default handler (macOS `open`, Windows
    `explorer.exe`, Linux `xdg-open`, …), or returns (but does not show) an
    error message on failure.

    Can also be invoked with `:Open`.                                  *:Open*

    Expands "~/" and environment variables in filesystem paths.

    Examples: >lua
        -- Asynchronous.
        vim.ui.open("https://neovim.io/")
        vim.ui.open("~/path/to/file")
        -- Use the "osurl" command to handle the path or URL.
        vim.ui.open("gh#neovim/neovim!29490", { cmd = { 'osurl' } })
        -- Synchronous (wait until the process exits).
        local cmd, err = vim.ui.open("$VIMRUNTIME")
        if cmd then
          cmd:wait()
        end
<

    Parameters: ~
      • {path}  (`string`) Path or URL to open
      • {opt}   (`{ cmd?: string[] }?`) Options
                • cmd string[]|nil Command used to open the path or URL.

    Return (multiple): ~
        (`vim.SystemObj?`) Command object, or nil if not found.
        (`string?`) Error message on failure, or nil on success.

    See also: ~
      • |vim.system()|

vim.ui.select({items}, {opts}, {on_choice})                  *vim.ui.select()*
    Prompts the user to pick from a list of items, allowing arbitrary
    (potentially asynchronous) work until `on_choice`.

    Example: >lua
        vim.ui.select({ 'tabs', 'spaces' }, {
            prompt = 'Select tabs or spaces:',
            format_item = function(item)
                return "I'd like to choose " .. item
            end,
        }, function(choice)
            if choice == 'spaces' then
                vim.o.expandtab = true
            else
                vim.o.expandtab = false
            end
        end)
<

    Parameters: ~
      • {items}      (`any[]`) Arbitrary items
      • {opts}       (`table`) Additional options
                     • prompt (string|nil) Text of the prompt. Defaults to
                       `Select one of:`
                     • format_item

Title: Lua API: URI to Filename Conversion, User Input and Selection
Summary
This section describes functions for converting URIs to filenames (`vim.uri_to_fname`) and prompting users for input (`vim.ui.input`). It also explains `vim.ui.open` for opening files or URLs with the system's default handler, and `vim.ui.select` for presenting users with a list of items to choose from.