Core API Functions
Corenvim_* functions provide global operations for the Neovim editor, including input handling, buffer/window/tabpage management, variables, and more.
Input and Execution
nvim_feedkeys()
Sends input-keys to Nvim, subject to various quirks controlled by mode flags. This is a blocking call.Keys to be typed
Behavior flags (see
:h feedkeys())'n': No remapping'm': Remapping allowed't': Handle keys as if typed'i': Insert at start of typebuf'x': Execute keys immediately
If true, escape K_SPECIAL bytes in keys. Should be false if you already used
nvim_replace_termcodes()nvim_input()
Queues raw user-input. Unlikenvim_feedkeys(), this uses a low-level input buffer and is non-blocking.
Keys to be typed
Number of bytes actually written
nvim_exec_lua()
Executes Lua code. Arguments are available as... inside the chunk.
Lua code to execute
Arguments to the Lua code
Value returned by the Lua code (if any), or NIL
Buffer Management
nvim_list_bufs()
Gets the current list of buffers. Includes unlisted (unloaded/deleted) buffers.List of buffer handles (buffer numbers)
nvim_get_current_buf()
Gets the current buffer.Buffer handle
nvim_set_current_buf()
Sets the current window’s buffer.Buffer handle
nvim_create_buf()
Creates a new, empty, unnamed buffer.Sets ‘buflisted’
Creates a scratch buffer (always ‘nomodified’)
Buffer handle, or 0 on error
Window Management
nvim_list_wins()
Gets the current list of all window IDs in all tabpages.List of window handles
nvim_get_current_win()
Gets the current window.Window handle
nvim_set_current_win()
Navigates to the given window (and tabpage, implicitly).Window handle
Tabpage Management
nvim_list_tabpages()
Gets the current list of tabpage IDs.List of tabpage handles
nvim_get_current_tabpage()
Gets the current tabpage.Tabpage handle
nvim_set_current_tabpage()
Sets the current tabpage.Tabpage handle
Variables
nvim_get_var()
Gets a global (g:) variable.Variable name
Variable value
nvim_set_var()
Sets a global (g:) variable.Variable name
Variable value
nvim_del_var()
Removes a global (g:) variable.Variable name
nvim_get_vvar()
Gets a v: variable.Variable name
Variable value
Current Line Operations
nvim_get_current_line()
Gets the current line.Current line string
nvim_set_current_line()
Sets the text on the current line.Line contents
nvim_del_current_line()
Deletes the current line.Highlights
nvim_get_hl_id_by_name()
Gets a highlight group by name. Similar tohlID(), but allocates a new ID if not present.
Highlight group name
Highlight group ID
nvim_set_hl()
Sets a highlight group.Namespace id (use 0 for global)
Highlight group name (e.g., “ErrorMsg”)
Highlight definition map with keys:
fg: foreground colorbg: background colorbold: booleanitalic: booleanunderline: booleanlink: name of another group to link to
nvim_get_hl()
Gets all or specific highlight groups in a namespace.Namespace id (use 0 for global)
Options:
name: Get by nameid: Get by idlink: Show linked group name
Highlight definition map
Utility Functions
nvim_get_mode()
Gets the current mode.Dictionary with keys:
mode: Mode short-name stringblocking: Boolean, true if waiting for input
nvim_strwidth()
Calculates the number of display cells occupied by text.Some text
Number of cells
nvim_get_api_info()
Returns a 2-tuple with current channel id and API metadata.Array
[{channel-id}, {api-metadata}]See Also
- Buffer Functions - Buffer-specific operations
- Window Functions - Window-specific operations
- Tabpage Functions - Tabpage-specific operations