Home Explore Blog CI



neovim

21th chunk of `runtime/doc/lua.txt`
152dd3d96611f661499252ea879a24cdd73995aa1c39a7e90000000100000fcc
 |nvim_exec2()|, where `opts.output` is
                   set to false. Thus it works identical to |:source|. If a
                   table, executes a single command. In this case, it is an
                   alias to |nvim_cmd()| where `opts` is empty.

    See also: ~
      • |ex-cmd-index|

vim.defer_fn({fn}, {timeout})                                 *vim.defer_fn()*
    Defers calling {fn} until {timeout} ms passes.

    Use to do a one-shot timer that calls {fn} Note: The {fn} is
    |vim.schedule_wrap()|ped automatically, so API functions are safe to call.

    Parameters: ~
      • {fn}       (`function`) Callback to call once `timeout` expires
      • {timeout}  (`integer`) Number of milliseconds to wait before calling
                   `fn`

    Return: ~
        (`table`) timer luv timer object

                                                             *vim.deprecate()*
vim.deprecate({name}, {alternative}, {version}, {plugin}, {backtrace})
    Shows a deprecation message to the user.

    Parameters: ~
      • {name}         (`string`) Deprecated feature (function, API, etc.).
      • {alternative}  (`string?`) Suggested alternative feature.
      • {version}      (`string`) Version when the deprecated function will be
                       removed.
      • {plugin}       (`string?`) Name of the plugin that owns the deprecated
                       feature. Defaults to "Nvim".
      • {backtrace}    (`boolean?`) Prints backtrace. Defaults to true.

    Return: ~
        (`string?`) Deprecated message, or nil if no message was shown.

vim.inspect()                                                  *vim.inspect()*
    Gets a human-readable representation of the given object.

    Return: ~
        (`string`)

    See also: ~
      • |vim.print()|
      • https://github.com/kikito/inspect.lua
      • https://github.com/mpeterv/vinspect

vim.keycode({str})                                             *vim.keycode()*
    Translates keycodes.

    Example: >lua
        local k = vim.keycode
        vim.g.mapleader = k'<bs>'
<

    Parameters: ~
      • {str}  (`string`) String to be converted.

    Return: ~
        (`string`)

    See also: ~
      • |nvim_replace_termcodes()|

vim.lua_omnifunc({find_start})                            *vim.lua_omnifunc()*
    Omnifunc for completing Lua values from the runtime Lua interpreter,
    similar to the builtin completion for the `:lua` command.

    Activate using `set omnifunc=v:lua.vim.lua_omnifunc` in a Lua buffer.

    Parameters: ~
      • {find_start}  (`1|0`)

vim.notify({msg}, {level}, {opts})                              *vim.notify()*
    Displays a notification to the user.

    This function can be overridden by plugins to display notifications using
    a custom provider (such as the system notification provider). By default,
    writes to |:messages|.

    Parameters: ~
      • {msg}    (`string`) Content of the notification to show to the user.
      • {level}  (`integer?`) One of the values from |vim.log.levels|.
      • {opts}   (`table?`) Optional parameters. Unused by default.

vim.notify_once({msg}, {level}, {opts})                    *vim.notify_once()*
    Displays a notification only one time.

    Like |vim.notify()|, but subsequent calls with the same message will not
    display a notification.

    Parameters: ~
      • {msg}    (`string`) Content of the notification to show to the user.
      • {level}  (`integer?`) One of the values from |vim.log.levels|.
      • {opts}   (`table?`) Optional parameters. Unused by default.

    Return: ~
        (`boolean`) true if message was displayed, else false

vim.on_key({fn}, {ns_id}, {opts})                               *vim.on_key()*
    Adds Lua function {fn} with namespace id {ns_id} as a listener to every,
    yes every, input key.

    The Nvim command-line option |-w| is related but does not support
    callbacks and cannot be toggled dynamically.

    Note: ~
      • {fn} will be removed on error.

Title: Lua vim API: vim.defer_fn(), vim.deprecate(), vim.inspect(), vim.keycode(), vim.lua_omnifunc(), vim.notify(), vim.notify_once(), vim.on_key()
Summary
This section describes various Lua API functions in Neovim. It details `vim.defer_fn()` for deferred function execution, `vim.deprecate()` for displaying deprecation messages, `vim.inspect()` for getting a human-readable representation of an object, `vim.keycode()` for translating keycodes, `vim.lua_omnifunc()` for Lua omnicompletion, `vim.notify()` for displaying user notifications, `vim.notify_once()` for displaying notifications only once, and `vim.on_key()` for listening to every input key.