Data Structures | Macros | Functions
vim.c File Reference
#include <assert.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "nvim/api/vim.h"
#include "nvim/ascii.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/dispatch.h"
#include "nvim/api/buffer.h"
#include "nvim/api/window.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/lua/executor.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/file_search.h"
#include "nvim/highlight.h"
#include "nvim/window.h"
#include "nvim/types.h"
#include "nvim/ex_docmd.h"
#include "nvim/screen.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/fileio.h"
#include "nvim/option.h"
#include "nvim/state.h"
#include "nvim/syntax.h"
#include "nvim/getchar.h"
#include "nvim/os/input.h"
#include "nvim/os/process.h"
#include "nvim/viml/parser/expressions.h"
#include "nvim/viml/parser/parser.h"
#include "nvim/ui.h"

Data Structures

struct  ExprASTConvStackItem
 

Macros

#define LINE_BUFFER_SIZE   4096
 
#define PUSH_CHAR(i, pos, line_buf, msg)
 

Functions

void api_vim_init (void)
 
void api_vim_free_all_mem (void)
 
void nvim_command (String command, Error *err) FUNC_API_SINCE(1)
 
Dictionary nvim_get_hl_by_name (String name, Boolean rgb, Error *err) FUNC_API_SINCE(3)
 
Dictionary nvim_get_hl_by_id (Integer hl_id, Boolean rgb, Error *err) FUNC_API_SINCE(3)
 
void nvim_feedkeys (String keys, String mode, Boolean escape_csi) FUNC_API_SINCE(1)
 
Integer nvim_input (String keys) FUNC_API_SINCE(1) FUNC_API_ASYNC
 
void nvim_input_mouse (String button, String action, String modifier, Integer grid, Integer row, Integer col, Error *err) FUNC_API_SINCE(6) FUNC_API_ASYNC
 
String nvim_replace_termcodes (String str, Boolean from_part, Boolean do_lt, Boolean special) FUNC_API_SINCE(1)
 
String nvim_command_output (String command, Error *err) FUNC_API_SINCE(1)
 
Object nvim_eval (String expr, Error *err) FUNC_API_SINCE(1)
 
Object nvim_execute_lua (String code, Array args, Error *err) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY
 
Object nvim_call_function (String fn, Array args, Error *err) FUNC_API_SINCE(1)
 
Object nvim_call_dict_function (Object dict, String fn, Array args, Error *err) FUNC_API_SINCE(4)
 
Integer nvim_strwidth (String text, Error *err) FUNC_API_SINCE(1)
 
 ArrayOf (String)
 
void nvim_set_current_dir (String dir, Error *err) FUNC_API_SINCE(1)
 
String nvim_get_current_line (Error *err) FUNC_API_SINCE(1)
 
void nvim_set_current_line (String line, Error *err) FUNC_API_SINCE(1)
 
void nvim_del_current_line (Error *err) FUNC_API_SINCE(1)
 
Object nvim_get_var (String name, Error *err) FUNC_API_SINCE(1)
 
void nvim_set_var (String name, Object value, Error *err) FUNC_API_SINCE(1)
 
void nvim_del_var (String name, Error *err) FUNC_API_SINCE(1)
 
Object vim_set_var (String name, Object value, Error *err)
 
Object vim_del_var (String name, Error *err)
 
Object nvim_get_vvar (String name, Error *err) FUNC_API_SINCE(1)
 
void nvim_set_vvar (String name, Object value, Error *err) FUNC_API_SINCE(6)
 
Object nvim_get_option (String name, Error *err) FUNC_API_SINCE(1)
 
void nvim_set_option (uint64_t channel_id, String name, Object value, Error *err) FUNC_API_SINCE(1)
 
void nvim_out_write (String str) FUNC_API_SINCE(1)
 
void nvim_err_write (String str) FUNC_API_SINCE(1)
 
void nvim_err_writeln (String str) FUNC_API_SINCE(1)
 
 ArrayOf (Buffer)
 
Buffer nvim_get_current_buf (void)
 
void nvim_set_current_buf (Buffer buffer, Error *err) FUNC_API_SINCE(1)
 
 ArrayOf (Window)
 
Window nvim_get_current_win (void)
 
void nvim_set_current_win (Window window, Error *err) FUNC_API_SINCE(1)
 
Buffer nvim_create_buf (Boolean listed, Boolean scratch, Error *err) FUNC_API_SINCE(6)
 
Window nvim_open_win (Buffer buffer, Boolean enter, Dictionary config, Error *err) FUNC_API_SINCE(6)
 
 ArrayOf (Tabpage)
 
Tabpage nvim_get_current_tabpage (void)
 
void nvim_set_current_tabpage (Tabpage tabpage, Error *err) FUNC_API_SINCE(1)
 
Integer nvim_create_namespace (String name) FUNC_API_SINCE(5)
 
Dictionary nvim_get_namespaces (void)
 
void nvim_subscribe (uint64_t channel_id, String event) FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
 
void nvim_unsubscribe (uint64_t channel_id, String event) FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
 
Integer nvim_get_color_by_name (String name) FUNC_API_SINCE(1)
 
Dictionary nvim_get_color_map (void)
 
Dictionary nvim_get_mode (void)
 
 ArrayOf (Dictionary)
 
Dictionary nvim_get_commands (Dictionary opts, Error *err) FUNC_API_SINCE(4)
 
Array nvim_get_api_info (uint64_t channel_id) FUNC_API_SINCE(1) FUNC_API_ASYNC FUNC_API_REMOTE_ONLY
 
void nvim_set_client_info (uint64_t channel_id, String name, Dictionary version, String type, Dictionary methods, Dictionary attributes, Error *err) FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY
 
Dictionary nvim_get_chan_info (Integer chan, Error *err) FUNC_API_SINCE(4)
 
Array nvim_list_chans (void)
 
Array nvim_call_atomic (uint64_t channel_id, Array calls, Error *err) FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
 
Dictionary nvim_parse_expression (String expr, String flags, Boolean highlight, Error *err) FUNC_API_SINCE(4) FUNC_API_ASYNC
 
Object nvim__id (Object obj)
 
Array nvim__id_array (Array arr)
 
Dictionary nvim__id_dictionary (Dictionary dct)
 
Float nvim__id_float (Float flt)
 
Dictionary nvim__stats (void)
 
Array nvim_list_uis (void)
 
Array nvim_get_proc_children (Integer pid, Error *err) FUNC_API_SINCE(4)
 
Object nvim_get_proc (Integer pid, Error *err) FUNC_API_SINCE(4)
 
void nvim_select_popupmenu_item (Integer item, Boolean insert, Boolean finish, Dictionary opts, Error *err) FUNC_API_SINCE(6)
 
Array nvim__inspect_cell (Integer row, Integer col, Error *err)
 NB: if your UI doesn't use hlstate, this will not return hlstate first time. More...
 

Macro Definition Documentation

#define LINE_BUFFER_SIZE   4096
#define PUSH_CHAR (   i,
  pos,
  line_buf,
  msg 
)
Value:
if (message.data[i] == NL || pos == LINE_BUFFER_SIZE - 1) { \
line_buf[pos] = NUL; \
msg((char_u *)line_buf); \
pos = 0; \
continue; \
} \
\
line_buf[pos++] = message.data[i];
Definition: defs.h:10
#define NUL
Definition: ascii.h:19
#define LINE_BUFFER_SIZE
Definition: vim.c:46
#define NL
Definition: ascii.h:23
err msg
Definition: helpers.c:1186
unsigned char char_u
Definition: types.h:11
int i
Definition: typval.c:868

Function Documentation

void api_vim_free_all_mem ( void  )
void api_vim_init ( void  )
ArrayOf ( String  )

Gets the paths contained in 'runtimepath'.

Returns
List of paths
ArrayOf ( Buffer  )

Gets the current list of buffer handles

Includes unlisted (unloaded/deleted) buffers, like :ls!. Use |nvim_buf_is_loaded()| to check if a buffer is loaded.

Returns
List of buffer handles
ArrayOf ( Window  )

Gets the current list of window handles.

Returns
List of window handles
ArrayOf ( Tabpage  )

Gets the current list of tabpage handles.

Returns
List of tabpage handles
ArrayOf ( Dictionary  )

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

Parameters
modeMode short-name ("n", "i", "v", ...)
Returns
Array of maparg()-like dictionaries describing mappings. The "buffer" key is always zero.
Object nvim__id ( Object  obj)

Returns object given as argument.

This API function is used for testing. One should not rely on its presence in plugins.

Parameters
[in]objObject to return.
Returns
its argument.
Array nvim__id_array ( Array  arr)

Returns array given as argument.

This API function is used for testing. One should not rely on its presence in plugins.

Parameters
[in]arrArray to return.
Returns
its argument.
Dictionary nvim__id_dictionary ( Dictionary  dct)

Returns dictionary given as argument.

This API function is used for testing. One should not rely on its presence in plugins.

Parameters
[in]dctDictionary to return.
Returns
its argument.
Float nvim__id_float ( Float  flt)

Returns floating-point value given as argument.

This API function is used for testing. One should not rely on its presence in plugins.

Parameters
[in]fltValue to return.
Returns
its argument.
Array nvim__inspect_cell ( Integer  row,
Integer  col,
Error err 
)

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

Dictionary nvim__stats ( void  )

Gets internal stats.

Returns
Map of various internal stats.
Array nvim_call_atomic ( uint64_t  channel_id,
Array  calls,
Error err 
)

Calls many API methods atomically.

This has two main usages:

  1. To perform several requests from an async context atomically, i.e. without interleaving redraws, RPC requests from other clients, or user interactions (however API methods may trigger autocommands or event processing which have such side-effects, e.g. |:sleep| may wake timers).
  2. To minimize RPC overhead (roundtrips) of a sequence of many requests.
Parameters
callsan array of calls, where each call is described by an array with two elements: the request name, and an array of arguments.
[out]errDetails of a validation error of the nvim_multi_request call itself, i.e. malformed calls parameter. Errors from called methods will be indicated in the return value, see below.
Returns
an array with two elements. The first is an array of return values. The second is NIL if all calls succeeded. If a call resulted in an error, it is a three-element array with the zero-based index of the call which resulted in an error, the error type and the error message. If an error occurred, the values from all preceding calls will still be returned.
Object nvim_call_dict_function ( Object  dict,
String  fn,
Array  args,
Error err 
)

Calls a VimL |Dictionary-function| with the given arguments.

On execution error: fails with VimL error, does not update v:errmsg.

Parameters
dictDictionary, or String evaluating to a VimL |self| dict
fnName of the function defined on the VimL dict
argsFunction arguments packed in an Array
[out]errError details, if any
Returns
Result of the function call
Object nvim_call_function ( String  fn,
Array  args,
Error err 
)

Calls a VimL function with the given arguments.

On execution error: fails with VimL error, does not update v:errmsg.

Parameters
fnFunction to call
argsFunction arguments packed in an Array
[out]errError details, if any
Returns
Result of the function call
void nvim_command ( String  command,
Error err 
)

Executes an ex-command.

On execution error: fails with VimL error, does not update v:errmsg.

Parameters
commandEx-command string
[out]errError details (Vim error), if any
String nvim_command_output ( String  command,
Error err 
)

Executes an ex-command and returns its (non-error) output. Shell |:!| output is not captured.

On execution error: fails with VimL error, does not update v:errmsg.

Parameters
commandEx-command string
[out]errError details (Vim error), if any
Buffer nvim_create_buf ( Boolean  listed,
Boolean  scratch,
Error err 
)

Creates a new, empty, unnamed buffer.

Parameters
listedControls 'buflisted'
scratchCreates a "throwaway" |scratch-buffer| for temporary work (always 'nomodified')
[out]errError details, if any
Returns
Buffer handle, or 0 on error
See also
buf_open_scratch
Integer nvim_create_namespace ( String  name)

Creates a new namespace, or gets an existing one.

Namespaces are used for buffer highlights and virtual text, see |nvim_buf_add_highlight()| and |nvim_buf_set_virtual_text()|.

Namespaces can be named or anonymous. If name matches an existing namespace, the associated id is returned. If name is an empty string a new, anonymous namespace is created.

Parameters
nameNamespace name or empty string
Returns
Namespace id
void nvim_del_current_line ( Error err)

Deletes the current line.

Parameters
[out]errError details, if any
void nvim_del_var ( String  name,
Error err 
)

Removes a global (g:) variable.

Parameters
nameVariable name
[out]errError details, if any
void nvim_err_write ( String  str)

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

Parameters
strMessage
void nvim_err_writeln ( String  str)

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

Parameters
strMessage
See also
nvim_err_write()
Object nvim_eval ( String  expr,
Error err 
)

Evaluates a VimL expression (:help expression). Dictionaries and Lists are recursively expanded.

On execution error: fails with VimL error, does not update v:errmsg.

Parameters
exprVimL expression string
[out]errError details, if any
Returns
Evaluation result or expanded object
Object nvim_execute_lua ( String  code,
Array  args,
Error err 
)

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

Only statements are executed. To evaluate an expression, prefix it with return: return my_function(...)

Parameters
codelua code to execute
argsArguments to the code
[out]errDetails of an error encountered while parsing or executing the lua code.
Returns
Return value of lua code if present or NIL.
void nvim_feedkeys ( String  keys,
String  mode,
Boolean  escape_csi 
)

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

On execution error: does not fail, but updates v:errmsg.

Parameters
keysto be typed
modebehavior flags, see |feedkeys()|
escape_csiIf true, escape K_SPECIAL/CSI bytes in keys
See also
feedkeys()
vim_strsave_escape_csi
Array nvim_get_api_info ( uint64_t  channel_id)

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

Returns
2-tuple [{channel-id}, {api-metadata}]
Dictionary nvim_get_chan_info ( Integer  chan,
Error err 
)

Get information about a channel.

Returns
a Dictionary, describing a channel with the following keys:
  • "stream" the stream underlying the channel
    • "stdio" stdin and stdout of this Nvim instance
    • "stderr" stderr of this Nvim instance
    • "socket" TCP/IP socket or named pipe
    • "job" job with communication over its stdio
  • "mode" how data received on the channel is interpreted
    • "bytes" send and recieve raw bytes
    • "terminal" a |terminal| instance interprets ASCII sequences
    • "rpc" |RPC| communication on the channel is active
  • "pty" Name of pseudoterminal, if one is used (optional). On a POSIX system, this will be a device path like /dev/pts/1. Even if the name is unknown, the key will still be present to indicate a pty is used. This is currently the case when using winpty on windows.
  • "buffer" buffer with connected |terminal| instance (optional)
  • "client" information about the client on the other end of the RPC channel, if it has added it using |nvim_set_client_info()|. (optional)
Integer nvim_get_color_by_name ( String  name)
Dictionary nvim_get_color_map ( void  )
Dictionary nvim_get_commands ( Dictionary  opts,
Error err 
)

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

Currently only |user-commands| are supported, not builtin Ex commands.

Parameters
optsOptional parameters. Currently only supports {"builtin":false}
[out]errError details, if any.
Returns
Map of maps describing commands.
Buffer nvim_get_current_buf ( void  )

Gets the current buffer.

Returns
Buffer handle
String nvim_get_current_line ( Error err)

Gets the current line.

Parameters
[out]errError details, if any
Returns
Current line string
Tabpage nvim_get_current_tabpage ( void  )

Gets the current tabpage.

Returns
Tabpage handle
Window nvim_get_current_win ( void  )

Gets the current window.

Returns
Window handle
Dictionary nvim_get_hl_by_id ( Integer  hl_id,
Boolean  rgb,
Error err 
)

Gets a highlight definition by id. |hlID()|

Parameters
hl_idHighlight id as returned by |hlID()|
rgbExport RGB colors
[out]errError details, if any
Returns
Highlight definition map
See also
nvim_get_hl_by_name
Dictionary nvim_get_hl_by_name ( String  name,
Boolean  rgb,
Error err 
)

Gets a highlight definition by name.

Parameters
nameHighlight group name
rgbExport RGB colors
[out]errError details, if any
Returns
Highlight definition map
See also
nvim_get_hl_by_id
Dictionary nvim_get_mode ( void  )

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

Returns
Dictionary { "mode": String, "blocking": Boolean }
Dictionary nvim_get_namespaces ( void  )

Gets existing, non-anonymous namespaces.

Returns
dict that maps from names to namespace ids.
Object nvim_get_option ( String  name,
Error err 
)

Gets an option value string.

Parameters
nameOption name
[out]errError details, if any
Returns
Option value (global)
Object nvim_get_proc ( Integer  pid,
Error err 
)

Gets info describing process pid.

Returns
Map of process properties, or NIL if process not found.
Array nvim_get_proc_children ( Integer  pid,
Error err 
)

Gets the immediate children of process pid.

Returns
Array of child process ids, empty if process not found.
Object nvim_get_var ( String  name,
Error err 
)

Gets a global (g:) variable.

Parameters
nameVariable name
[out]errError details, if any
Returns
Variable value
Object nvim_get_vvar ( String  name,
Error err 
)

Gets a v: variable.

Parameters
nameVariable name
[out]errError details, if any
Returns
Variable value
Integer nvim_input ( String  keys)

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).

On execution error: does not fail, but updates v:errmsg.

Note
|keycodes| like <CR> are translated, so "<" is special. To input a literal "<", send <LT>.
For mouse events use |nvim_input_mouse()|. The pseudokey form "<LeftMouse><col,row>" is deprecated since |api-level| 6.
Parameters
keysto be typed
Returns
Number of bytes actually written (can be fewer than requested if the buffer becomes full).
void nvim_input_mouse ( String  button,
String  action,
String  modifier,
Integer  grid,
Integer  row,
Integer  col,
Error err 
)

Send mouse event from GUI.

The call is non-blocking. It doesn't wait on any resulting action, but queues the event to be processed soon by the event loop.

Note
Currently this doesn't support "scripting" multiple mouse events by calling it multiple times in a loop: the intermediate mouse positions will be ignored. It should be used to implement real-time mouse input in a GUI. The deprecated pseudokey form ("<LeftMouse><col,row>") of |nvim_input()| has the same limitiation.
Parameters
buttonMouse button: one of "left", "right", "middle", "wheel".
actionFor ordinary buttons, one of "press", "drag", "release". For the wheel, one of "up", "down", "left", "right".
modifierString of modifiers each represented by a single char. The same specifiers are used as for a key press, except that the "-" separator is optional, so "C-A-", "c-a" and "CA" can all be used to specify Ctrl+Alt+click.
gridGrid number if the client uses |ui-multigrid|, else 0.
rowMouse row-position (zero-based, like redraw events)
colMouse column-position (zero-based, like redraw events)
Array nvim_list_chans ( void  )

Get information about all open channels.

Returns
Array of Dictionaries, each describing a channel with the format specified at |nvim_get_chan_info()|.
Array nvim_list_uis ( void  )

Gets a list of dictionaries representing attached UIs.

Returns
Array of UI dictionaries

Each dictionary has the following keys:

  • "height" requested height of the UI
  • "width" requested width of the UI
  • "rgb" whether the UI uses rgb colors (false implies cterm colors)
  • "ext_..." Requested UI extensions, see |ui-options|
  • "chan" Channel id of remote UI (not present for TUI)
Window nvim_open_win ( Buffer  buffer,
Boolean  enter,
Dictionary  config,
Error err 
)

Open a new window.

Currently this is used to open floating and external windows. Floats are windows that are drawn above the split layout, at some anchor position in some other window. Floats can be draw internally or by external GUI with the |ui-multigrid| extension. External windows are only supported with multigrid GUIs, and are displayed as separate top-level windows.

For a general overview of floats, see |api-floatwin|.

Exactly one of external and relative must be specified.

Parameters
bufferhandle of buffer to be displayed in the window
enterwhether the window should be entered (made the current window)
configdictionary for the window configuration accepts these keys:
`relative`: If set, the window becomes a floating window. The window
    will be placed with row,col coordinates relative one of the
    following:
   "editor" the global editor grid
   "win"    a window. Use `win` to specify a window id,
            or the current window will be used by default.
   "cursor" the cursor position in current window.
`win`: When using relative='win', window id of the window where the
    position is defined.
`anchor`: The corner of the float that the row,col position defines:
   "NW" north-west (default)
   "NE" north-east
   "SW" south-west
   "SE" south-east
`height`: window height (in character cells). Minimum of 1.
`width`: window width (in character cells). Minimum of 2.
`row`: row position. Screen cell height are used as unit. Can be
    floating point.
`col`: column position. Screen cell width is used as unit. Can be
    floating point.
`focusable`: Whether window can be focused by wincmds and
    mouse events. Defaults to true. Even if set to false, the window
    can still be entered using |nvim_set_current_win()| API call.
`external`: GUI should display the window as an external
    top-level window. Currently accepts no other positioning
    configuration together with this.

With editor positioning row=0, col=0 refers to the top-left corner of the screen-grid and row=Lines-1, Columns-1 refers to the bottom-right corner. Floating point values are allowed, but the builtin implementation (used by TUI and GUIs without multigrid support) will always round down to nearest integer.

Out-of-bounds values, and configurations that make the float not fit inside the main editor, are allowed. The builtin implementation will truncate values so floats are completely within the main screen grid. External GUIs could let floats hover outside of the main window like a tooltip, but this should not be used to specify arbitrary WM screen positions.

Parameters
[out]errError details, if any
Returns
the window handle or 0 when error
void nvim_out_write ( String  str)

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

Parameters
strMessage
Dictionary nvim_parse_expression ( String  expr,
String  flags,
Boolean  highlight,
Error err 
)

Parse a VimL expression.

Parameters
[in]exprExpression to parse. Is always treated as a single line.
[in]flagsFlags:
               - "m" if multiple expressions in a row are allowed (only
                 the first one will be parsed),
               - "E" if EOC tokens are not allowed (determines whether
                 they will stop parsing process or be recognized as an
                 operator/space, though also yielding an error).
               - "l" when needing to start parsing with lvalues for
                 ":let" or ":for".

               Common flag sets:
               - "m" to parse like for ":echo".
               - "E" to parse like for "<C-r>=".
               - empty string for ":call".
               - "lm" to parse for ":let".
[in]highlightIf true, return value will also include "highlight" key containing array of 4-tuples (arrays) (Integer, Integer, Integer, String), where first three numbers define the highlighted region and represent line, starting column and ending column (latter exclusive: one should highlight region [start_col, end_col)).
Returns
AST: top-level dictionary with these keys:
    "error": Dictionary with error, present only if parser saw some
             error. Contains the following keys:

      "message": String, error message in printf format, translated.
                 Must contain exactly one "%.*s".
      "arg": String, error message argument.

    "len": Amount of bytes successfully parsed. With flags equal to ""
           that should be equal to the length of expr string.

           @note: “Sucessfully parsed” here means “participated in AST
                  creation”, not “till the first error”.

    "ast": AST, either nil or a dictionary with these keys:

      "type": node type, one of the value names from ExprASTNodeType
              stringified without "kExprNode" prefix.
      "start": a pair [line, column] describing where node is “started”
               where "line" is always 0 (will not be 0 if you will be
               using nvim_parse_viml() on e.g. ":let", but that is not
               present yet). Both elements are Integers.
      "len": “length” of the node. This and "start" are there for
             debugging purposes primary (debugging parser and providing
             debug information).
      "children": a list of nodes described in top/"ast". There always
                  is zero, one or two children, key will not be present
                  if node has no children. Maximum number of children
                  may be found in node_maxchildren array.

      Local values (present only for certain nodes):

      "scope": a single Integer, specifies scope for "Option" and
               "PlainIdentifier" nodes. For "Option" it is one of
               ExprOptScope values, for "PlainIdentifier" it is one of
               ExprVarScope values.
      "ident": identifier (without scope, if any), present for "Option",
               "PlainIdentifier", "PlainKey" and "Environment" nodes.
      "name": Integer, register name (one character) or -1. Only present
              for "Register" nodes.
      "cmp_type": String, comparison type, one of the value names from
                  ExprComparisonType, stringified without "kExprCmp"
                  prefix. Only present for "Comparison" nodes.
      "ccs_strategy": String, case comparison strategy, one of the
                      value names from ExprCaseCompareStrategy,
                      stringified without "kCCStrategy" prefix. Only
                      present for "Comparison" nodes.
      "augmentation": String, augmentation type for "Assignment" nodes.
                      Is either an empty string, "Add", "Subtract" or
                      "Concat" for "=", "+=", "-=" or ".=" respectively.
      "invert": Boolean, true if result of comparison needs to be
                inverted. Only present for "Comparison" nodes.
      "ivalue": Integer, integer value for "Integer" nodes.
      "fvalue": Float, floating-point value for "Float" nodes.
      "svalue": String, value for "SingleQuotedString" and
                "DoubleQuotedString" nodes.  
String nvim_replace_termcodes ( String  str,
Boolean  from_part,
Boolean  do_lt,
Boolean  special 
)

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

Parameters
strString to be converted.
from_partLegacy Vim parameter. Usually true.
do_ltAlso translate <lt>. Ignored if special is false.
specialReplace |keycodes|, e.g. <CR> becomes a "\n" char.
See also
replace_termcodes
cpoptions
void nvim_select_popupmenu_item ( Integer  item,
Boolean  insert,
Boolean  finish,
Dictionary  opts,
Error err 
)

Selects an item in the completion popupmenu.

If |ins-completion| is not active this API call is silently ignored. Useful for an external UI using |ui-popupmenu| to control the popupmenu with the mouse. Can also be used in a mapping; use <cmd> |:map-cmd| to ensure the mapping doesn't end completion mode.

Parameters
itemIndex (zero-based) of the item to select. Value of -1 selects nothing and restores the original text.
insertWhether the selection should be inserted in the buffer.
finishFinish the completion and dismiss the popupmenu. Implies insert.
optsOptional parameters. Reserved for future use.
void nvim_set_client_info ( uint64_t  channel_id,
String  name,
Dictionary  version,
String  type,
Dictionary  methods,
Dictionary  attributes,
Error err 
)

Identify the client for nvim. Can be called more than once, but subsequent calls will remove earlier info, which should be resent if it is still valid. (This could happen if a library first identifies the channel, and a plugin using that library later overrides that info)

Parameters
nameshort name for the connected client
versionDictionary describing the version, with the following possible keys (all optional)
  • "major" major version (defaults to 0 if not set, for no release yet)
  • "minor" minor version
  • "patch" patch number
  • "prerelease" string describing a prerelease, like "dev" or "beta1"
  • "commit" hash or similar identifier of commit
typeMust be one of the following values. A client library should use "remote" if the library user hasn't specified other value.
  • "remote" remote client that connected to nvim.
  • "ui" gui frontend
  • "embedder" application using nvim as a component, for instance IDE/editor implementing a vim mode.
  • "host" plugin host, typically started by nvim
  • "plugin" single plugin, started by nvim
methodsBuiltin methods in the client. For a host, this does not include plugin methods which will be discovered later. The key should be the method name, the values are dicts with the following (optional) keys:
  • "async" if true, send as a notification. If false or unspecified, use a blocking request
  • "nargs" Number of arguments. Could be a single integer or an array two integers, minimum and maximum inclusive. Further keys might be added in later versions of nvim and unknown keys are thus ignored. Clients must only use keys defined in this or later versions of nvim!
attributesInformal attributes describing the client. Clients might define their own keys, but the following are suggested:
  • "website" Website of client (for instance github repository)
  • "license" Informal description of the license, such as "Apache 2", "GPLv3" or "MIT"
  • "logo" URI or path to image, preferably small logo or icon. .png or .svg format is preferred.
void nvim_set_current_buf ( Buffer  buffer,
Error err 
)

Sets the current buffer.

Parameters
bufferBuffer handle
[out]errError details, if any
void nvim_set_current_dir ( String  dir,
Error err 
)

Changes the global working directory.

Parameters
dirDirectory path
[out]errError details, if any
void nvim_set_current_line ( String  line,
Error err 
)

Sets the current line.

Parameters
lineLine contents
[out]errError details, if any
void nvim_set_current_tabpage ( Tabpage  tabpage,
Error err 
)

Sets the current tabpage.

Parameters
tabpageTabpage handle
[out]errError details, if any
void nvim_set_current_win ( Window  window,
Error err 
)

Sets the current window.

Parameters
windowWindow handle
void nvim_set_option ( uint64_t  channel_id,
String  name,
Object  value,
Error err 
)

Sets an option value.

Parameters
nameOption name
valueNew option value
[out]errError details, if any
void nvim_set_var ( String  name,
Object  value,
Error err 
)

Sets a global (g:) variable.

Parameters
nameVariable name
valueVariable value
[out]errError details, if any
void nvim_set_vvar ( String  name,
Object  value,
Error err 
)

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

Parameters
nameVariable name
valueVariable value
[out]errError details, if any
Integer nvim_strwidth ( String  text,
Error err 
)

Calculates the number of display cells occupied by text. <Tab> counts as one cell.

Parameters
textSome text
[out]errError details, if any
Returns
Number of cells
void nvim_subscribe ( uint64_t  channel_id,
String  event 
)

Subscribes to event broadcasts.

Parameters
channel_idChannel id (passed automatically by the dispatcher)
eventEvent type string
void nvim_unsubscribe ( uint64_t  channel_id,
String  event 
)

Unsubscribes to event broadcasts.

Parameters
channel_idChannel id (passed automatically by the dispatcher)
eventEvent type string
Object vim_del_var ( String  name,
Error err 
)
Object vim_set_var ( String  name,
Object  value,
Error err 
)
Deprecated:
See also
nvim_set_var
Returns
Old value or nil if there was no previous value.
Warning
May return nil if there was no previous value OR if previous value was v:null.