Home Explore Blog CI



neovim

35th chunk of `runtime/doc/lua.txt`
0b5841ca7c08efbfae8af6e08ba0889554785a56d3588e150000000100000fba
 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 (function item -> text) Function to format
                       an individual item from `items`. Defaults to
                       `tostring`.
                     • kind (string|nil) Arbitrary hint string indicating the
                       item shape. Plugins reimplementing `vim.ui.select` may
                       wish to use this to infer the structure or semantics of
                       `items`, or the context in which select() was called.
      • {on_choice}  (`fun(item: T?, idx: integer?)`) Called once the user
                     made a choice. `idx` is the 1-based index of `item`
                     within `items`. `nil` if the user aborted the dialog.


==============================================================================
Lua module: vim._extui                                            *vim._extui*

WARNING: This is an experimental interface intended to replace the message
grid in the TUI.

To enable the experimental UI (default opts shown): >lua
    require('vim._extui').enable({
     enable = true, -- Whether to enable or disable the UI.
     msg = { -- Options related to the message module.
       ---@type 'box'|'cmd' Type of window used to place messages, either in the
       ---cmdline or in a separate message box window with ephemeral messages.
       pos = 'cmd',
       box = { -- Options related to the message box window.
         timeout = 4000, -- Time a message is visible.
       },
     },
    })
<

There are four separate window types used by this interface:
• "cmd": The cmdline window; also used for 'showcmd', 'showmode', 'ruler', and
  messages if 'cmdheight' > 0.
• "box": The message box window; used for messages when 'cmdheight' == 0.
• "more": The more-prompt window; used for |:messages| and certain messages
  that should be shown in full.
• "prompt": The cmdline prompt window; used for prompt messages that expect
  user input.

These four windows are assigned the "cmdline", "msgbox", "msgmore" and
"msgprompt" 'filetype' respectively. Use a |FileType| autocommand to configure
any local options for these windows and their respective buffers.

Rather than a |hit-enter-prompt|, messages shown in the cmdline area that do
not fit are appended with a `[+x]` "spill" indicator, where `x` indicates the
spilled lines. To see the full message, the |g<| command can be used.



==============================================================================
Lua module: vim.filetype                                        *vim.filetype*

vim.filetype.add({filetypes})                             *vim.filetype.add()*
    Add new filetype mappings.

    Filetype mappings can be added either by extension or by filename (either
    the "tail" or the full file path). The full file path is checked first,
    followed by the file name. If a match is not found using the filename,
    then the filename is matched against the list of |lua-pattern|s (sorted by
    priority) until a match is found. Lastly, if pattern matching does

Title: Lua API: User Selection and Experimental UI for Messages
Summary
This section details the `vim.ui.select` function for prompting users to choose from a list of items. It also describes the experimental `vim._extui` module, which aims to replace the message grid in the TUI. This experimental interface includes four window types ('cmd', 'box', 'more', 'prompt') and can be enabled with `require('vim._extui').enable()`. Finally, it introduces the `vim.filetype.add()` function which allows adding new filetype mappings by extension or filename.