Home Explore Blog CI



neovim

14th chunk of `runtime/doc/lua.txt`
77d5d744bb66984dd0572826ee9629b2d557231e671c9f0c0000000100000fc6
 if conversion succeeds, `nil` otherwise.

vim.in_fast_event()                                      *vim.in_fast_event()*
    Returns true if the code is executing as part of a "fast" event handler,
    where most of the API is disabled. These are low-level events (e.g.
    |lua-loop-callbacks|) which can be invoked whenever Nvim polls for input.
    When this is `false` most API functions are callable (but may be subject
    to other restrictions such as |textlock|).

vim.rpcnotify({channel}, {method}, {...})                    *vim.rpcnotify()*
    Sends {event} to {channel} via |RPC| and returns immediately. If {channel}
    is 0, the event is broadcast to all channels.

    This function also works in a fast callback |lua-loop-callbacks|.

    Parameters: ~
      • {channel}  (`integer`)
      • {method}   (`string`)
      • {...}      (`any?`)

vim.rpcrequest({channel}, {method}, {...})                  *vim.rpcrequest()*
    Sends a request to {channel} to invoke {method} via |RPC| and blocks until
    a response is received.

    Note: NIL values as part of the return value is represented as |vim.NIL|
    special value

    Parameters: ~
      • {channel}  (`integer`)
      • {method}   (`string`)
      • {...}      (`any?`)

vim.schedule({fn})                                            *vim.schedule()*
    Schedules {fn} to be invoked soon by the main event-loop. Useful to avoid
    |textlock| or other temporary restrictions.

    Parameters: ~
      • {fn}  (`fun()`)

vim.str_utf_end({str}, {index})                            *vim.str_utf_end()*
    Gets the distance (in bytes) from the last byte of the codepoint
    (character) that {index} points to.

    Examples: >lua
        -- The character 'æ' is stored as the bytes '\xc3\xa6' (using UTF-8)

        -- Returns 0 because the index is pointing at the last byte of a character
        vim.str_utf_end('æ', 2)

        -- Returns 1 because the index is pointing at the penultimate byte of a character
        vim.str_utf_end('æ', 1)
<

    Parameters: ~
      • {str}    (`string`)
      • {index}  (`integer`)

    Return: ~
        (`integer`)

vim.str_utf_pos({str})                                     *vim.str_utf_pos()*
    Gets a list of the starting byte positions of each UTF-8 codepoint in the
    given string.

    Embedded NUL bytes are treated as terminating the string.

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

    Return: ~
        (`integer[]`)

vim.str_utf_start({str}, {index})                        *vim.str_utf_start()*
    Gets the distance (in bytes) from the starting byte of the codepoint
    (character) that {index} points to.

    The result can be added to {index} to get the starting byte of a
    character.

    Examples: >lua
        -- The character 'æ' is stored as the bytes '\xc3\xa6' (using UTF-8)

        -- Returns 0 because the index is pointing at the first byte of a character
        vim.str_utf_start('æ', 1)

        -- Returns -1 because the index is pointing at the second byte of a character
        vim.str_utf_start('æ', 2)
<

    Parameters: ~
      • {str}    (`string`)
      • {index}  (`integer`)

    Return: ~
        (`integer`)

vim.stricmp({a}, {b})                                          *vim.stricmp()*
    Compares strings case-insensitively.

    Parameters: ~
      • {a}  (`string`)
      • {b}  (`string`)

    Return: ~
        (`0|1|-1`) if strings are equal, {a} is greater than {b} or {a} is
        lesser than {b}, respectively.

vim.ui_attach({ns}, {opts}, {callback})                      *vim.ui_attach()*
    WARNING: This feature is experimental/unstable.

    Subscribe to |ui-events|, similar to |nvim_ui_attach()| but receive events
    in a Lua callback. Used to implement screen elements like popupmenu or
    message handling in Lua.

    {callback} receives event name plus additional parameters. See
    |ui-popupmenu| and the sections below for event format for respective
    events.

    Callbacks for `msg_show`

Title: vim.builtin: RPC, Scheduling, String Manipulation, and UI Attachment
Summary
This section covers the `vim.builtin` module's functions for RPC (`vim.rpcnotify`, `vim.rpcrequest`), scheduling (`vim.schedule`), UTF-8 string manipulation (`vim.str_utf_end`, `vim.str_utf_pos`, `vim.str_utf_start`), case-insensitive string comparison (`vim.stricmp`), and UI attachment (`vim.ui_attach`) for receiving UI events in a Lua callback. The `vim.rpcrequest` function blocks until a response is received, and represents NIL values using `vim.NIL`.