Skip to main content
Module

x/denops_std/function/nvim/mod.ts

📚 Standard module for denops.vim
Latest
import * as denopsStd from "https://deno.land/x/denops_std@v6.4.0/function/nvim/mod.ts";

A module to provide functions of Neovim native functions.

import type { Denops } from "https://deno.land/x/denops_std@v6.4.0/mod.ts";
import * as nvimFn from "https://deno.land/x/denops_std@v6.4.0/function/nvim/mod.ts";

export async function main(denops: Denops): Promise<void> {
  // nvimFn holds functions exists only in Neovim
  console.log(nvimFn.api_info(denops));
}

Functions

Returns Dictionary of api-metadata.

Close a channel or a specific stream associated with it. For a job, {stream} can be one of "stdin", "stdout", "stderr" or "rpc" (closes stdin/stdout for a job started with "rpc":v:true) If {stream} is omitted, all streams are closed. If the channel is a pty, this will then close the pty master, sending SIGHUP to the job process. For a socket, there is only one stream, and {stream} should be omitted.

Send data to channel {id}. For a job, it writes it to the stdin of the process. For the stdio channel channel-stdio, it writes to Nvim's stdout. Returns the number of bytes written if the write succeeded, 0 otherwise. See channel-bytes for more information.

Returns a Dictionary representing the context at {index} from the top of the context-stack (see context-dict). If {index} is not given, it is assumed to be 0 (i.e.: top).

Pops and restores the context at the top of the context-stack.

Pushes the current editor state (context) on the context-stack. If {types} is given and is a List of Strings, it specifies which context-types to include in the pushed context. Otherwise, all context types are included.

Sets the context at {index} from the top of the context-stack to that represented by {context}. {context} is a Dictionary with context data (context-dict). If {index} is not given, it is assumed to be 0 (i.e.: top).

Returns the size of the context-stack.

Adds a watcher to a dictionary. A dictionary watcher is identified by three components:

Removes a watcher added with dictwatcheradd(). All three arguments must match the ones passed to dictwatcheradd() in order for the watcher to be successfully deleted.

Returns a String which is a unique identifier of the container type (List, Dict, Blob and Partial). It is guaranteed that for the mentioned types id(v1) ==# id(v2) returns true iff type(v1) == type(v2) && v1 is v2. Note that v:_null_string, v:_null_list, v:_null_dict and v:_null_blob have the same id() with different types because they are internally represented as NULL pointers. id() returns a hexadecimal representanion of the pointers to the containers (i.e. like 0x994a40), same as printf("%p", {expr}), but it is advised against counting on the exact format of the return value.

Return the PID (process id) of job-id {job}.

Resize the pseudo terminal window of job-id {job} to {width} columns and {height} rows. Fails if the job was not started with "pty":v:true.

Spawns {cmd} as a job. If {cmd} is a List it runs directly (no 'shell'). If {cmd} is a String it runs in the 'shell', like this:

Stop job-id {id} by sending SIGTERM to the job process. If the process does not terminate after a timeout then SIGKILL will be sent. When the job terminates its on_exit handler (if any) will be invoked. See job-control.

Waits for jobs and their on_exit handlers to complete.

Returns a List of Dictionaries describing menus (defined by :menu, :amenu, …), including hidden-menus.

Convert a list of VimL objects to msgpack. Returned value is a readfile()-style list. When {type} contains "B", a Blob is returned instead. Example:

Convert a readfile()-style list or a Blob to a list of VimL objects. Example:

Find files in runtime directories

Returns object given as argument.

Returns array given as argument.

Returns dictionary given as argument.

Returns floating-point value given as argument.

NB: if your UI doesn't use hlstate, this will not return hlstate first time.

Gets internal stats.

Adds a highlight to buffer.

Activates buffer-update events on a channel, or as Lua callbacks.

call a function with buffer as temporary current buffer

Clears namespaced objects (highlights, extmarks, virtual text) from a region.

Creates a buffer-local command user-commands.

Removes an extmark.

Unmaps a buffer-local mapping for the given mode.

Deletes a named mark in the buffer. See mark-motions.

Delete a buffer-local user-defined command.

Removes a buffer-scoped (b:) variable

Deletes the buffer. See :bwipeout

Deactivates buffer-update events on the channel.

Gets a changed tick of a buffer

Gets a map of buffer-local user-commands.

Gets the position (0-indexed) of an extmark.

Gets extmarks in "traversal order" from a charwise region defined by buffer positions (inclusive, 0-indexed api-indexing).

Gets a list of buffer-local mapping definitions.

Gets a line-range from the buffer.

Returns a tuple (row,col) representing the position of the named mark. See mark-motions.

Gets the full file name for the buffer

Returns the byte offset of a line (0-indexed). api-indexing

Gets a buffer option value

Gets a range from the buffer.

Gets a buffer-scoped (b:) variable.

Checks if a buffer is valid and loaded. See api-buffer for more info about unloaded buffers.

Checks if a buffer is valid.

Returns the number of lines in the given buffer.

Creates or updates an extmark.

Sets a buffer-local mapping for the given mode.

Sets (replaces) a line-range in the buffer.

Sets a named mark in the given buffer, all marks are allowed file/uppercase, visual, last change, etc. See mark-motions.

Sets the full file name for a buffer

Sets a buffer option value. Passing nil as value deletes the option (only works if there's a global fallback)

Sets (replaces) a range in the buffer

Sets a buffer-scoped (b:) variable

Calls many API methods atomically.

Calls a VimL Dictionary-function with the given arguments.

Calls a VimL function with the given arguments.

Send data to channel id. For a job, it writes it to the stdin of the process. For the stdio channel channel-stdio, it writes to Nvim's stdout. For an internal terminal instance (nvim_open_term()) it writes directly to terminal output. See channel-bytes for more information.

Clear all autocommands that match the corresponding {opts}. To delete a particular autocmd, see nvim_del_autocmd().

Executes an Ex command.

Executes an Ex command.

Create or get an autocommand group autocmd-groups.

Creates an autocommand event handler, defined by callback (Lua function or Vimscript function name string) or command (Ex command string).

Creates a new, empty, unnamed buffer.

Creates a new namespace or gets an existing one.

Creates a global user-commands command.

Delete an autocommand group by id.

Delete an autocommand group by name.

Delete an autocommand by id.

Deletes the current line.

Unmaps a global mapping for the given mode.

Deletes an uppercase/file named mark. See mark-motions.

Delete a user-defined command.

Removes a global (g:) variable.

Echo a message.

Writes a message to the Vim error buffer. Does not append "\n", the message is buffered (won't display) until a linefeed is written.

Writes a message to the Vim error buffer. Appends "\n", so the buffer is flushed (and displayed).

Evaluates a VimL expression. Dictionaries and Lists are recursively expanded.

Evaluates statusline string.

Execute all autocommands for {event} that match the corresponding {opts} autocmd-execute.

Execute Lua code. Parameters (if any) are available as ... inside the chunk. The chunk can return a value.

Executes Vimscript (multiline block of Ex commands), like anonymous :source.

Sends input-keys to Nvim, subject to various quirks controlled by mode flags. This is a blocking call, unlike nvim_input().

Gets the option information for all options.

Returns a 2-tuple (Array), where item 0 is the current channel id and item 1 is the api-metadata map (Dictionary).

Get all autocommands that match the corresponding {opts}.

Gets information about a channel.

Returns the 24-bit RGB value of a nvim_get_color_map() color name or "#rrggbb" hexadecimal string.

Returns a map of color names and RGB values.

Gets a map of global (non-buffer-local) Ex commands.

Gets a map of the current editor state.

Gets the current buffer.

Gets the current line.

Gets the current tabpage.

Gets the current window.

Gets all or specific highlight groups in a namespace.

Gets a highlight group by name

Gets a list of global (non-buffer-local) mapping definitions.

Return a tuple (row, col, buffer, buffername) representing the position of the uppercase/file named mark. See mark-motions.

Gets the current mode. mode() "blocking" is true if Nvim is waiting for input.

Gets existing, non-anonymous namespaces.

Gets the global value of an option.

Gets the option information for one option from arbitrary buffer or window

Gets the value of an option. The behavior of this function matches that of :set: the local value of an option is returned if it exists; otherwise, the global value is returned. Local values always correspond to the current buffer or window, unless "buf" or "win" is set in {opts}.

Gets info describing process pid.

Gets the immediate children of process pid.

Find files in runtime directories

Gets a global (g:) variable.

Gets a v: variable.

Queues raw user-input. Unlike nvim_feedkeys(), this uses a low-level input buffer and the call is non-blocking (input is processed asynchronously by the eventloop).

Send mouse event from GUI.

Gets the current list of buffer handles

Get information about all open channels.

Gets the paths contained in 'runtimepath'.

Gets the current list of tabpage handles.

Gets a list of dictionaries representing attached UIs.

Gets the current list of window handles.

Sets the current editor state from the given context map.

Notify the user with a message

Open a terminal instance in a buffer

Open a new window.

Writes a message to the Vim output buffer. Does not append "\n", the message is buffered (won't display) until a linefeed is written.

Parse command line.

Parse a VimL expression.

Pastes at cursor, in any mode.

Puts text at cursor, in any mode.

Replaces terminal codes and keycodes (<CR>, <Esc>, ...) in a string with the internal representation.

Selects an item in the completion popup menu.

Self-identifies the client.

Sets the current buffer.

Changes the global working directory.

Sets the current line.

Sets the current tabpage.

Sets the current window.

Set or change decoration provider for a namespace

Sets a highlight group.

Set active namespace for highlights defined with nvim_set_hl(). This can be set for a single window, see nvim_win_set_hl_ns().

Set active namespace for highlights defined with nvim_set_hl() while redrawing.

Sets a global mapping for the given mode.

Sets the global value of an option.

Sets the value of an option. The behavior of this function matches that of :set: for global-local options, both the global and local value are set unless otherwise specified with {scope}.

Sets a global (g:) variable.

Sets a v: variable, if it is not readonly.

Calculates the number of display cells occupied by text. Control characters including <Tab> count as one cell.

Subscribes to event broadcasts.

Removes a tab-scoped (t:) variable

Gets the tabpage number

Gets a tab-scoped (t:) variable

Gets the current window in a tabpage

Checks if a tabpage is valid

Gets the windows in a tabpage

Sets a tab-scoped (t:) variable

Activates UI events on the channel.

Deactivates UI events on the channel.

Tells Nvim the geometry of the popupmenu, to align floating windows with an external popup menu.

Tells Nvim the number of elements displaying in the popupmenu, to decide <PageUp> and <PageDown> movement.

Tells the nvim server if focus was gained or lost by the GUI.

TODO: Documentation

TODO: Documentation

Tell Nvim to resize a grid. Triggers a grid_resize event with the requested grid size or the maximum size if it exceeds size limits.

Unsubscribes to event broadcasts.

Calls a function with window as temporary current window.

Closes the window (like :close with a window-ID).

Removes a window-scoped (w:) variable

Gets the current buffer in a window

Gets window configuration.

Gets the (1,0)-indexed, buffer-relative cursor position for a given window (different windows showing the same buffer have independent cursor positions). api-indexing

Gets the window height

Gets the window number

Gets a window option value

Gets the window position in display cells. First position is zero.

Gets the window tabpage

Gets a window-scoped (w:) variable

Gets the window width

Closes the window and hide the buffer it contains (like :hide with a window-ID).

Checks if a window is valid

Sets the current buffer in a window, without side effects

Configures window layout. Currently only for floating and external windows (including changing a split window to those layouts).

Sets the (1,0)-indexed cursor position in the window. api-indexing This scrolls the window even if it is not the current one.

Sets the window height.

Set highlight namespace for a window. This will use highlights defined with nvim_set_hl() for this namespace, but fall back to global highlights (ns=0) when missing.

Sets a window option value. Passing nil as value deletes the option (only works if there's a global fallback)

Sets a window-scoped (w:) variable

Sets the window width. This will only succeed if the screen is split vertically.

Returns the single letter name of the last recorded register. Returns an empty string when nothing was recorded yet. See q and Q.

Sends {event} to {channel} via RPC and returns immediately. If {channel} is 0, the event is broadcast to all channels. Example:

Sends a request to {channel} to invoke {method} via RPC and blocks until a response is received. Example:

Deprecated. Replace

Opens a socket or named pipe at {address} and listens for RPC messages. Clients can send API commands to the returned address to control Nvim.

Closes the pipe or socket at {address}. Returns TRUE if {address} is valid, else FALSE. If v:servername is stopped it is set to the next available address in serverlist().

Connect a socket to an address. If {mode} is "pipe" then {address} should be the path of a local domain socket (on unix) or named pipe (on Windows). If {mode} is "tcp" then {address} should be of the form "host:port" where the host should be an ip adderess or host name, and port the port number.

With --headless this opens stdin and stdout as a channel. May be called only once. See channel-stdio. stderr is not handled by this function, see v:stderr.

Returns standard-path locations of various default files and directories.

Spawns {cmd} in a new pseudo-terminal session connected to the current (unmodified) buffer. Parameters and behavior are the same as jobstart() except "pty", "width", "height", and "TERM" are ignored: "height" and "width" are taken from the current window. Returns the same values as jobstart().

Waits until {condition} evaluates to TRUE, where {condition} is a Funcref or string containing an expression.