robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
175.0 KiB4413 linesraw
1*api.txt*               Nvim
2
3
4                 NVIM REFERENCE MANUAL    by Thiago de Arruda
5
6
7Nvim API                                                           *API* *api*
8
9Nvim exposes a powerful API that can be used by plugins and external processes
10via |RPC|, |Lua| and Vimscript (|eval-api|).
11
12Applications can also embed libnvim to work with the C API directly.
13
14                                      Type |gO| to see the table of contents.
15
16==============================================================================
17API Usage                                               *api-rpc* *RPC* *rpc*
18
19                                                        *msgpack-rpc*
20RPC is the main way to control Nvim programmatically.  Nvim implements the
21MessagePack-RPC protocol with these extra (out-of-spec) constraints:
22
231. Responses must be given in reverse order of requests (like "unwinding
24   a stack").
252. Nvim processes all messages (requests and notifications) in the order they
26   are received.
27
28MessagePack-RPC specification:
29  https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md
30  https://github.com/msgpack/msgpack/blob/0b8f5ac/spec.md
31
32Many clients use the API: user interfaces (GUIs), remote plugins, scripts like
33"nvr" (https://github.com/mhinz/neovim-remote).  Even Nvim itself can control
34other Nvim instances.  API clients can:
35
36  - Call any API function
37  - Listen for events
38  - Receive remote calls from Nvim
39
40The RPC API is like a more powerful version of Vim's "clientserver" feature.
41
42CONNECTING                                              *rpc-connecting*
43
44See |channel-intro| for various ways to open a channel. Channel-opening
45functions take an `rpc` key in the options dict. RPC channels can also be
46opened by other processes connecting to TCP/IP sockets or named pipes listened
47to by Nvim.
48
49Nvim creates a default RPC socket at |startup|, given by |v:servername|. To
50start with a TCP/IP socket instead, use |--listen| with a TCP-style address: >
51    nvim --listen 127.0.0.1:6666
52More endpoints can be started with |serverstart()|.
53
54Note that localhost TCP sockets are generally less secure than named pipes,
55and can lead to vulnerabilities like remote code execution.
56
57Connecting to the socket is the easiest way a programmer can test the API,
58which can be done through any msgpack-rpc client library or full-featured
59|api-client|. Here's a Ruby script that prints "hello world!" in the current
60Nvim instance:
61>ruby
62    #!/usr/bin/env ruby
63    # Requires msgpack: gem install msgpack
64    #
65    # To run this script, use Nvim's built-in terminal emulator:
66    #
67    #   :term ruby hello.rb
68    #
69    # Or from another shell by setting NVIM:
70    # :echo v:servername -- this is the unix socket path address
71    # $ NVIM=[unix_socket_path_address] ruby ./hello.rb
72    # or if you run the command above: nvim --listen 127.0.0.1:6666 -- tcp socket address
73    # $ NVIM=127.0.0.1:6666 ruby hello.rb
74
75    require 'msgpack'
76    require 'socket'
77
78    sock =
79    if ENV['NVIM'] =~ /:\d+$/
80        host, port = ENV['NVIM'].split(':')
81        TCPSocket.new(host, port)
82    else
83        UNIXSocket.new(ENV['NVIM'])
84    end
85    sock.write([0, 0, 'nvim_command', ['echo "hello world!"']].to_msgpack)
86    p MessagePack::Unpacker.new(sock).read.last
87<
88Another way is to use the Python REPL with the "pynvim" package, where API
89functions can be called interactively (requires `pip install pynvim` or
90`uv add pynvim`): >
91
92    >>> from pynvim import attach
93    >>> nvim = attach('socket', path='[address]')
94    >>> nvim.command('echo "hello world!"')
95<
96You can also embed Nvim via |jobstart()|, and communicate using |rpcrequest()|
97and |rpcnotify()|:
98>vim
99    let nvim = jobstart(['nvim', '--embed'], {'rpc': v:true})
100    echo rpcrequest(nvim, 'nvim_eval', '"Hello " . "world!"')
101    call jobstop(nvim)
102<
103
104==============================================================================
105API Definitions                                         *api-definitions*
106
107                                                        *api-types*
108The Nvim C API defines custom types for all function parameters. Some are just
109typedefs around C99 standard types, others are Nvim-defined data structures.
110
111Basic types ~
112>
113  API Type                              C type
114  ------------------------------------------------------------------------
115  Nil
116  Boolean                               bool
117  Integer (signed 64-bit integer)       int64_t
118  Float (IEEE 754 double precision)     double
119  String                                {char* data, size_t size} struct
120  Array                                 kvec
121  Dict (msgpack: map)                   kvec
122  Object                                any of the above
123<
124  Note:
125    - Empty Array is accepted as a valid Dictionary parameter.
126    - Functions cannot cross RPC boundaries. But API functions (e.g.
127      |nvim_create_autocmd()|) may support Lua function parameters for non-RPC
128      invocations.
129
130Special types (msgpack EXT) ~
131
132  These are integer typedefs discriminated as separate Object subtypes. They
133  can be treated as opaque integers, but are mutually incompatible: Buffer may
134  be passed as an integer but not as Window or Tabpage.
135
136  The EXT object data is the (integer) object handle. The EXT type codes given
137  in the |api-metadata| `types` key are stable: they will not change and are
138  thus forward-compatible.
139>
140  EXT Type      C type                                  Data
141  ------------------------------------------------------------------------
142  Buffer        enum value kObjectTypeBuffer            |bufnr()|
143  Window        enum value kObjectTypeWindow            |window-ID|
144  Tabpage       enum value kObjectTypeTabpage           internal handle
145<
146
147                                                        *api-indexing*
148Most of the API uses 0-based indices, and ranges are end-exclusive. For the
149end of a range, -1 denotes the last line/column. A column in buffer text is a
150byte index, not a character index or screen cell. See |vim.pos|, |vim.range|
151for representing and converting positions.
152
153Exception: the following API functions use "mark-like" indexing (1-based
154lines, 0-based columns, see also |vim.pos.mark()|):
155
156- |nvim_get_mark()|
157- |nvim_buf_get_mark()|
158- |nvim_buf_set_mark()|
159- |nvim_win_get_cursor()|
160- |nvim_win_set_cursor()|
161
162Exception: the following API functions use |extmarks| indexing (0-based
163indices, end-inclusive, see also |vim.pos.extmark()|):
164
165- |nvim_buf_del_extmark()|
166- |nvim_buf_get_extmark_by_id()|
167- |nvim_buf_get_extmarks()|
168- |nvim_buf_set_extmark()|
169
170                                              *api-fast* *deferred* *schedule*
171Most API functions are deferred: they are queued ("scheduled") on the main
172loop and processed sequentially with normal input. If the editor is waiting
173for user input in a "modal" fashion (e.g. an |input()| prompt), a deferred
174request will block.
175- Non-deferred (fast) functions such |nvim_get_mode()|, |nvim_input()|, or any
176  Lua callback, are executed immediately (not sequenced in the input queue).
177- Lua code can use |vim.in_fast_event()| to detect a fast context, where it
178  may interact with Lua state but not "editor" state (|textlock|, options,
179  window layout, …).
180- To perform editor operations, Lua code must schedule via |vim.defer_fn()| or
181  |vim.schedule()|, or wait until `vim.in_fast_event()` returns `false`.
182
183==============================================================================
184API metadata                                            *api-metadata*
185
186The Nvim C API is automatically exposed to RPC by the build system, which
187parses headers in src/nvim/api/* and generates dispatch-functions mapping RPC
188API method names to public C API functions, converting/validating arguments
189and return values.
190
191Nvim exposes its API metadata as a Dictionary with these items:
192
193- version                 Nvim version, API level/compatibility
194- version.api_level       API version integer *api-level*
195- version.api_compatible  API is backwards-compatible with this level
196- version.api_prerelease  Declares the API as unstable/unreleased
197                          `(version.api_prerelease && fn.since == version.api_level)`
198- functions               API function signatures, containing |api-types| info
199                          describing the return value and parameters.
200- ui_events               |UI| event signatures
201- ui_options              Supported |ui-option|s
202- {fn}.since              API level where function {fn} was introduced
203- {fn}.deprecated_since   API level where function {fn} was deprecated
204- types                   Custom handle types defined by Nvim
205- error_types             Possible error types returned by API functions
206
207About the `functions` map:
208
209  - Container types may be decorated with type/size constraints, e.g.
210    ArrayOf(Buffer) or ArrayOf(Integer, 2).
211  - Each function `parameters` item is a `[type, name, optional]` tuple.
212  - Functions considered to be methods that operate on instances of Nvim
213    special types (msgpack EXT) have the "method=true" flag. The receiver type
214    is that of the first argument. Method names are prefixed with `nvim_` plus
215    a type name, e.g. `nvim_buf_get_lines` is the `get_lines` method of
216    a Buffer instance. |dev-api|
217  - Global functions have the "method=false" flag and are prefixed with just
218    `nvim_`, e.g. `nvim_list_bufs`.
219
220                                                        *api-mapping*
221External programs (clients) can use the metadata to discover the API, using
222any of these approaches:
223
2241. Connect to a running Nvim instance and call |nvim_get_api_info()| via
225   msgpack-RPC. This is best for clients written in dynamic languages which
226   can define functions at runtime.
2272. Use the |--api-info| startup arg. Useful for statically-compiled clients.
228   Example (requires Python "pyyaml" and "msgpack-python" modules): >
229     nvim --api-info | python -c 'import msgpack, sys, yaml; yaml.dump(msgpack.unpackb(sys.stdin.buffer.read()), sys.stdout)'
2303. Use the |api_info()| function. >vim
231     :lua vim.print(vim.fn.api_info())
232     " Example using filter() to exclude non-deprecated API functions:
233     :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val.name')
234<
235
236==============================================================================
237API contract                                                     *api-contract*
238
239The Nvim API is composed of functions and events.
240
241- Clients call functions like those described at |api-global|.
242- Clients can subscribe to |ui-events|, |api-buffer-updates|, etc.
243- API function names are prefixed with "nvim_".
244- API event names are prefixed with "nvim_" and suffixed with "_event".
245
246As Nvim evolves the API may change in compliance with this CONTRACT:
247
248- New functions and events may be added.
249  - Any such extensions are OPTIONAL: old clients may ignore them.
250- New functions MAY CHANGE before release. Clients can dynamically check
251  `api_prerelease`, |api-metadata|.
252- Function signatures will NOT CHANGE after release, except as follows:
253  - Map/list parameters/results may be EXTENDED (new fields may be added).
254    - Such new fields are OPTIONAL: old clients MAY ignore them.
255    - Existing fields will not be removed.
256  - Return type MAY CHANGE from void to non-void. Old clients MAY ignore the
257    new return value.
258  - An optional `opts` parameter may be ADDED.
259  - Optional parameters may be ADDED following an `opts` parameter.
260  - The `opts` parameter and any following parameters MAY BE OMITTED by the
261    client (equivalent to passing an empty dict). Explicitly passing a nil
262    value is an error.
263- Event parameters will not be removed or reordered (after release).
264- Events may be EXTENDED: new parameters may be added.
265- Deprecated functions will not be removed until Nvim 2.0.
266
267"Private" interfaces are NOT covered by this contract:
268
269- Undocumented (not in :help) functions or events of any kind
270- nvim__x ("double underscore") functions
271
272The idea is "versionless evolution", in the words of Rich Hickey:
273- Relaxing a requirement should be a compatible change.
274- Strengthening a promise should be a compatible change.
275
276==============================================================================
277Buffer update events                                    *api-buffer-updates*
278
279API clients can "attach" to Nvim buffers to subscribe to buffer update events.
280This is similar to |TextChanged| but more powerful and granular.
281
282Call |nvim_buf_attach()| to receive these events on the channel:
283
284                                                        *nvim_buf_lines_event*
285nvim_buf_lines_event[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}, {more}]
286    When the buffer text between {firstline} and {lastline} (end-exclusive,
287    zero-indexed) were changed to the new text in the {linedata} list. The
288    granularity is a line, i.e. if a single character is changed in the
289    editor, the entire line is sent.
290
291    When {changedtick} is |v:null| this means the screen lines (display)
292    changed but not the buffer contents. {linedata} contains the changed
293    screen lines. This happens when 'inccommand' shows a buffer preview.
294
295    Parameters: ~
296      • {buf}         (`integer`) Buffer id
297      • {changedtick} (`integer`) Value of |b:changedtick|. If you send an API
298                      command back to Nvim you can check |b:changedtick| as
299                      part of your request to ensure that no other changes
300                      have been made.
301      • {firstline}   (`integer`) The first line that was replaced.
302                      Zero-indexed: if line 1 was replaced then {firstline}
303                      will be zero, not one. Always less than or equal to
304                      the number of lines that were in the buffer before the
305                      lines were replaced.
306      • {lastline}    (`integer`) The first line that was not replaced (i.e.
307                      the range {firstline}, {lastline} is end-exclusive).
308                      Zero-indexed: if line numbers 2 to 5 were replaced,
309                      this will be 5 instead of 6. Always less than or equal
310                      to the number of lines that were in the buffer before
311                      the lines were replaced. Will be -1 if the event is
312                      part of the initial update after attaching.
313      • {linedata}    (`string[]`) Contents of the new buffer lines. Newline
314                      characters are omitted; empty lines are sent as empty
315                      strings.
316      • {more}        (`boolean`) true for a "multipart" change notification:
317                      the current change was chunked into multiple
318                      |nvim_buf_lines_event| notifications (e.g. because it
319                      was too big).
320
321nvim_buf_changedtick_event[{buf}, {changedtick}]  *nvim_buf_changedtick_event*
322    When |b:changedtick| was incremented but no text was changed. Relevant for
323    undo/redo.
324
325    Parameters: ~
326      • {buf}         (`integer`) Buffer id
327      • {changedtick} (`integer`) New value of |b:changedtick|.
328
329nvim_buf_detach_event[{buf}]                           *nvim_buf_detach_event*
330    When buffer is detached (i.e. updates are disabled). Triggered explicitly by
331    |nvim_buf_detach()| or implicitly in these cases:
332    - Buffer was |abandon|ed and 'hidden' is not set.
333    - Buffer was reloaded, e.g. with |:edit| or an external change triggered
334      |:checktime| or 'autoread'.
335    - Generally: whenever the buffer contents are unloaded from memory.
336
337    Parameters: ~
338      • {buf}         (`integer`) Buffer id
339
340
341EXAMPLE ~
342
343Calling |nvim_buf_attach()| with send_buffer=true on an empty buffer, emits: >
344    nvim_buf_lines_event[{buf}, {changedtick}, 0, -1, [""], v:false]
345
346User adds two lines to the buffer, emits: >
347    nvim_buf_lines_event[{buf}, {changedtick}, 0, 0, ["line1", "line2"], v:false]
348
349User moves to a line containing the text "Hello world" and inserts "!", emits: >
350    nvim_buf_lines_event[{buf}, {changedtick}, {linenr}, {linenr} + 1,
351                         ["Hello world!"], v:false]
352
353User moves to line 3 and deletes 20 lines using "20dd", emits: >
354    nvim_buf_lines_event[{buf}, {changedtick}, 2, 22, [], v:false]
355
356User selects lines 3-5 using |linewise-visual| mode and then types "p" to
357paste a block of 6 lines, emits: >
358    nvim_buf_lines_event[{buf}, {changedtick}, 2, 5,
359      ['pasted line 1', 'pasted line 2', 'pasted line 3', 'pasted line 4',
360       'pasted line 5', 'pasted line 6'],
361      v:false
362    ]
363
364User reloads the buffer with ":edit", emits: >
365    nvim_buf_detach_event[{buf}]
366<
367
368LUA ~
369                                                        *api-buffer-updates-lua*
370In-process plugins can receive buffer updates via Lua callbacks. These
371callbacks are called frequently in various contexts; |textlock| prevents
372changing buffer contents and window layout (such operations must be
373|schedule|d). Moving the cursor is allowed, but it is restored afterwards.
374
375|nvim_buf_attach()| will take keyword args for the callbacks. "on_lines" will
376receive parameters ("lines", {buf}, {changedtick}, {firstline}, {lastline},
377{new_lastline}, {old_byte_size} [, {old_utf32_size}, {old_utf16_size}]).
378Unlike remote channel events the text contents are not passed. The new text can
379be accessed inside the callback as >lua
380
381    vim.api.nvim_buf_get_lines(buf, firstline, new_lastline, true)
382<
383{old_byte_size} is the total size of the replaced region {firstline} to
384{lastline} in bytes, including the final newline after {lastline}. if
385`utf_sizes` is set to true in |nvim_buf_attach()| keyword args, then the
386UTF-32 and UTF-16 sizes of the deleted region is also passed as additional
387arguments {old_utf32_size} and {old_utf16_size}.
388
389"on_changedtick" is invoked when |b:changedtick| was incremented but no text
390was changed. The parameters received are ("changedtick", {buf}, {changedtick}).
391
392                                                        *api-lua-detach*
393In-process Lua callbacks can detach by returning `true`. This will detach all
394callbacks attached with the same |nvim_buf_attach()| call without invoking the
395"on_detach" callback.
396
397
398==============================================================================
399Buffer highlighting                                            *api-highlights*
400
401Nvim allows plugins to add position-based highlights to buffers. This is
402similar to |matchaddpos()| but with some key differences. The added highlights
403are associated with a buffer and adapts to line insertions and deletions,
404similar to signs. It is also possible to manage a set of highlights as a group
405and delete or replace all at once.
406
407The intended use case are linter or semantic highlighter plugins that monitor
408a buffer for changes, and in the background compute highlights to the buffer.
409Another use case are plugins that show output in an append-only buffer, and
410want to add highlights to the outputs. Highlight data cannot be preserved
411on writing and loading a buffer to file, nor in undo/redo cycles.
412
413Highlights are registered using the |nvim_buf_set_extmark()| function, which
414adds highlights as |extmarks|. If highlights need to be tracked or manipulated
415after adding them, the returned |extmark| id can be used. >lua
416  -- create the highlight through an extmark
417  extid = vim.api.nvim_buf_set_extmark(buf, ns_id, line, col_start, {end_col = col_end, hl_group = hl_group})
418
419  -- example: modify the extmark's highlight group
420  vim.api.nvim_buf_set_extmark(buf, ns_id, line, col_start, {end_col = col_end, hl_group = NEW_HL_GROUP, id = extid})
421
422  -- example: change the highlight's position
423  vim.api.nvim_buf_set_extmark(buf, ns_id, NEW_LINE, col_start, {end_col = col_end, hl_group = NEW_HL_GROUP, id = extid})
424<
425
426See also |vim.hl.range()|.
427
428==============================================================================
429Floating windows        *api-floatwin* *floating-windows* *E5601* *E5602*
430
431Floating windows ("floats") are displayed on top of normal windows.  This is
432useful to implement simple widgets, such as tooltips displayed next to the
433cursor. Floats are fully functional windows supporting user editing, common
434|api-window| calls, and most window options (except 'statusline').
435
436Two ways to create a floating window:
437- |nvim_open_win()| creates a new window (needs a buffer, see |nvim_create_buf()|)
438- |nvim_win_set_config()| reconfigures a normal window into a float
439
440To close it use |nvim_win_close()| or a command such as |:close|.
441
442To check whether a window is floating, check whether the `relative` option in
443its config is non-empty: >lua
444
445    if vim.api.nvim_win_get_config(window_id).relative ~= '' then
446      -- window with this window_id is floating
447    end
448<
449
450Buffer text can be highlighted by typical mechanisms (syntax highlighting,
451|api-highlights|). The |hl-NormalFloat| group highlights normal text;
452'winhighlight' can be used as usual to override groups locally. Floats inherit
453options from the current window; specify `style=minimal` in |nvim_open_win()|
454to disable various visual features such as the 'number' column.
455
456Other highlight groups specific to floating windows:
457- |hl-FloatBorder| for window's border
458- |hl-FloatTitle| for window's title
459- |hl-FloatFooter| for window's footer
460
461Currently, floating windows don't support some widgets like scrollbar.
462
463The output of |:mksession| does not include commands for restoring floating
464windows.
465
466Example: create a float with scratch buffer: >vim
467
468    let buf = nvim_create_buf(v:false, v:true)
469    call nvim_buf_set_lines(buf, 0, -1, v:true, ["test", "text"])
470    let opts = {'relative': 'cursor', 'width': 10, 'height': 2, 'col': 0,
471        \ 'row': 1, 'anchor': 'NW', 'style': 'minimal'}
472    let win = nvim_open_win(buf, 0, opts)
473    " optional: change highlight, otherwise Pmenu is used
474    call nvim_set_option_value('winhl', 'Normal:MyHighlight', {'win': win})
475<
476
477==============================================================================
478Extended marks                       *api-extended-marks* *extmarks* *extmark*
479
480Extended marks (extmarks) represent buffer annotations that track text changes
481in the buffer. They can represent cursors, folds, misspelled words, anything
482that needs to track a logical location in the buffer over time. |api-indexing|
483
484Extmark position works like a "vertical bar" cursor: it exists between
485characters. Thus, the maximum extmark index on a line is 1 more than the
486character index: >
487
488     f o o b a r      line contents
489     0 1 2 3 4 5      character positions (0-based)
490    0 1 2 3 4 5 6     extmark positions (0-based)
491
492Extmarks have "forward gravity": if you place the cursor directly on an
493extmark position and enter some text, the extmark migrates forward. >
494
495     f o o|b a r      line (| = cursor)
496          3           extmark
497
498     f o o z|b a r    line (| = cursor)
499            4         extmark (after typing "z")
500
501If an extmark is on the last index of a line and you input a newline at that
502point, the extmark will accordingly migrate to the next line: >
503
504     f o o z b a r|   line (| = cursor)
505                  7   extmark
506
507     f o o z b a r    first line
508                      extmarks (none present)
509     |                second line (| = cursor)
510     0                extmark (after typing <CR>)
511
512
513Example:
514
515Let's set an extmark at the first row (row=0) and third column (column=2).
516|api-indexing| Passing id=0 creates a new mark and returns the id: >
517
518      01 2345678
519    0 ex|ample..
520        ^ extmark position
521<
522>vim
523    let g:mark_ns = nvim_create_namespace('myplugin')
524    let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 2)
525<
526We can get the mark by its id: >vim
527
528    echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id)
529    " => [0, 2]
530
531We can get all marks in a buffer by |namespace| (or by a range): >vim
532
533    echo nvim_buf_get_extmarks(0, g:mark_ns, 0, -1)
534    " => [[1, 0, 2]]
535
536Deleting all surrounding text does NOT remove an extmark! To remove extmarks
537use |nvim_buf_del_extmark()|. Deleting "x" in our example: >
538
539      0 12345678
540    0 e|ample..
541       ^ extmark position
542<
543>vim
544    echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id)
545    " => [0, 1]
546<
547    Note: Extmark "gravity" decides how it will shift after a text edit.
548          See |nvim_buf_set_extmark()|
549
550Namespaces allow any plugin to manage only its own extmarks, ignoring those
551created by another plugin.
552
553Extmark positions changed by an edit will be restored on undo/redo. Creating
554and deleting extmarks is not a buffer change, thus new undo states are not
555created for extmark changes.
556
557==============================================================================
558Global Events                                                     *api-events*
559
560nvim_error_event({type}, {msg})                             *nvim_error_event*
561    Emitted on the client channel if an async API request responds with an
562    error.
563
564    Attributes: ~
565        |RPC| only
566
567    Parameters: ~
568      • {type}  (`integer`) Error type id as defined by
569                `api_info().error_types`.
570      • {msg}   (`string`) Error message.
571
572nvim_ui_term_event({event}, {value})                      *nvim_ui_term_event*
573    Emitted by the TUI client to signal when a host-terminal event occurred.
574
575    Supports these events:
576    • "termresponse": The host-terminal sent an OSC, DCS, APC, or recognized
577      CSI (DA1, kitty multiple-cursors) response to Nvim. The payload is the
578      received response. Sets |v:termresponse| and fires |TermResponse|.
579
580    Attributes: ~
581        |RPC| only
582        Since: 0.10.0
583
584    Parameters: ~
585      • {event}  (`string`) Event name
586      • {value}  (`any`) Event payload
587
588
589==============================================================================
590Global Functions                                                  *api-global*
591
592nvim_chan_send({chan}, {data})                              *nvim_chan_send()*
593    Sends raw data to channel `chan`. |channel-bytes|
594    • For a job, it writes it to the stdin of the process.
595    • For the stdio channel |channel-stdio|, it writes to Nvim's stdout.
596    • For an internal terminal instance (|nvim_open_term()|) it writes
597      directly to terminal output.
598
599    This function writes raw data, not RPC messages. Use |vim.rpcrequest()|
600    and |vim.rpcnotify()| if the channel expects RPC messages (i.e. it was
601    created with `rpc=true`).
602
603    To write data to the |TUI| host terminal, see |nvim_ui_send()|.
604
605    Attributes: ~
606        |RPC| only
607        Lua |vim.api| only
608        Since: 0.5.0
609
610    Parameters: ~
611      • {chan}  (`integer`) Channel id
612      • {data}  (`string`) Data to write. 8-bit clean: may contain NUL bytes.
613
614nvim_create_buf({listed}, {scratch})                       *nvim_create_buf()*
615    Creates a new, empty, unnamed buffer.
616
617    Attributes: ~
618        Since: 0.4.0
619
620    Parameters: ~
621      • {listed}   (`boolean`) Sets 'buflisted'
622      • {scratch}  (`boolean`) Creates a "throwaway" |scratch-buffer| for
623                   temporary work (always 'nomodified'). Also sets
624                   'nomodeline' on the buffer.
625
626    Return: ~
627        (`integer`) Buffer id, or 0 on error
628
629nvim_del_current_line()                              *nvim_del_current_line()*
630    Deletes the current line.
631
632    Attributes: ~
633        not allowed when |textlock| is active
634        Since: 0.1.0
635
636nvim_del_keymap({mode}, {lhs}, {opts})                     *nvim_del_keymap()*
637    Unmaps a global |mapping| for the given mode.
638
639    To unmap a buffer-local mapping, use |nvim_buf_del_keymap()|.
640
641    Attributes: ~
642        Since: 0.4.0
643
644    Parameters: ~
645      • {mode}  (`string`) Mode short-name ("n", "i", "v", ...)
646      • {lhs}   (`string`) Left-hand-side |{lhs}| of the mapping.
647      • {opts}  (`vim.api.keyset.keymap_del?`) Optional parameters.
648                • lhs: When true, only match {lhs}, not {rhs}.
649
650    See also: ~
651      • |nvim_set_keymap()|
652
653nvim_del_mark({name})                                        *nvim_del_mark()*
654    Deletes an uppercase/file named mark. See |mark-motions|.
655
656    Note: ~
657      • Lowercase name (or other buffer-local mark) is an error.
658
659    Attributes: ~
660        Since: 0.6.0
661
662    Parameters: ~
663      • {name}  (`string`) Mark name
664
665    Return: ~
666        (`boolean`) true if the mark was deleted, else false.
667
668    See also: ~
669      • |nvim_buf_del_mark()|
670      • |nvim_get_mark()|
671
672nvim_del_var({name})                                          *nvim_del_var()*
673    Removes a global (g:) variable.
674
675    Attributes: ~
676        Since: 0.1.0
677
678    Parameters: ~
679      • {name}  (`string`) Variable name
680
681nvim_echo({chunks}, {history}, {opts})                           *nvim_echo()*
682    Prints a message given by a list of `[text, hl_group]` "chunks". Emits a
683    |Progress| event if `kind='progress'`.
684
685    Returns a message-id, which can be given in later calls to update an
686    existing message. The message-id is an autogenerated integer, or a
687    user-defined string. The id "address space" is global, so plugins
688    specifying a string id should use qualified names such as "my.msg.id" to
689    avoid unintentional conflicts.
690
691    Example: >lua
692        vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true)
693<
694
695    Attributes: ~
696        Since: 0.5.0
697
698    Parameters: ~
699      • {chunks}   (`[string, integer|string?][]`) List of `[text, hl_group]`
700                   pairs, where each is a `text` string highlighted by the
701                   (optional) name or ID `hl_group`.
702      • {history}  (`boolean`) if true, add to |message-history|.
703      • {opts}     (`vim.api.keyset.echo_opts?`) Optional parameters.
704                   • data (`table?`) Dict of arbitrary data, available in
705                     |Progress| |event-data|.
706                   • err (`boolean?`) Treat the message like `:echoerr`. Sets
707                     `hl_group` to |hl-ErrorMsg| by default.
708                   • id (`integer|string?`) Message-id returned by a previous
709                     `nvim_echo` call, or a user-defined id (string). If
710                     existing message has this id, it will be updated instead
711                     of creating a new message.
712                   • kind (`string?`) Decides the |ui-messages| kind in the
713                     emitted message. Set "progress" to emit a
714                     |progress-message|.
715                   • percent (`integer?`) |progress-message| percentage, or
716                     nil to signal "unknown progress".
717                   • source (`string?`) |progress-message| source.
718                   • status (`string?`) |progress-message| status:
719                     • "success": Process completed successfully.
720                     • "running": Process is ongoing.
721                     • "failed": Process failed.
722                     • "cancel": Process should be cancelled. Progress owner
723                       must handle the |Progress| event to perform the
724                       cancellation.
725                   • title (`string?`) Message title. Only for
726                     |progress-message| currently.
727                   • verbose (`boolean?`) Message is controlled by the
728                     'verbose' option. `nvim -V3log` will write the message to
729                     the "log" file instead of standard output.
730
731    Return: ~
732        (`integer|string`) Message-id, or -1 if message wasn't shown.
733
734nvim_eval_statusline({str}, {opts})                   *nvim_eval_statusline()*
735    Evaluates statusline string.
736
737    Attributes: ~
738        |api-fast|
739        Since: 0.6.0
740
741    Parameters: ~
742      • {str}   (`string`) Statusline string (see 'statusline').
743      • {opts}  (`vim.api.keyset.eval_statusline?`) Optional parameters.
744                • fillchar: (string) Character to fill blank spaces in the
745                  statusline (see 'fillchars'). Treated as single-width even
746                  if it isn't.
747                • highlights: (boolean) Return highlight information.
748                • maxwidth: (number) Maximum width of statusline.
749                • use_statuscol_lnum: (number) Evaluate statuscolumn for this
750                  line number instead of statusline.
751                • use_tabline: (boolean) Evaluate tabline instead of
752                  statusline. When true, {winid} is ignored. Mutually
753                  exclusive with {use_winbar}.
754                • use_winbar: (boolean) Evaluate winbar instead of statusline.
755                • winid: (number) |window-ID| of the window to use as context
756                  for statusline.
757
758    Return: ~
759        (`vim.api.keyset.eval_statusline_ret`) Dict containing statusline
760        information, with these keys:
761        • str: (string) Characters that will be displayed on the statusline.
762        • width: (number) Display width of the statusline.
763        • highlights: Array containing highlight information of the
764          statusline. Only included when the "highlights" key in {opts} is
765          true. Each element of the array is a |Dict| with these keys:
766          • start: (number) Byte index (0-based) of first character that uses
767            the highlight.
768          • group: (string) Deprecated. Use `groups` instead.
769          • groups: (array) Names of stacked highlight groups (highest
770            priority last).
771
772nvim_exec_lua({code}, {args})                                *nvim_exec_lua()*
773    Executes Lua code. Arguments are available as `...` inside the chunk. The
774    chunk can return a value.
775
776    Only statements are executed. To evaluate an expression, prefix it with
777    "return": `return my_function(...)`
778
779    Example: >lua
780        local peer = vim.fn.jobstart({ vim.v.progpath, '--clean', '--embed' }, { rpc=true })
781        vim.print(vim.rpcrequest(peer, 'nvim_exec_lua', [[
782              local a, b = ...
783              return ('result: %s'):format(a + b)
784            ]],
785            { 1, 3 }
786          )
787        )
788<
789
790    Attributes: ~
791        |RPC| only
792        Since: 0.5.0
793
794    Parameters: ~
795      • {code}  (`string`) Lua code to execute.
796      • {args}  (`any[]`) Arguments to the Lua code.
797
798    Return: ~
799        (`any`) Value returned by the Lua code (if any), or NIL.
800
801nvim_feedkeys({keys}, {mode}, {escape_ks})                   *nvim_feedkeys()*
802    Sends input-keys to Nvim, subject to various quirks controlled by `mode`
803    flags. This is a blocking call, unlike |nvim_input()|.
804
805    On execution error: does not fail, but updates v:errmsg.
806
807    To input keycodes like <C-o>, pass the result of
808    |nvim_replace_termcodes()|: >vim
809        :let key = nvim_replace_termcodes('<C-o>', v:true, v:false, v:true)
810        :call nvim_feedkeys(key, 'n', v:false)
811<
812
813    Attributes: ~
814        Since: 0.1.0
815
816    Parameters: ~
817      • {keys}       (`string`) Keys to send as input.
818      • {mode}       (`string`) Behavior flags, see |feedkeys()|.
819      • {escape_ks}  (`boolean`) If true, escape K_SPECIAL bytes in `keys`.
820                     Should be false if you used |nvim_replace_termcodes()|,
821                     else true.
822
823    See also: ~
824      • feedkeys()
825      • vim_strsave_escape_ks
826
827nvim_get_api_info()                                      *nvim_get_api_info()*
828    Returns a 2-tuple (Array), where item 0 is the current channel id and item
829    1 is the |api-metadata| map (Dict).
830
831    Attributes: ~
832        |api-fast|
833        |RPC| only
834        Since: 0.1.0
835
836    Return: ~
837        (`[any, any]`) 2-tuple `[{channel-id}, {api-metadata}]`
838
839nvim_get_chan_info({chan})                              *nvim_get_chan_info()*
840    Gets information about a channel.
841
842    See |nvim_list_uis()| for an example of how to get channel info.
843
844    Attributes: ~
845        Since: 0.3.0
846
847    Parameters: ~
848      • {chan}  (`integer`) channel_id, or 0 for current channel
849
850    Return: ~
851        (`table<string,any>`) Channel info dict with these keys:
852        • "id" Channel id.
853        • "argv" (optional) Job arguments list.
854        • "stream" Stream underlying the channel.
855          • "stdio" stdin and stdout of this Nvim instance
856          • "stderr" stderr of this Nvim instance
857          • "socket" TCP/IP socket or named pipe
858          • "job" Job with communication over its stdio.
859        • "mode" How data received on the channel is interpreted.
860          • "bytes" Send and receive raw bytes.
861          • "terminal" |terminal| instance interprets ASCII sequences.
862          • "rpc" |RPC| communication on the channel is active.
863        • "pty" (optional) Name of pseudoterminal. On a POSIX system this is a
864          device path like "/dev/pts/1". If unknown, the key will still be
865          present if a pty is used (e.g. for conpty on Windows).
866        • "buf" (optional) Buffer connected to |terminal| instance.
867        • "buffer" (optional) Deprecated alias for `buf`.
868        • "client" (optional) Info about the peer (client on the other end of
869          the channel), as set by |nvim_set_client_info()|.
870        • "exitcode" (optional) Exit code of the |terminal| process.
871
872nvim_get_color_by_name({name})                      *nvim_get_color_by_name()*
873    Returns the 24-bit RGB value of a |nvim_get_color_map()| color name or
874    "#rrggbb" hexadecimal string.
875
876    Example: >vim
877        :echo nvim_get_color_by_name("Pink")
878        :echo nvim_get_color_by_name("#cbcbcb")
879<
880
881    Attributes: ~
882        Since: 0.1.0
883
884    Parameters: ~
885      • {name}  (`string`) Color name or "#rrggbb" string
886
887    Return: ~
888        (`integer`) 24-bit RGB value, or -1 for invalid argument.
889
890nvim_get_color_map()                                    *nvim_get_color_map()*
891    Returns a map of color names and RGB values.
892
893    Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values
894    (e.g. 65535).
895
896    Attributes: ~
897        Since: 0.1.0
898
899    Return: ~
900        (`table<string,integer>`) Map of color names and RGB values.
901
902nvim_get_context({opts})                                  *nvim_get_context()*
903    Gets a map (msgpack encoding) of the current editor state:
904    • "bufs" |buffer-list|
905    • "funcs" Vimscript global and |script-local| functions
906    • "gvars" |global-variable|s
907    • "jumps" |jumplist|
908    • "regs" |registers|
909    • "sfuncs" Vimscript |script-local| functions
910
911    Attributes: ~
912        Since: 0.4.0
913
914    Parameters: ~
915      • {opts}  (`vim.api.keyset.context?`) Optional parameters.
916                • types: List of context types (see above) to gather, or empty
917                  for "all".
918
919    Return: ~
920        (`table<string,any>`) Editor state as a msgpack-encoded map.
921
922nvim_get_current_buf()                                *nvim_get_current_buf()*
923    Gets the current buffer.
924
925    Attributes: ~
926        Since: 0.1.0
927
928    Return: ~
929        (`integer`) Buffer id
930
931nvim_get_current_line()                              *nvim_get_current_line()*
932    Gets the current line.
933
934    Attributes: ~
935        Since: 0.1.0
936
937    Return: ~
938        (`string`) Current line string
939
940nvim_get_current_tabpage()                        *nvim_get_current_tabpage()*
941    Gets the current tabpage.
942
943    Attributes: ~
944        Since: 0.1.0
945
946    Return: ~
947        (`integer`) |tab-ID|
948
949nvim_get_current_win()                                *nvim_get_current_win()*
950    Gets the current window.
951
952    Attributes: ~
953        Since: 0.1.0
954
955    Return: ~
956        (`integer`) |window-ID|
957
958nvim_get_hl({ns_id}, {opts})                                   *nvim_get_hl()*
959    Gets all or specific highlight groups in a namespace.
960
961    Note: ~
962      • When the `link` attribute is defined in the highlight definition map,
963        other attributes will not be taking effect (see |:hi-link|).
964
965    Attributes: ~
966        Since: 0.9.0
967
968    Parameters: ~
969      • {ns_id}  (`integer`) Get highlight groups for namespace ns_id
970                 |nvim_get_namespaces()|. Use 0 to get global highlight groups
971                 |:highlight|.
972      • {opts}   (`vim.api.keyset.get_highlight?`) Options dict:
973                 • create: (boolean, default true) When highlight group
974                   doesn't exist create it.
975                 • id: (integer) Get a highlight definition by id.
976                 • link: (boolean, default true) Show linked group name
977                   instead of effective definition |:hi-link|.
978                 • name: (string) Get a highlight definition by name.
979
980    Return: ~
981        (`vim.api.keyset.get_hl_info`) Highlight groups as a map from group
982        name to a highlight definition map as in |nvim_set_hl()|, or only a
983        single highlight definition map if requested by name or id.
984
985nvim_get_hl_id_by_name({name})                      *nvim_get_hl_id_by_name()*
986    Gets a highlight group by name
987
988    similar to |hlID()|, but allocates a new ID if not present.
989
990    Attributes: ~
991        Since: 0.5.0
992
993    Parameters: ~
994      • {name}  (`string`)
995
996    Return: ~
997        (`integer`)
998
999nvim_get_hl_ns({opts})                                      *nvim_get_hl_ns()*
1000    Gets the active highlight namespace.
1001
1002    Attributes: ~
1003        Since: 0.10.0
1004
1005    Parameters: ~
1006      • {opts}  (`vim.api.keyset.get_ns?`) Optional parameters
1007                • winid: (number) |window-ID| for retrieving a window's
1008                  highlight namespace. A value of -1 is returned when
1009                  |nvim_win_set_hl_ns()| has not been called for the window
1010                  (or was called with a namespace of -1).
1011
1012    Return: ~
1013        (`integer`) Namespace id, or -1
1014
1015nvim_get_keymap({mode})                                    *nvim_get_keymap()*
1016    Gets a list of global (non-buffer-local) |mapping| definitions.
1017
1018    Attributes: ~
1019        Since: 0.2.1
1020
1021    Parameters: ~
1022      • {mode}  (`string`) Mode short-name ("n", "i", "v", ...)
1023
1024    Return: ~
1025        (`vim.api.keyset.get_keymap[]`) Array of |maparg()|-like dictionaries
1026        describing mappings. The "buf" key is always zero.
1027
1028nvim_get_mark({name}, {opts})                                *nvim_get_mark()*
1029    Returns a `(row, col, buffer, buffername)` tuple representing the position
1030    of the uppercase/file named mark. "End of line" column position is
1031    returned as |v:maxcol| (big number). See |mark-motions|.
1032
1033    Marks are (1,0)-indexed. |api-indexing|
1034
1035    Note: ~
1036      • Lowercase name (or other buffer-local mark) is an error.
1037
1038    Attributes: ~
1039        Since: 0.6.0
1040
1041    Parameters: ~
1042      • {name}  (`string`) Mark name
1043      • {opts}  (`vim.api.keyset.empty?`) Optional parameters. Reserved for
1044                future use.
1045
1046    Return: ~
1047        (`[integer, integer, integer, string]`) 4-tuple (row, col, buffer,
1048        buffername), (0, 0, 0, '') if the mark is not set.
1049
1050    See also: ~
1051      • |nvim_buf_set_mark()|
1052      • |nvim_del_mark()|
1053
1054nvim_get_mode()                                              *nvim_get_mode()*
1055    Gets the current mode. |mode()| "blocking" is true if Nvim is waiting for
1056    input.
1057
1058    Attributes: ~
1059        |api-fast|
1060        Since: 0.2.0
1061
1062    Return: ~
1063        (`vim.api.keyset.get_mode`) Dict { "mode": String, "blocking": Boolean
1064        }
1065
1066nvim_get_proc({pid})                                         *nvim_get_proc()*
1067    Gets info describing process `pid`.
1068
1069    Attributes: ~
1070        Since: 0.3.0
1071
1072    Parameters: ~
1073      • {pid}  (`integer`)
1074
1075    Return: ~
1076        (`any`) Map of process properties, or NIL if process not found.
1077
1078nvim_get_proc_children({pid})                       *nvim_get_proc_children()*
1079    Gets the immediate children of process `pid`.
1080
1081    Attributes: ~
1082        Since: 0.3.0
1083
1084    Parameters: ~
1085      • {pid}  (`integer`)
1086
1087    Return: ~
1088        (`any[]`) Array of child process ids, empty if process not found.
1089
1090nvim_get_runtime_file({name}, {all})                 *nvim_get_runtime_file()*
1091    Finds files in runtime directories, in 'runtimepath' order.
1092
1093    "name" can contain wildcards. For example
1094    `nvim_get_runtime_file("colors/*.{vim,lua}", true)` will return all color
1095    scheme files. Always use forward slashes (/) in the search pattern for
1096    subdirectories regardless of platform.
1097
1098    It is not an error to not find any files. An empty array is returned then.
1099
1100    Attributes: ~
1101        |api-fast|
1102        Since: 0.5.0
1103
1104    Parameters: ~
1105      • {name}  (`string`) pattern of files to search for
1106      • {all}   (`boolean`) whether to return all matches or only the first
1107
1108    Return: ~
1109        (`string[]`) list of absolute paths to the found files
1110
1111nvim_get_var({name})                                          *nvim_get_var()*
1112    Gets a global (g:) variable.
1113
1114    Attributes: ~
1115        Since: 0.1.0
1116
1117    Parameters: ~
1118      • {name}  (`string`) Variable name
1119
1120    Return: ~
1121        (`any`) Variable value
1122
1123nvim_get_vvar({name})                                        *nvim_get_vvar()*
1124    Gets a v: variable.
1125
1126    Attributes: ~
1127        Since: 0.1.0
1128
1129    Parameters: ~
1130      • {name}  (`string`) Variable name
1131
1132    Return: ~
1133        (`any`) Variable value
1134
1135nvim_input({keys})                                              *nvim_input()*
1136    Queues raw user-input. Unlike |nvim_feedkeys()|, this uses a low-level
1137    input buffer and the call is non-blocking (input is processed
1138    asynchronously by the eventloop).
1139
1140    To input blocks of text, |nvim_paste()| is much faster and should be
1141    preferred.
1142
1143    On execution error: does not fail, but updates v:errmsg.
1144
1145    Note: ~
1146      • |keycodes| like <CR> are translated, so "<" is special. To input a
1147        literal "<", send <LT>.
1148      • For mouse events use |nvim_input_mouse()|. The pseudokey form
1149        `<LeftMouse><col,row>` is deprecated since |api-level| 6.
1150
1151    Attributes: ~
1152        |api-fast|
1153        Since: 0.1.0
1154
1155    Parameters: ~
1156      • {keys}  (`string`) to be typed
1157
1158    Return: ~
1159        (`integer`) Number of bytes actually written (can be fewer than
1160        requested if the buffer becomes full).
1161
1162                                                          *nvim_input_mouse()*
1163nvim_input_mouse({button}, {action}, {modifier}, {grid}, {row}, {col})
1164    Send mouse event from GUI.
1165
1166    Non-blocking: does not wait on any result, but queues the event to be
1167    processed soon by the event loop.
1168
1169    Note: ~
1170      • Currently this doesn't support "scripting" multiple mouse events by
1171        calling it multiple times in a loop: the intermediate mouse positions
1172        will be ignored. It should be used to implement real-time mouse input
1173        in a GUI. The deprecated pseudokey form (`<LeftMouse><col,row>`) of
1174        |nvim_input()| has the same limitation.
1175
1176    Attributes: ~
1177        |api-fast|
1178        Since: 0.4.0
1179
1180    Parameters: ~
1181      • {button}    (`string`) Mouse button: one of "left", "right", "middle",
1182                    "wheel", "move", "x1", "x2".
1183      • {action}    (`string`) For ordinary buttons, one of "press", "drag",
1184                    "release". For the wheel, one of "up", "down", "left",
1185                    "right". Ignored for "move".
1186      • {modifier}  (`string`) String of modifiers each represented by a
1187                    single char. The same specifiers are used as for a key
1188                    press, except that the "-" separator is optional, so
1189                    "C-A-", "c-a" and "CA" can all be used to specify
1190                    Ctrl+Alt+click.
1191      • {grid}      (`integer`) Grid number (used by |ui-multigrid| client),
1192                    or 0 to let Nvim decide positioning of windows. For more
1193                    information, see |dev-ui-multigrid|
1194      • {row}       (`integer`) Mouse row-position (zero-based, like redraw
1195                    events)
1196      • {col}       (`integer`) Mouse column-position (zero-based, like redraw
1197                    events)
1198
1199nvim_list_bufs()                                            *nvim_list_bufs()*
1200    Gets the current list of buffers.
1201
1202    Includes unlisted (unloaded/deleted) buffers, like `:ls!`. Use
1203    |nvim_buf_is_loaded()| to check if a buffer is loaded.
1204
1205    Attributes: ~
1206        Since: 0.1.0
1207
1208    Return: ~
1209        (`integer[]`) List of buffer ids
1210
1211nvim_list_chans()                                          *nvim_list_chans()*
1212    Get information about all open channels.
1213
1214    Attributes: ~
1215        Since: 0.3.0
1216
1217    Return: ~
1218        (`table<string,any>[]`) Array of Dictionaries, each describing a
1219        channel with the format specified at |nvim_get_chan_info()|.
1220
1221nvim_list_runtime_paths()                          *nvim_list_runtime_paths()*
1222    Gets the paths contained in |runtime-search-path|.
1223
1224    Attributes: ~
1225        Since: 0.1.0
1226
1227    Return: ~
1228        (`string[]`) List of paths
1229
1230nvim_list_tabpages()                                    *nvim_list_tabpages()*
1231    Gets the current list of |tab-ID|s.
1232
1233    Attributes: ~
1234        Since: 0.1.0
1235
1236    Return: ~
1237        (`integer[]`) List of |tab-ID|s
1238
1239nvim_list_uis()                                              *nvim_list_uis()*
1240    Gets a list of dictionaries representing attached UIs.
1241
1242    Example: The Nvim builtin |TUI| sets its channel info as described in
1243    |startup-tui|. In particular, it sets `client.name` to "nvim-tui". So you
1244    can check if the TUI is running by inspecting the client name of each UI: >lua
1245        vim.print(vim.api.nvim_get_chan_info(vim.api.nvim_list_uis()[1].chan).client.name)
1246<
1247
1248    Attributes: ~
1249        Since: 0.3.0
1250
1251    Return: ~
1252        (`table<string,any>[]`) Array of UI dictionaries, each with these
1253        keys:
1254        • "height" Requested height of the UI
1255        • "width" Requested width of the UI
1256        • "rgb" true if the UI uses RGB colors (false implies |cterm-colors|)
1257        • "ext_..." Requested UI extensions, see |ui-option|
1258        • "chan" |channel-id| of remote UI
1259
1260nvim_list_wins()                                            *nvim_list_wins()*
1261    Gets the current list of all |window-ID|s in all tabpages.
1262
1263    Attributes: ~
1264        Since: 0.1.0
1265
1266    Return: ~
1267        (`integer[]`) List of |window-ID|s
1268
1269nvim_load_context({dict})                                *nvim_load_context()*
1270    Sets the current editor state from the given map.
1271
1272    Attributes: ~
1273        Since: 0.4.0
1274
1275    Parameters: ~
1276      • {dict}  (`table<string,any>`) Msgpack-encoded editor state, in the
1277                form returned by |nvim_get_context()|.
1278
1279    Return: ~
1280        (`any`)
1281
1282nvim_open_term({buf}, {opts})                               *nvim_open_term()*
1283    Open a terminal instance in a buffer
1284
1285    By default (and currently the only option) the terminal will not be
1286    connected to an external process. Instead, input sent on the channel will
1287    be echoed directly by the terminal. This is useful to display ANSI
1288    terminal sequences returned as part of an RPC message, or similar.
1289
1290    Note: |:ls| reports the buffer as "R" (running) until the channel is
1291    closed. |chanclose()|
1292
1293    Note: To initialize the terminal size, display the buffer in a window
1294    first. E.g. for a floating display,
1295    1. Create an empty buffer using |nvim_create_buf()|.
1296    2. Display it with |nvim_open_win()|.
1297    3. Call nvim_open_term().
1298    4. Then calling |nvim_chan_send()| will process sequences in a virtual
1299       terminal with the intended size (defined by the window width/height).
1300
1301    Example: this `TermHl` command can be used to display and highlight raw
1302    ANSI termcodes, so you can use Nvim as a "scrollback pager" (for terminals
1303    like kitty):                     *ansi-colorize* *terminal-scrollback-pager* >lua
1304        vim.api.nvim_create_user_command('TermHl', function()
1305          vim.api.nvim_open_term(0)
1306        end, { desc = 'Highlights ANSI termcodes in curbuf' })
1307<
1308
1309    Attributes: ~
1310        not allowed when |textlock| is active
1311        Since: 0.5.0
1312
1313    Parameters: ~
1314      • {buf}   (`integer`) Buffer which displays the PTY output. The initial
1315                buffer contents (if any) will be written to the PTY.
1316      • {opts}  (`vim.api.keyset.open_term?`) Optional parameters.
1317                • force_crlf: (boolean, default: true) Convert "\n" to "\r\n".
1318                • on_input:
1319                  (`fun("input", chan: integer, buf: integer, data: string)`)
1320                  Function invoked when the terminal emits bytes, see above.
1321                  |textlock| applies. May call |nvim_chan_send()| directly.
1322
1323    Return: ~
1324        (`integer`) Channel id, or 0 on error
1325
1326nvim_paste({data}, {crlf}, {phase})                             *nvim_paste()*
1327    Pastes at cursor (in any mode), and sets "redo" so dot (|.|) will repeat
1328    the input. UIs call this to implement "paste", but it's also intended for
1329    use by scripts to input large, dot-repeatable blocks of text (as opposed
1330    to |nvim_input()| which is subject to mappings/events and is thus much
1331    slower).
1332
1333    Invokes the |vim.paste()| handler, which handles each mode appropriately.
1334
1335    Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err`
1336    but do not affect the return value (which is strictly decided by
1337    `vim.paste()`). On error or cancel, subsequent calls are ignored
1338    ("drained") until the next paste is initiated (phase 1 or -1).
1339
1340    Useful in mappings and scripts to insert multiline text. Example: >lua
1341        vim.keymap.set('n', 'x', function()
1342          vim.api.nvim_paste([[
1343            line1
1344            line2
1345            line3
1346          ]], false, -1)
1347        end, { buf = 0 })
1348<
1349
1350    Attributes: ~
1351        not allowed when |textlock| is active
1352        Since: 0.4.0
1353
1354    Parameters: ~
1355      • {data}   (`string`) Multiline input. Lines break at LF ("\n"). May be
1356                 binary (containing NUL bytes).
1357      • {crlf}   (`boolean`) Also break lines at CR and CRLF.
1358      • {phase}  (`integer`) -1: paste in a single call (i.e. without
1359                 streaming). To "stream" a paste, call `nvim_paste`
1360                 sequentially with these `phase` values:
1361                 • 1: starts the paste (exactly once)
1362                 • 2: continues the paste (zero or more times)
1363                 • 3: ends the paste (exactly once)
1364
1365    Return: ~
1366        (`boolean`)
1367        • true: Client may continue pasting.
1368        • false: Client should cancel the paste.
1369
1370nvim_put({lines}, {type}, {after}, {follow})                      *nvim_put()*
1371    Puts text at cursor, in any mode. For dot-repeatable input, use
1372    |nvim_paste()|.
1373
1374    Compare |:put| and |p| which are always linewise.
1375
1376    Attributes: ~
1377        not allowed when |textlock| is active
1378        Since: 0.4.0
1379
1380    Parameters: ~
1381      • {lines}   (`string[]`) |readfile()|-style list of lines.
1382                  |channel-lines|
1383      • {type}    (`string`) Edit behavior: any |getregtype()| result, or:
1384                  • "b" |blockwise-visual| mode (may include width, e.g. "b3")
1385                  • "c" |charwise| mode
1386                  • "l" |linewise| mode
1387                  • "" guess by contents, see |setreg()|
1388      • {after}   (`boolean`) If true insert after cursor (like |p|), or
1389                  before (like |P|).
1390      • {follow}  (`boolean`) If true place cursor at end of inserted text.
1391
1392                                                    *nvim_replace_termcodes()*
1393nvim_replace_termcodes({str}, {from_part}, {do_lt}, {special})
1394    Converts terminal codes and |keycodes| (<CR>, <Esc>, …) in a key
1395    sequence, to the internal representation. See also Lua |vim.keycode()|.
1396
1397    Attributes: ~
1398        |api-fast|
1399        Since: 0.1.0
1400
1401    Parameters: ~
1402      • {str}        (`string`) String to be converted.
1403      • {from_part}  (`boolean`) Legacy Vim parameter. Usually true.
1404      • {do_lt}      (`boolean`) Also translate <lt>. Ignored if `special` is
1405                     false.
1406      • {special}    (`boolean`) Replace |keycodes|, e.g. <CR> becomes a "\r"
1407                     char.
1408
1409    Return: ~
1410        (`string`)
1411
1412    See also: ~
1413      • replace_termcodes
1414      • cpoptions
1415
1416                                                *nvim_select_popupmenu_item()*
1417nvim_select_popupmenu_item({item}, {insert}, {finish}, {opts})
1418    Selects an item in the completion popup menu.
1419
1420    If neither |ins-completion| nor |cmdline-completion| popup menu is active
1421    this API call is silently ignored. Useful for an external UI using
1422    |ui-popupmenu| to control the popup menu with the mouse. Can also be used
1423    in a mapping; use <Cmd> |:map-cmd| or a Lua mapping to ensure the mapping
1424    doesn't end completion mode.
1425
1426    Attributes: ~
1427        Since: 0.4.0
1428
1429    Parameters: ~
1430      • {item}    (`integer`) Index (zero-based) of the item to select. Value
1431                  of -1 selects nothing and restores the original text.
1432      • {insert}  (`boolean`) For |ins-completion|, whether the selection
1433                  should be inserted in the buffer. Ignored for
1434                  |cmdline-completion|.
1435      • {finish}  (`boolean`) Finish the completion and dismiss the popup
1436                  menu. Implies {insert}.
1437      • {opts}    (`vim.api.keyset.empty?`) Optional parameters. Reserved for
1438                  future use.
1439
1440                                                      *nvim_set_client_info()*
1441nvim_set_client_info({name}, {version}, {type}, {methods}, {attributes})
1442    Self-identifies the client, and sets optional flags on the channel.
1443    Defines the `client` object returned by |nvim_get_chan_info()|.
1444
1445    Clients should call this just after connecting, to provide hints for
1446    debugging and orchestration. (Note: Something is better than nothing!
1447    Fields are optional, but at least set `name`.)
1448
1449    Can be called more than once; caller should merge old info if appropriate.
1450    Example: a library first identifies the channel, then a plugin using that
1451    library later identifies itself.
1452
1453    Attributes: ~
1454        |RPC| only
1455        Since: 0.3.0
1456
1457    Parameters: ~
1458      • {name}        (`string`) Client short-name. Sets the `client.name`
1459                      field of |nvim_get_chan_info()|.
1460      • {version}     (`table<string,any>`) Dict describing the version, with
1461                      these (optional) keys:
1462                      • "commit" hash or similar identifier of commit
1463                      • "major" major version (defaults to 0 if not set, for
1464                        no release yet)
1465                      • "minor" minor version
1466                      • "patch" patch number
1467                      • "prerelease" string describing a prerelease, like
1468                        "dev" or "beta1"
1469      • {type}        (`string`) Must be one of the following values. Client
1470                      libraries should default to "remote" unless overridden
1471                      by the user.
1472                      • "embedder" application using Nvim as a component (for
1473                        example, IDE/editor implementing a vim mode).
1474                      • "host" plugin host, typically started by nvim
1475                      • "msgpack-rpc" remote client connected to Nvim via
1476                        fully MessagePack-RPC compliant protocol.
1477                      • "plugin" single plugin, started by nvim
1478                      • "remote" remote client connected "Nvim flavored"
1479                        MessagePack-RPC (responses must be in reverse order of
1480                        requests). |msgpack-rpc|
1481                      • "ui" gui frontend
1482      • {methods}     (`table<string,any>`) Builtin methods in the client. For
1483                      a host, this does not include plugin methods which will
1484                      be discovered later. The key should be the method name,
1485                      the values are dicts with these (optional) keys (more
1486                      keys may be added in future versions of Nvim, thus
1487                      unknown keys are ignored. Clients must only use keys
1488                      defined in this or later versions of Nvim):
1489                      • "async" if true, send as a notification. If false or
1490                        unspecified, use a blocking request
1491                      • "nargs" Number of arguments. Could be a single integer
1492                        or an array of two integers, minimum and maximum
1493                        inclusive.
1494      • {attributes}  (`table<string,any>`) Arbitrary string:string map of
1495                      informal client properties. Suggested keys:
1496                      • "license": License description ("Apache 2", "GPLv3",
1497                        "MIT", …)
1498                      • "logo": URI or path to image, preferably small logo or
1499                        icon. .png or .svg format is preferred.
1500                      • "pid": Process id.
1501                      • "website": Client homepage URL (e.g. GitHub
1502                        repository)
1503
1504nvim_set_current_buf({buf})                           *nvim_set_current_buf()*
1505    Sets the current window's buffer to `buf`.
1506
1507    Attributes: ~
1508        not allowed when |textlock| is active
1509        Since: 0.1.0
1510
1511    Parameters: ~
1512      • {buf}  (`integer`) Buffer id
1513
1514nvim_set_current_dir({dir})                           *nvim_set_current_dir()*
1515    Changes the global working directory.
1516
1517    Attributes: ~
1518        Since: 0.1.0
1519
1520    Parameters: ~
1521      • {dir}  (`string`) Directory path
1522
1523nvim_set_current_line({line})                        *nvim_set_current_line()*
1524    Sets the text on the current line.
1525
1526    Attributes: ~
1527        not allowed when |textlock| is active
1528        Since: 0.1.0
1529
1530    Parameters: ~
1531      • {line}  (`string`) Line contents
1532
1533nvim_set_current_tabpage({tabpage})               *nvim_set_current_tabpage()*
1534    Sets the current tabpage.
1535
1536    Attributes: ~
1537        not allowed when |textlock| is active
1538        Since: 0.1.0
1539
1540    Parameters: ~
1541      • {tabpage}  (`integer`) |tab-ID| to focus
1542
1543nvim_set_current_win({win})                           *nvim_set_current_win()*
1544    Navigates to the given window (and tabpage, implicitly).
1545
1546    Attributes: ~
1547        not allowed when |textlock| is active
1548        Since: 0.1.0
1549
1550    Parameters: ~
1551      • {win}  (`integer`) |window-ID| to focus
1552
1553nvim_set_hl({ns_id}, {name}, {val})                            *nvim_set_hl()*
1554    Sets a highlight group. By default, replaces the entire definition (e.g.
1555    `nvim_set_hl(0, 'Visual', {})` will clear the "Visual" group), unless
1556    `update` is specified.
1557
1558    Note: ~
1559      • The fg and bg keys also accept the string values `"fg"` or `"bg"`
1560        which act as aliases to the corresponding foreground and background
1561        values of the Normal group. If the Normal group has not been defined,
1562        using these values results in an error.
1563      • If `link` is used in combination with other attributes; only the
1564        `link` will take effect (see |:hi-link|).
1565
1566    Attributes: ~
1567        Since: 0.5.0
1568
1569    Parameters: ~
1570      • {ns_id}  (`integer`) Namespace id for this highlight
1571                 |nvim_create_namespace()|. Use 0 to set a highlight group
1572                 globally |:highlight|. Highlights from non-global namespaces
1573                 are not active by default, use |nvim_set_hl_ns()| or
1574                 |nvim_win_set_hl_ns()| to activate them.
1575      • {name}   (`string`) Highlight group name, e.g. "ErrorMsg"
1576      • {val}    (`vim.api.keyset.highlight`) Highlight definition map,
1577                 accepts the following keys:
1578                 • altfont: boolean
1579                 • bg: color name or "#RRGGBB", see note.
1580                 • bg_indexed: boolean. If true, `bg` is an RGB approximation
1581                   of `ctermbg` (a palette index). UIs rendering cterm
1582                   natively may prefer `ctermbg`.
1583                 • blend: integer between 0 and 100
1584                 • blink: boolean
1585                 • bold: boolean
1586                 • conceal: boolean Concealment at the UI level (terminal
1587                   SGR), unrelated to |:syn-conceal|.
1588                 • cterm: cterm attribute map, like |highlight-args|. If not
1589                   set, cterm attributes will match those from the attribute
1590                   map documented above.
1591                 • ctermbg: Sets background of cterm color |ctermbg|
1592                 • ctermfg: Sets foreground of cterm color |ctermfg|
1593                 • default: boolean Don't override existing definition
1594                   |:hi-default|
1595                 • dim: boolean
1596                 • fg: Color name or "#RRGGBB", see note.
1597                 • fg_indexed: boolean. Same as `bg_indexed`, for `fg` and
1598                   `ctermfg`.
1599                 • font: GUI font name (string). Sets |highlight-font|. Use
1600                   "NONE" to clear.
1601                 • force: (boolean, default: false) Update the highlight group
1602                   even if it already exists.
1603                 • italic: boolean
1604                 • link: Name of highlight group to link to. |:hi-link|
1605                 • link_global: Like "link", but always resolved in the global
1606                   namespace (ns=0).
1607                 • nocombine: boolean
1608                 • overline: boolean
1609                 • reverse: boolean
1610                 • sp: Color name or "#RRGGBB"
1611                 • standout: boolean
1612                 • strikethrough: boolean
1613                 • undercurl: boolean
1614                 • underdashed: boolean
1615                 • underdotted: boolean
1616                 • underdouble: boolean
1617                 • underline: boolean
1618                 • update: (boolean, default: false) Update specified
1619                   attributes only, leave others unchanged.
1620
1621nvim_set_hl_ns({ns_id})                                     *nvim_set_hl_ns()*
1622    Set active namespace for highlights defined with |nvim_set_hl()|. This can
1623    be set for a single window, see |nvim_win_set_hl_ns()|.
1624
1625    Attributes: ~
1626        Since: 0.8.0
1627
1628    Parameters: ~
1629      • {ns_id}  (`integer`) the namespace to use
1630
1631nvim_set_hl_ns_fast({ns_id})                           *nvim_set_hl_ns_fast()*
1632    Set active namespace for highlights defined with |nvim_set_hl()| while
1633    redrawing.
1634
1635    This function is meant to be called while redrawing, primarily from
1636    |nvim_set_decoration_provider()| on_win and on_line callbacks, which are
1637    allowed to change the namespace during a redraw cycle.
1638
1639    Attributes: ~
1640        |api-fast|
1641        Since: 0.8.0
1642
1643    Parameters: ~
1644      • {ns_id}  (`integer`) the namespace to activate
1645
1646nvim_set_keymap({mode}, {lhs}, {rhs}, {opts})              *nvim_set_keymap()*
1647    Sets a global |mapping| for the given mode.
1648
1649    To set a buffer-local mapping, use |nvim_buf_set_keymap()|.
1650
1651    Unlike |:map|, leading/trailing whitespace is accepted as part of the
1652    {lhs} or {rhs}. Empty {rhs} is <Nop>. |keycodes| are replaced as usual.
1653
1654    Example: >vim
1655        call nvim_set_keymap('n', ' <NL>', '', {'nowait': v:true})
1656<
1657
1658    is equivalent to: >vim
1659        nmap <nowait> <Space><NL> <Nop>
1660<
1661
1662    Attributes: ~
1663        Since: 0.4.0
1664
1665    Parameters: ~
1666      • {mode}  (`string`) Mode short-name (map command prefix: "n", "i", "v",
1667                "x", …) or "!" for |:map!|, or empty string for |:map|.
1668                "ia", "ca" or "!a" for abbreviation in Insert mode, Cmdline
1669                mode, or both, respectively
1670      • {lhs}   (`string`) Left-hand-side |{lhs}| of the mapping.
1671      • {rhs}   (`string`) Right-hand-side |{rhs}| of the mapping.
1672      • {opts}  (`vim.api.keyset.keymap?`) Optional parameters map: Accepts
1673                all |:map-arguments| as keys except <buffer>, values are
1674                booleans (default false). Also:
1675                • "callback" Lua function called in place of {rhs}.
1676                • "desc" human-readable description.
1677                • "noremap" disables |recursive_mapping|, like |:noremap|
1678                • "replace_keycodes" (boolean) When "expr" is true, replace
1679                  keycodes in the resulting string (see
1680                  |nvim_replace_termcodes()|). Returning nil from the Lua
1681                  "callback" is equivalent to returning an empty string.
1682
1683nvim_set_var({name}, {value})                                 *nvim_set_var()*
1684    Sets a global (g:) variable.
1685
1686    Attributes: ~
1687        Since: 0.1.0
1688
1689    Parameters: ~
1690      • {name}   (`string`) Variable name
1691      • {value}  (`any`) Variable value
1692
1693nvim_set_vvar({name}, {value})                               *nvim_set_vvar()*
1694    Sets a v: variable, if it is not readonly.
1695
1696    Attributes: ~
1697        Since: 0.4.0
1698
1699    Parameters: ~
1700      • {name}   (`string`) Variable name
1701      • {value}  (`any`) Variable value
1702
1703nvim_strwidth({text})                                        *nvim_strwidth()*
1704    Calculates the number of display cells occupied by `text`. Control
1705    characters including <Tab> count as one cell.
1706
1707    Attributes: ~
1708        Since: 0.1.0
1709
1710    Parameters: ~
1711      • {text}  (`string`) Some text
1712
1713    Return: ~
1714        (`integer`) Number of cells
1715
1716nvim__chan_set_detach({detach})                      *nvim__chan_set_detach()*
1717    WARNING: This feature is experimental/unstable.
1718
1719    Sets the detach flag for the channel.
1720
1721    Detached channels do not trigger self-exit when they are closed.
1722
1723    Attributes: ~
1724        |RPC| only
1725        Since: 0.12.0
1726
1727    Parameters: ~
1728      • {detach}  (`boolean`) New detach value for the channel.
1729
1730nvim__cmdwin_set({type}, {buf})                           *nvim__cmdwin_set()*
1731    WARNING: This feature is experimental/unstable.
1732
1733    Records the cmdwin scratchbuf and type, or clears both when type="" /
1734    buf=0. Internal use only.
1735
1736    Attributes: ~
1737        Since: 0.12.0
1738
1739    Parameters: ~
1740      • {type}  (`string`) ':', '/', '?' (first char only); empty to clear.
1741      • {buf}   (`integer`) cmdwin buffer id, or 0 to clear.
1742
1743nvim__complete_set({index}, {opts})                     *nvim__complete_set()*
1744    WARNING: This feature is experimental/unstable.
1745
1746    Sets info for the completion item at the given index. If the info text was
1747    shown in a window, returns the window and buffer ids, or empty dict if not
1748    shown.
1749
1750    Parameters: ~
1751      • {index}  (`integer`) Completion candidate index
1752      • {opts}   (`vim.api.keyset.complete_set?`) Optional parameters.
1753                 • info: (string) info text.
1754
1755    Return: ~
1756        (`table<string,integer>`) Dict containing these keys:
1757        • winid: (integer) floating window id
1758        • bufnr: (integer) buffer id in floating window
1759
1760nvim__exec_lua_fast({code}, {args})                    *nvim__exec_lua_fast()*
1761    WARNING: This feature is experimental/unstable.
1762
1763    Like |nvim_exec_lua()|, but can be called during |api-fast| contexts.
1764
1765    Execute Lua code. Parameters (if any) are available as `...` inside the
1766    chunk. The chunk can return a value.
1767
1768    Only statements are executed. To evaluate an expression, prefix it with
1769    `return`: return my_function(...)
1770
1771    Attributes: ~
1772        |api-fast|
1773        |RPC| only
1774        Since: 0.12.0
1775
1776    Parameters: ~
1777      • {code}  (`string`) Lua code to execute
1778      • {args}  (`any[]`) Arguments to the code
1779
1780    Return: ~
1781        (`any`) Return value of Lua code if present or NIL.
1782
1783nvim__get_runtime({pat}, {all}, {opts})                  *nvim__get_runtime()*
1784    WARNING: This feature is experimental/unstable.
1785
1786    Find files in runtime directories
1787
1788    Attributes: ~
1789        |api-fast|
1790        Since: 0.6.0
1791
1792    Parameters: ~
1793      • {pat}   (`string[]`) pattern of files to search for
1794      • {all}   (`boolean`) whether to return all matches or only the first
1795      • {opts}  (`vim.api.keyset.runtime?`) is_lua: only search Lua subdirs
1796
1797    Return: ~
1798        (`string[]`) list of absolute paths to the found files
1799
1800nvim__id({obj})                                                   *nvim__id()*
1801    WARNING: This feature is experimental/unstable.
1802
1803    Returns object given as argument.
1804
1805    This API function is used for testing. One should not rely on its presence
1806    in plugins.
1807
1808    Parameters: ~
1809      • {obj}  (`any`) Object to return.
1810
1811    Return: ~
1812        (`any`) its argument.
1813
1814nvim__id_array({arr})                                       *nvim__id_array()*
1815    WARNING: This feature is experimental/unstable.
1816
1817    Returns array given as argument.
1818
1819    This API function is used for testing. One should not rely on its presence
1820    in plugins.
1821
1822    Parameters: ~
1823      • {arr}  (`any[]`) Array to return.
1824
1825    Return: ~
1826        (`any[]`) its argument.
1827
1828nvim__id_dict({dct})                                         *nvim__id_dict()*
1829    WARNING: This feature is experimental/unstable.
1830
1831    Returns dict given as argument.
1832
1833    This API function is used for testing. One should not rely on its presence
1834    in plugins.
1835
1836    Parameters: ~
1837      • {dct}  (`table<string,any>`) Dict to return.
1838
1839    Return: ~
1840        (`table<string,any>`) its argument.
1841
1842nvim__id_float({flt})                                       *nvim__id_float()*
1843    WARNING: This feature is experimental/unstable.
1844
1845    Returns floating-point value given as argument.
1846
1847    This API function is used for testing. One should not rely on its presence
1848    in plugins.
1849
1850    Parameters: ~
1851      • {flt}  (`number`) Value to return.
1852
1853    Return: ~
1854        (`number`) its argument.
1855
1856nvim__inspect_cell({grid}, {row}, {col})                *nvim__inspect_cell()*
1857    WARNING: This feature is experimental/unstable.
1858
1859    NB: if your UI doesn't use hlstate, this will not return hlstate first
1860    time.
1861
1862    Parameters: ~
1863      • {grid}  (`integer`)
1864      • {row}   (`integer`)
1865      • {col}   (`integer`)
1866
1867    Return: ~
1868        (`any[]`)
1869
1870nvim__invalidate_glyph_cache()                *nvim__invalidate_glyph_cache()*
1871    WARNING: This feature is experimental/unstable.
1872
1873    For testing. The condition in schar_cache_clear_if_full is hard to reach,
1874    so this function can be used to force a cache clear in a test.
1875
1876nvim__redraw({opts})                                          *nvim__redraw()*
1877    WARNING: This feature is experimental/unstable.
1878
1879    Instruct Nvim to redraw various components.
1880
1881    Attributes: ~
1882        Since: 0.10.0
1883
1884    Parameters: ~
1885      • {opts}  (`vim.api.keyset.redraw?`) Optional parameters.
1886                • buf: Target a specific buffer number as described below.
1887                • cursor: Immediately update cursor position on the screen in
1888                  `win` or the current window.
1889                • flush: Update the screen with pending updates.
1890                • range: Redraw a range in `buf`, the buffer in `win` or the
1891                  current buffer (useful for decoration providers). Expects a
1892                  tuple `[first, last]` with the first and last line number of
1893                  the range, 0-based end-exclusive |api-indexing|.
1894                • statuscolumn: Redraw the 'statuscolumn' in `buf`, `win` or
1895                  all windows.
1896                • statusline: Redraw the 'statusline' in `buf`, `win` or all
1897                  windows.
1898                • tabline: Redraw the 'tabline'.
1899                • valid: When present mark `win`, `buf`, or all windows for
1900                  redraw. When `true`, only redraw changed lines (useful for
1901                  decoration providers). When `false`, forcefully redraw.
1902                • win: Target a specific |window-ID| as described below.
1903                • winbar: Redraw the 'winbar' in `buf`, `win` or all windows.
1904
1905    See also: ~
1906      • |:redraw|
1907
1908                                                *nvim__set_restart_on_crash()*
1909nvim__set_restart_on_crash({progpath}, {argv})
1910    WARNING: This feature is experimental/unstable.
1911
1912
1913    Parameters: ~
1914      • {progpath}  (`string`)
1915      • {argv}      (`any[]`)
1916
1917nvim__stats()                                                  *nvim__stats()*
1918    WARNING: This feature is experimental/unstable.
1919
1920    Gets internal stats.
1921
1922    Return: ~
1923        (`table<string,any>`) Map of various internal stats.
1924
1925
1926==============================================================================
1927Vimscript Functions                                            *api-vimscript*
1928
1929                                                   *nvim_call_dict_function()*
1930nvim_call_dict_function({dict}, {fn}, {args})
1931    Calls a Vimscript |Dictionary-function| with the given arguments.
1932
1933    On execution error: fails with Vimscript error, updates v:errmsg.
1934
1935    Attributes: ~
1936        Since: 0.3.0
1937
1938    Parameters: ~
1939      • {dict}  (`any`) Dict, or String evaluating to a Vimscript |self| dict
1940      • {fn}    (`string`) Name of the function defined on the Vimscript dict
1941      • {args}  (`any[]`) Function arguments packed in an Array
1942
1943    Return: ~
1944        (`any`) Result of the function call
1945
1946nvim_call_function({fn}, {args})                        *nvim_call_function()*
1947    Calls a Vimscript function with the given arguments.
1948
1949    On execution error: fails with Vimscript error, updates v:errmsg.
1950
1951    Attributes: ~
1952        Since: 0.1.0
1953
1954    Parameters: ~
1955      • {fn}    (`string`) Function to call
1956      • {args}  (`any[]`) Function arguments packed in an Array
1957
1958    Return: ~
1959        (`any`) Result of the function call
1960
1961nvim_command({cmd})                                           *nvim_command()*
1962    Executes an Ex command.
1963
1964    On execution error: fails with Vimscript error, updates v:errmsg.
1965
1966    Prefer |nvim_cmd()| or |nvim_exec2()| instead. To modify an Ex command in
1967    a structured way before executing it, modify the result of
1968    |nvim_parse_cmd()| then pass it to |nvim_cmd()|.
1969
1970    Attributes: ~
1971        Since: 0.1.0
1972
1973    Parameters: ~
1974      • {cmd}  (`string`) Ex command string
1975
1976nvim_eval({expr})                                                *nvim_eval()*
1977    Evaluates a Vimscript |expression|. Dicts and Lists are recursively
1978    expanded.
1979
1980    On execution error: fails with Vimscript error, updates v:errmsg.
1981
1982    Attributes: ~
1983        Since: 0.1.0
1984
1985    Parameters: ~
1986      • {expr}  (`string`) Vimscript expression string
1987
1988    Return: ~
1989        (`any`) Evaluation result or expanded object
1990
1991nvim_exec2({src}, {opts})                                       *nvim_exec2()*
1992    Executes Vimscript (multiline block of Ex commands), like anonymous
1993    |:source|.
1994
1995    Unlike |nvim_command()| this function supports heredocs, script-scope
1996    (s:), etc.
1997
1998    On execution error: fails with Vimscript error, updates v:errmsg.
1999
2000    Attributes: ~
2001        Since: 0.9.0
2002
2003    Parameters: ~
2004      • {src}   (`string`) Vimscript code
2005      • {opts}  (`vim.api.keyset.exec_opts?`) Optional parameters.
2006                • output: (boolean, default false) Whether to capture and
2007                  return all (non-error, non-shell |:!|) output.
2008
2009    Return: ~
2010        (`table<string,any>`) Dict containing information about execution,
2011        with these keys:
2012        • output: (string|nil) Output if `opts.output` is true.
2013
2014    See also: ~
2015      • |execute()|
2016      • |nvim_command()|
2017      • |nvim_cmd()|
2018
2019nvim_parse_expression({expr}, {flags}, {hl})         *nvim_parse_expression()*
2020    Parse a Vimscript expression.
2021
2022    Attributes: ~
2023        |api-fast|
2024        Since: 0.3.0
2025
2026    Parameters: ~
2027      • {expr}   (`string`) Expression to parse. Always treated as a single
2028                 line.
2029      • {flags}  (`string`) Flags:
2030                 • "E" if EOC tokens are not allowed (determines whether they
2031                   will stop parsing process or be recognized as an
2032                   operator/space, though also yielding an error).
2033                 • "l" when needing to start parsing with lvalues for ":let"
2034                   or ":for".
2035                 • "m" if multiple expressions in a row are allowed (only the
2036                   first one will be parsed),
2037                 • Common flag sets:
2038                   • "E" to parse like for `"<C-r>="`.
2039                   • "lm" to parse for ":let".
2040                   • "m" to parse like for `":echo"`.
2041                   • empty string for ":call".
2042      • {hl}     (`boolean`) If true, return value will also include
2043                 "highlight" key containing array of 4-tuples (arrays)
2044                 (Integer, Integer, Integer, String), where first three
2045                 numbers define the highlighted region and represent line,
2046                 starting column and ending column (latter exclusive: one
2047                 should highlight region [start_col, end_col)).
2048
2049    Return: ~
2050        (`table<string,any>`)
2051        • AST: top-level dict with these keys:
2052          • "error": Dict with error, present only if parser saw some error.
2053            Contains the following keys:
2054            • "message": String, error message in printf format, translated.
2055              Must contain exactly one `%.*s`.
2056            • "arg": String, error message argument.
2057          • "len": Amount of bytes successfully parsed. With flags equal to ""
2058            that should be equal to the length of expr string. ("Successfully
2059            parsed" here means "participated in AST creation", not "till the
2060            first error".)
2061          • "ast": AST, either nil or a dict with these keys:
2062            • "type": node type, one of the value names from ExprASTNodeType
2063              stringified without "kExprNode" prefix.
2064            • "start": a pair `[line, column]` describing where node is
2065              "started" where "line" is always 0 (will not be 0 if you will be
2066              using this API on e.g. ":let", but that is not present yet).
2067              Both elements are Integers.
2068            • "len": “length” of the node. This and "start" are there for
2069              debugging purposes primary (debugging parser and providing debug
2070              information).
2071            • "children": a list of nodes described in top/"ast". There always
2072              is zero, one or two children, key will not be present if node
2073              has no children. Maximum number of children may be found in
2074              node_maxchildren array.
2075        • Local values (present only for certain nodes):
2076          • "scope": a single Integer, specifies scope for "Option" and
2077            "PlainIdentifier" nodes. For "Option" it is one of ExprOptScope
2078            values, for "PlainIdentifier" it is one of ExprVarScope values.
2079          • "ident": identifier (without scope, if any), present for "Option",
2080            "PlainIdentifier", "PlainKey" and "Environment" nodes.
2081          • "name": Integer, register name (one character) or -1. Only present
2082            for "Register" nodes.
2083          • "cmp_type": String, comparison type, one of the value names from
2084            ExprComparisonType, stringified without "kExprCmp" prefix. Only
2085            present for "Comparison" nodes.
2086          • "ccs_strategy": String, case comparison strategy, one of the value
2087            names from ExprCaseCompareStrategy, stringified without
2088            "kCCStrategy" prefix. Only present for "Comparison" nodes.
2089          • "augmentation": String, augmentation type for "Assignment" nodes.
2090            Is either an empty string, "Add", "Subtract" or "Concat" for "=",
2091            "+=", "-=" or ".=" respectively.
2092          • "invert": Boolean, true if result of comparison needs to be
2093            inverted. Only present for "Comparison" nodes.
2094          • "ivalue": Integer, integer value for "Integer" nodes.
2095          • "fvalue": Float, floating-point value for "Float" nodes.
2096          • "svalue": String, value for "SingleQuotedString" and
2097            "DoubleQuotedString" nodes.
2098
2099
2100==============================================================================
2101Autocmd Functions                                                *api-autocmd*
2102
2103nvim_clear_autocmds({opts})                            *nvim_clear_autocmds()*
2104    Clears all autocommands matching the {opts} query. To delete autocmds see
2105    |nvim_del_autocmd()|.
2106
2107    Attributes: ~
2108        Since: 0.7.0
2109
2110    Parameters: ~
2111      • {opts}  (`vim.api.keyset.clear_autocmds?`) Optional parameters:
2112                • buf: (`integer?`) Select |autocmd-buflocal| autocommands.
2113                  Not allowed with {pattern}.
2114                • event: (`vim.api.keyset.events|vim.api.keyset.events[]?`)
2115                  Examples:
2116                  • event: "pat1"
2117                  • event: { "pat1" }
2118                  • event: { "pat1", "pat2", "pat3" }
2119                • group: (`string|int?`) Group name or id.
2120                  • NOTE: If not given, matches autocmds not in any group.
2121                • pattern: (`string|table?`) Filter by patterns (exact match).
2122                  Not allowed with {buf}.
2123                  • Example: if you have `*.py` as that pattern for the
2124                    autocmd, you must pass `*.py` exactly to clear it.
2125                    `test.py` will not match the pattern.
2126
2127nvim_create_augroup({name}, {opts})                    *nvim_create_augroup()*
2128    Create or get an autocommand group |autocmd-groups|.
2129
2130    To get an existing group id, do: >lua
2131        local id = vim.api.nvim_create_augroup('my.lsp.config', {
2132          clear = false
2133        })
2134<
2135
2136    Attributes: ~
2137        Since: 0.7.0
2138
2139    Parameters: ~
2140      • {name}  (`string`) Group name
2141      • {opts}  (`vim.api.keyset.create_augroup?`) Optional parameters:
2142                • clear (`boolean?`, default: true) Clear existing commands in
2143                  the group |autocmd-groups|.
2144
2145    Return: ~
2146        (`integer`) Group id.
2147
2148    See also: ~
2149      • |autocmd-groups|
2150
2151nvim_create_autocmd({event}, {opts})                   *nvim_create_autocmd()*
2152    Creates an |autocommand| event handler, defined by `callback` (Lua
2153    function or Vimscript function name string) or `command` (Ex command
2154    string).
2155
2156    Example using Lua callback: >lua
2157        vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
2158          pattern = {'*.c', '*.h'},
2159          callback = function(ev)
2160            print(string.format('event fired: %s', vim.inspect(ev)))
2161          end
2162        })
2163<
2164
2165    Example using an Ex command as the handler: >lua
2166        vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
2167          pattern = {'*.c', '*.h'},
2168          command = "echo 'Entering a C or C++ file'",
2169        })
2170<
2171
2172    Note: `pattern` is NOT automatically expanded (unlike with |:autocmd|),
2173    thus names like "$HOME" and "~" must be expanded explicitly: >lua
2174        pattern = vim.fn.expand('~') .. '/some/path/*.py'
2175<
2176
2177    Attributes: ~
2178        |api-fast|
2179        Since: 0.7.0
2180
2181    Parameters: ~
2182      • {event}  (`vim.api.keyset.events|vim.api.keyset.events[]`) Event(s)
2183                 that will trigger the handler (`callback` or `command`): one
2184                 handler is created for each event name.
2185      • {opts}   (`vim.api.keyset.create_autocmd?`) Options dict:
2186                 • buf (`integer?`) Buffer id for buffer-local autocommands
2187                   |autocmd-buflocal|. Not allowed with {pattern}.
2188                 • callback (`function|string?`) Lua function (or Vimscript
2189                   function name, if string) called when the event(s) is
2190                   triggered. Lua callback can return |lua-truthy| to delete
2191                   the autocommand. Callback receives one argument, a table
2192                   with keys:                                     *event-args*
2193                   • buf: (`integer`) <abuf>
2194                   • data: (`any`) Arbitrary data passed from
2195                     |nvim_exec_autocmds()|                       *event-data*
2196                   • event: (`vim.api.keyset.events`) Name of the triggered
2197                     event |autocmd-events|
2198                   • file: (`string`) <afile> (not expanded to a full path)
2199                   • group: (`integer?`) Group id, if any
2200                   • id: (`integer`) Autocommand id
2201                   • match: (`string`) <amatch> (expanded to a full path)
2202                   • win: (`integer`) id of the window for the event, see
2203                     |window-ID|
2204                 • command (string?) Vim command executed on event. Not
2205                   allowed with {callback}.
2206                 • desc (`string?`) Description (for documentation and
2207                   troubleshooting).
2208                 • group (`string|integer?`) Group name or id to match
2209                   against.
2210                 • nested (`boolean?`, default: false) Run nested autocommands
2211                   |autocmd-nested|.
2212                 • once (`boolean?`, default: false) Handle the event only
2213                   once |autocmd-once|. If {event} is a list, each handler
2214                   will fire once.
2215                 • pattern (`string|array?`) Pattern(s) to match literally
2216                   |autocmd-pattern|.
2217
2218    Return: ~
2219        (`integer`) Autocommand id (number)
2220
2221    See also: ~
2222      • |autocommand|
2223      • |nvim_del_autocmd()|
2224
2225nvim_del_augroup_by_id({id})                        *nvim_del_augroup_by_id()*
2226    Delete an autocommand group by id.
2227
2228    To get a group id one can use |nvim_get_autocmds()|.
2229
2230    NOTE: behavior differs from |:augroup-delete|. When deleting a group,
2231    autocommands contained in this group will also be deleted and cleared.
2232    This group will no longer exist.
2233
2234    Attributes: ~
2235        Since: 0.7.0
2236
2237    Parameters: ~
2238      • {id}  (`integer`) Group id.
2239
2240    See also: ~
2241      • |nvim_del_augroup_by_name()|
2242      • |nvim_create_augroup()|
2243
2244nvim_del_augroup_by_name({name})                  *nvim_del_augroup_by_name()*
2245    Delete an autocommand group by name.
2246
2247    NOTE: behavior differs from |:augroup-delete|. When deleting a group,
2248    autocommands contained in this group will also be deleted and cleared.
2249    This group will no longer exist.
2250
2251    Attributes: ~
2252        Since: 0.7.0
2253
2254    Parameters: ~
2255      • {name}  (`string`) Group name.
2256
2257    See also: ~
2258      • |autocmd-groups|
2259
2260nvim_del_autocmd({id})                                    *nvim_del_autocmd()*
2261    Deletes an autocommand by id.
2262
2263    Attributes: ~
2264        Since: 0.7.0
2265
2266    Parameters: ~
2267      • {id}  (`integer`) Autocommand id returned by |nvim_create_autocmd()|
2268
2269nvim_exec_autocmds({event}, {opts})                     *nvim_exec_autocmds()*
2270    Executes {event} handlers matching the {opts} query, in the context of
2271    {buf} (if given). |autocmd-execute|
2272
2273    Attributes: ~
2274        Since: 0.7.0
2275
2276    Parameters: ~
2277      • {event}  (`vim.api.keyset.events|vim.api.keyset.events[]`) Event(s) to
2278                 execute.
2279      • {opts}   (`vim.api.keyset.exec_autocmds?`) Optional filters:
2280                 • buf (`integer?`) Buffer where the event is applied.
2281                   |autocmd-buflocal| Not allowed with {pattern}.
2282                 • data (`any`): Arbitrary data passed to the callback. See
2283                   |nvim_create_autocmd()|.
2284                 • group (`string|integer?`) Group name or id to match
2285                   against. |autocmd-groups|.
2286                 • modeline (`boolean?`, default: true) Process the modeline
2287                   after the autocommands <nomodeline>. Ignored if `buf` is
2288                   given.
2289                 • pattern (`string|array?`, default: current file name)
2290                   |autocmd-pattern|. Not allowed with {buf}.
2291
2292    See also: ~
2293      • |:doautocmd|
2294
2295nvim_get_autocmds({opts})                                *nvim_get_autocmds()*
2296    Gets all autocommands matching ALL criteria in the {opts} query.
2297
2298    Note: When multiple patterns or events are provided they have "OR"
2299    semantics (any combination is matched).
2300
2301    Examples: >lua
2302        -- Matches all criteria
2303        autocommands = vim.api.nvim_get_autocmds({
2304          group = 'MyGroup',
2305          event = {'BufEnter', 'BufWinEnter'},
2306          pattern = {'*.c', '*.h'}
2307        })
2308
2309        -- All commands from one group
2310        autocommands = vim.api.nvim_get_autocmds({
2311          group = 'MyGroup',
2312        })
2313<
2314
2315    Attributes: ~
2316        Since: 0.7.0
2317
2318    Parameters: ~
2319      • {opts}  (`vim.api.keyset.get_autocmds?`) Dict with at least one of
2320                these keys:
2321                • buf: (`integer[]|integer?`) Buffer id or list of buffer ids,
2322                  for buffer-local autocommands |autocmd-buflocal|. Not
2323                  allowed with {pattern}.
2324                • event: (`vim.api.keyset.events|vim.api.keyset.events[]?`)
2325                  Event(s) to match |autocmd-events|.
2326                • group: (`string|table?`) Group name or id to match.
2327                • id: (`integer?`) Autocommand ID to match.
2328                • pattern: (`string|table?`) Pattern(s) to match
2329                  |autocmd-pattern|. Not allowed with {buf}.
2330
2331    Return: ~
2332        (`vim.api.keyset.get_autocmds.ret[]`) Array of matching autocommands,
2333        where each item has:
2334        • buf (`integer?`): Buffer id (only for |autocmd-buffer-local|).
2335        • buflocal (`boolean?`): true if the autocommand is buffer-local
2336          |autocmd-buffer-local|.
2337        • callback: (`function|string?`): Event handler: a Lua function or
2338          Vimscript function name.
2339        • command: (`string`) Event handler: an Ex-command. Empty if a
2340          `callback` is set.
2341        • desc: (`string`) Description.
2342        • event: (`vim.api.keyset.events`) Event name(s).
2343        • group: (`integer`) Group id.
2344        • group_name: (`string`) Group name.
2345        • id: (`integer`) Autocommand id (only when defined with the API).
2346        • once: (`boolean`) true if |autocmd-once| was set.
2347        • pattern: (`string`) Autocommand pattern.
2348
2349
2350==============================================================================
2351Buffer Functions                                                  *api-buffer*
2352
2353For more information on buffers, see |buffers|.
2354
2355Unloaded Buffers: ~
2356
2357Buffers may be unloaded by the |:bunload| command or the buffer's
2358'bufhidden' option. When a buffer is unloaded its file contents are freed
2359from memory and vim cannot operate on the buffer lines until it is reloaded
2360(usually by opening the buffer again in a new window). API methods such as
2361|nvim_buf_get_lines()| and |nvim_buf_line_count()| will be affected.
2362
2363You can use |nvim_buf_is_loaded()| or |nvim_buf_line_count()| to check
2364whether a buffer is loaded.
2365
2366
2367nvim_buf_attach({buf}, {send_buffer}, {opts})              *nvim_buf_attach()*
2368    Activates |api-buffer-updates| events on a channel, or as Lua callbacks.
2369
2370    Example (Lua): capture buffer updates in a global `events` variable (use
2371    "vim.print(events)" to see its contents): >lua
2372        events = {}
2373        vim.api.nvim_buf_attach(0, false, {
2374          on_lines = function(...)
2375            table.insert(events, {...})
2376          end,
2377        })
2378<
2379
2380    Attributes: ~
2381        Since: 0.3.0
2382
2383    Parameters: ~
2384      • {buf}          (`integer`) Buffer id, or 0 for current buffer
2385      • {send_buffer}  (`boolean`) True if the initial notification should
2386                       contain the whole buffer: first notification will be
2387                       `nvim_buf_lines_event`. Else the first notification
2388                       will be `nvim_buf_changedtick_event`. Not for Lua
2389                       callbacks.
2390      • {opts}         (`vim.api.keyset.buf_attach?`) Optional parameters.
2391                       • on_bytes: Called on granular changes (compared to
2392                         on_lines). Not called on buffer reload (`:checktime`,
2393                         `:edit`, …), see `on_reload`. Returning
2394                         |lua-truthy| deletes the callback. Args:
2395                         • the string "bytes"
2396                         • buffer id
2397                         • b:changedtick
2398                         • start row of the changed text (zero-indexed)
2399                         • start column of the changed text
2400                         • byte offset of the changed text (from the start of
2401                           the buffer)
2402                         • old end row of the changed text (offset from start
2403                           row)
2404                         • old end column of the changed text (if old end row
2405                           = 0, offset from start column)
2406                         • old end byte length of the changed text
2407                         • new end row of the changed text (offset from start
2408                           row)
2409                         • new end column of the changed text (if new end row
2410                           = 0, offset from start column)
2411                         • new end byte length of the changed text
2412                       • on_changedtick: Called on |changetick| increment
2413                         without text change. Args:
2414                         • the string "changedtick"
2415                         • buffer id
2416                         • b:changedtick
2417                       • on_detach: Called on detach, or when the buffer is
2418                         unloaded or deleted. Not called when a callback
2419                         returns |lua-truthy| to delete itself. Args:
2420                         • the string "detach"
2421                         • buffer id
2422                       • on_lines: Called on linewise changes. Not called on
2423                         buffer reload (`:checktime`, `:edit`, …), see
2424                         `on_reload`. Returning |lua-truthy| deletes the
2425                         callback. Args:
2426                         • the string "lines"
2427                         • buffer id
2428                         • b:changedtick
2429                         • first line that changed (zero-indexed)
2430                         • last line that was changed
2431                         • last line in the updated range
2432                         • byte count of previous contents
2433                         • deleted_codepoints (if `utf_sizes` is true)
2434                         • deleted_codeunits (if `utf_sizes` is true)
2435                       • on_reload: Called on whole-buffer load (`:checktime`,
2436                         `:edit`, …). Clients should typically re-fetch the
2437                         entire buffer contents. Args:
2438                         • the string "reload"
2439                         • buffer id
2440                       • preview: also attach to command preview (i.e.
2441                         'inccommand') events.
2442                       • utf_sizes: include UTF-32 and UTF-16 size of the
2443                         replaced region, as args to `on_lines`.
2444
2445    Return: ~
2446        (`boolean`) False if attach failed (invalid parameter, or buffer isn't
2447        loaded); otherwise True.
2448
2449    See also: ~
2450      • |nvim_buf_detach()|
2451      • |api-buffer-updates-lua|
2452
2453nvim_buf_call({buf}, {fn})                                   *nvim_buf_call()*
2454    Calls function `fn` in the context of buffer `buf` and returns its result
2455    (may be multiple values).
2456
2457    This temporarily switches current buffer to `buf`. If the current window
2458    already shows `buf`, the window is not switched. If a window inside the
2459    current tabpage (including a float) already shows the buffer, then one of
2460    those windows will be set as current window temporarily. Otherwise a
2461    temporary scratch window (called the "autocmd window" for historical
2462    reasons) will be used.
2463
2464    This is useful e.g. to call Vimscript functions that only work with the
2465    current buffer/window currently, like `jobstart(…, {'term': v:true})`.
2466
2467    Attributes: ~
2468        Lua |vim.api| only
2469        Since: 0.5.0
2470
2471    Parameters: ~
2472      • {buf}  (`integer`) Buffer id, or 0 for current buffer.
2473      • {fn}   (`function`) Lua function to call inside the buffer.
2474
2475    Return: ~
2476        (`any`) Value(s) returned by `fn()`.
2477
2478                                                       *nvim_buf_del_keymap()*
2479nvim_buf_del_keymap({buf}, {mode}, {lhs}, {opts})
2480    Unmaps a buffer-local |mapping| for the given mode.
2481
2482    Attributes: ~
2483        Since: 0.4.0
2484
2485    Parameters: ~
2486      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2487      • {mode}  (`string`) Mode short-name ("n", "i", "v", ...)
2488      • {lhs}   (`string`) Left-hand-side |{lhs}| of the mapping.
2489      • {opts}  (`vim.api.keyset.keymap_del?`) Optional parameters.
2490                • lhs: When true, only match {lhs}, not {rhs}.
2491
2492    See also: ~
2493      • |nvim_del_keymap()|
2494
2495nvim_buf_del_mark({buf}, {name})                         *nvim_buf_del_mark()*
2496    Deletes a named mark in the buffer. See |mark-motions|.
2497
2498    Note: ~
2499      • only deletes marks set in the buffer, if the mark is not set in the
2500        buffer it will return false.
2501
2502    Attributes: ~
2503        Since: 0.6.0
2504
2505    Parameters: ~
2506      • {buf}   (`integer`) Buffer to set the mark on
2507      • {name}  (`string`) Mark name
2508
2509    Return: ~
2510        (`boolean`) true if the mark was deleted, else false.
2511
2512    See also: ~
2513      • |nvim_buf_set_mark()|
2514      • |nvim_del_mark()|
2515
2516nvim_buf_del_var({buf}, {name})                           *nvim_buf_del_var()*
2517    Removes a buffer-scoped (b:) variable
2518
2519    Attributes: ~
2520        Since: 0.1.0
2521
2522    Parameters: ~
2523      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2524      • {name}  (`string`) Variable name
2525
2526nvim_buf_delete({buf}, {opts})                             *nvim_buf_delete()*
2527    Deletes a buffer and its metadata (like |:bwipeout|).
2528
2529    To get |:bdelete| behavior, reset 'buflisted' and pass `unload=true`: >lua
2530        vim.bo.buflisted = false
2531        vim.api.nvim_buf_delete(0, { unload = true })
2532<
2533
2534    Attributes: ~
2535        not allowed when |textlock| is active
2536        Since: 0.5.0
2537
2538    Parameters: ~
2539      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2540      • {opts}  (`vim.api.keyset.buf_delete?`) Optional parameters. Keys:
2541                • force: Force deletion, ignore unsaved changes.
2542                • unload: Unloaded only (|:bunload|), do not delete.
2543
2544nvim_buf_detach({buf})                                     *nvim_buf_detach()*
2545    Deactivates buffer-update events on the channel.
2546
2547    Attributes: ~
2548        |RPC| only
2549        Since: 0.3.0
2550
2551    Parameters: ~
2552      • {buf}  (`integer`) Buffer id, or 0 for current buffer
2553
2554    Return: ~
2555        (`boolean`) False if detach failed (because the buffer isn't loaded);
2556        otherwise True.
2557
2558    See also: ~
2559      • |nvim_buf_attach()|
2560      • |api-lua-detach| for detaching Lua callbacks
2561
2562nvim_buf_get_changedtick({buf})                   *nvim_buf_get_changedtick()*
2563    Gets a changed tick of a buffer
2564
2565    Attributes: ~
2566        Since: 0.2.0
2567
2568    Parameters: ~
2569      • {buf}  (`integer`) Buffer id, or 0 for current buffer
2570
2571    Return: ~
2572        (`integer`) `b:changedtick` value.
2573
2574nvim_buf_get_keymap({buf}, {mode})                     *nvim_buf_get_keymap()*
2575    Gets a list of buffer-local |mapping| definitions.
2576
2577    Attributes: ~
2578        Since: 0.2.1
2579
2580    Parameters: ~
2581      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2582      • {mode}  (`string`) Mode short-name ("n", "i", "v", ...)
2583
2584    Return: ~
2585        (`vim.api.keyset.get_keymap[]`) Array of |maparg()|-like dictionaries
2586        describing mappings. The "buf" key holds the associated buffer id.
2587
2588                                                        *nvim_buf_get_lines()*
2589nvim_buf_get_lines({buf}, {start}, {end}, {strict_indexing})
2590    Gets a line-range from the buffer.
2591
2592    Indexing is zero-based, end-exclusive. Negative indices are interpreted as
2593    length+1+index: -1 refers to the index past the end. So to get the last
2594    element use start=-2 and end=-1.
2595
2596    Out-of-bounds indices are clamped to the nearest valid value, unless
2597    `strict_indexing` is set.
2598
2599    Attributes: ~
2600        Since: 0.1.0
2601
2602    Parameters: ~
2603      • {buf}              (`integer`) Buffer id, or 0 for current buffer
2604      • {start}            (`integer`) First line index
2605      • {end}              (`integer`) Last line index, exclusive
2606      • {strict_indexing}  (`boolean`) Whether out-of-bounds should be an
2607                           error.
2608
2609    Return: ~
2610        (`string[]`) Array of lines, or empty array for unloaded buffer.
2611
2612    See also: ~
2613      • |nvim_buf_get_text()|
2614
2615nvim_buf_get_mark({buf}, {name})                         *nvim_buf_get_mark()*
2616    Returns a `(row,col)` tuple representing the position of the named mark.
2617    "End of line" column position is returned as |v:maxcol| (big number). See
2618    |mark-motions|.
2619
2620    Marks are (1,0)-indexed. |api-indexing|
2621
2622    Attributes: ~
2623        Since: 0.1.0
2624
2625    Parameters: ~
2626      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2627      • {name}  (`string`) Mark name
2628
2629    Return: ~
2630        (`[integer, integer]`) (row, col) tuple, (0, 0) if the mark is not
2631        set, or is an uppercase/file mark set in another buffer.
2632
2633    See also: ~
2634      • |nvim_buf_set_mark()|
2635      • |nvim_buf_del_mark()|
2636
2637nvim_buf_get_name({buf})                                 *nvim_buf_get_name()*
2638    Gets the full/absolute filepath of the buffer, or the buffer name for
2639    non-file buffers.
2640
2641    If the buffer represents a directory, the name ends with a path separator,
2642    unless it was changed by |:file| or |nvim_buf_set_name()|.
2643
2644    Attributes: ~
2645        Since: 0.1.0
2646
2647    Parameters: ~
2648      • {buf}  (`integer`) Buffer id, or 0 for current buffer
2649
2650    Return: ~
2651        (`string`) Buffer name
2652
2653nvim_buf_get_offset({buf}, {index})                    *nvim_buf_get_offset()*
2654    Returns the byte offset of a line (0-indexed). |api-indexing|
2655
2656    Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte.
2657    'fileformat' and 'fileencoding' are ignored. The line index just after the
2658    last line gives the total byte-count of the buffer. A final EOL byte is
2659    counted if it would be written, see 'eol'.
2660
2661    Unlike |line2byte()|, throws error for out-of-bounds indexing. Returns -1
2662    for unloaded buffer.
2663
2664    Attributes: ~
2665        Since: 0.3.2
2666
2667    Parameters: ~
2668      • {buf}    (`integer`) Buffer id, or 0 for current buffer
2669      • {index}  (`integer`) Line index
2670
2671    Return: ~
2672        (`integer`) Integer byte offset, or -1 for unloaded buffer.
2673
2674                                                         *nvim_buf_get_text()*
2675nvim_buf_get_text({buf}, {start_row}, {start_col}, {end_row}, {end_col},
2676                  {opts})
2677    Gets a range from the buffer (may be partial lines, unlike
2678    |nvim_buf_get_lines()|).
2679
2680    Indexing is zero-based. Row indices are end-inclusive, and column indices
2681    are end-exclusive.
2682
2683    Prefer |nvim_buf_get_lines()| when retrieving entire lines.
2684
2685    Attributes: ~
2686        Since: 0.7.0
2687
2688    Parameters: ~
2689      • {buf}        (`integer`) Buffer id, or 0 for current buffer
2690      • {start_row}  (`integer`) First line index
2691      • {start_col}  (`integer`) Starting column (byte offset) on first line
2692      • {end_row}    (`integer`) Last line index, inclusive
2693      • {end_col}    (`integer`) Ending column (byte offset) on last line,
2694                     exclusive
2695      • {opts}       (`vim.api.keyset.empty?`) Optional parameters. Currently
2696                     unused.
2697
2698    Return: ~
2699        (`string[]`) Array of lines, or empty array for unloaded buffer.
2700
2701nvim_buf_get_var({buf}, {name})                           *nvim_buf_get_var()*
2702    Gets a buffer-scoped (b:) variable.
2703
2704    Attributes: ~
2705        Since: 0.1.0
2706
2707    Parameters: ~
2708      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2709      • {name}  (`string`) Variable name
2710
2711    Return: ~
2712        (`any`) Variable value
2713
2714nvim_buf_is_loaded({buf})                               *nvim_buf_is_loaded()*
2715    Checks if a buffer is valid and loaded. See |api-buffer| for more info
2716    about unloaded buffers.
2717
2718    Attributes: ~
2719        Since: 0.3.2
2720
2721    Parameters: ~
2722      • {buf}  (`integer`) Buffer id, or 0 for current buffer
2723
2724    Return: ~
2725        (`boolean`) true if the buffer is valid and loaded, false otherwise.
2726
2727nvim_buf_is_valid({buf})                                 *nvim_buf_is_valid()*
2728    Checks if a buffer is valid.
2729
2730    Note: ~
2731      • Even if a buffer is valid it may have been unloaded. See |api-buffer|
2732        for more info about unloaded buffers.
2733
2734    Attributes: ~
2735        Since: 0.1.0
2736
2737    Parameters: ~
2738      • {buf}  (`integer`) Buffer id, or 0 for current buffer
2739
2740    Return: ~
2741        (`boolean`) true if the buffer is valid, false otherwise.
2742
2743nvim_buf_line_count({buf})                             *nvim_buf_line_count()*
2744    Returns the number of lines in the given buffer.
2745
2746    Attributes: ~
2747        Since: 0.1.0
2748
2749    Parameters: ~
2750      • {buf}  (`integer`) Buffer id, or 0 for current buffer
2751
2752    Return: ~
2753        (`integer`) Line count, or 0 for unloaded buffer. |api-buffer|
2754
2755                                                       *nvim_buf_set_keymap()*
2756nvim_buf_set_keymap({buf}, {mode}, {lhs}, {rhs}, {opts})
2757    Sets a buffer-local |mapping| for the given mode.
2758
2759    Attributes: ~
2760        Since: 0.4.0
2761
2762    Parameters: ~
2763      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2764      • {mode}  (`string`)
2765      • {lhs}   (`string`)
2766      • {rhs}   (`string`)
2767      • {opts}  (`vim.api.keyset.keymap?`)
2768
2769    See also: ~
2770      • |nvim_set_keymap()|
2771
2772                                                        *nvim_buf_set_lines()*
2773nvim_buf_set_lines({buf}, {start}, {end}, {strict_indexing}, {replacement})
2774    Sets (replaces) a line-range in the buffer.
2775
2776    Indexing is zero-based, end-exclusive. Negative indices are interpreted as
2777    length+1+index: -1 refers to the index past the end. So to change or
2778    delete the last line use start=-2 and end=-1.
2779
2780    To insert lines at a given index, set `start` and `end` to the same index.
2781    To delete a range of lines, set `replacement` to an empty array.
2782
2783    Out-of-bounds indices are clamped to the nearest valid value, unless
2784    `strict_indexing` is set.
2785
2786    Attributes: ~
2787        not allowed when |textlock| is active
2788        Since: 0.1.0
2789
2790    Parameters: ~
2791      • {buf}              (`integer`) Buffer id, or 0 for current buffer
2792      • {start}            (`integer`) First line index
2793      • {end}              (`integer`) Last line index, exclusive
2794      • {strict_indexing}  (`boolean`) Whether out-of-bounds should be an
2795                           error.
2796      • {replacement}      (`string[]`) Array of lines to use as replacement
2797
2798    See also: ~
2799      • |nvim_buf_set_text()|
2800
2801                                                         *nvim_buf_set_mark()*
2802nvim_buf_set_mark({buf}, {name}, {line}, {col}, {opts})
2803    Sets a named mark in the given buffer, all marks are allowed
2804    file/uppercase, visual, last change, etc. See |mark-motions|.
2805
2806    Marks are (1,0)-indexed. |api-indexing|
2807
2808    Note: ~
2809      • Passing 0 as line deletes the mark
2810
2811    Attributes: ~
2812        Since: 0.6.0
2813
2814    Parameters: ~
2815      • {buf}   (`integer`) Buffer to set the mark on
2816      • {name}  (`string`) Mark name
2817      • {line}  (`integer`) Line number
2818      • {col}   (`integer`) Column/row number
2819      • {opts}  (`vim.api.keyset.empty?`) Optional parameters. Reserved for
2820                future use.
2821
2822    Return: ~
2823        (`boolean`) true if the mark was set, else false.
2824
2825    See also: ~
2826      • |nvim_buf_del_mark()|
2827      • |nvim_buf_get_mark()|
2828
2829nvim_buf_set_name({buf}, {name})                         *nvim_buf_set_name()*
2830    Sets the full file name for a buffer, like |:file_f|
2831
2832    Attributes: ~
2833        Since: 0.1.0
2834
2835    Parameters: ~
2836      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2837      • {name}  (`string`) Buffer name
2838
2839                                                         *nvim_buf_set_text()*
2840nvim_buf_set_text({buf}, {start_row}, {start_col}, {end_row}, {end_col},
2841                  {replacement})
2842    Sets (replaces) a range in the buffer
2843
2844    This is recommended over |nvim_buf_set_lines()| when only modifying parts
2845    of a line, as extmarks will be preserved on non-modified parts of the
2846    touched lines.
2847
2848    Indexing is zero-based. Row indices are end-inclusive, and column indices
2849    are end-exclusive.
2850
2851    To insert text at a given `(row, column)` location, use
2852    `start_row = end_row = row` and `start_col = end_col = col`. To delete the
2853    text in a range, use `replacement = {}`.
2854
2855    Note: ~
2856      • Prefer |nvim_buf_set_lines()| (for performance) to add or delete
2857        entire lines.
2858      • Prefer |nvim_paste()| or |nvim_put()| to insert (instead of replace)
2859        text at cursor.
2860
2861    Attributes: ~
2862        not allowed when |textlock| is active
2863        Since: 0.5.0
2864
2865    Parameters: ~
2866      • {buf}          (`integer`) Buffer id, or 0 for current buffer
2867      • {start_row}    (`integer`) First line index
2868      • {start_col}    (`integer`) Starting column (byte offset) on first line
2869      • {end_row}      (`integer`) Last line index, inclusive
2870      • {end_col}      (`integer`) Ending column (byte offset) on last line,
2871                       exclusive
2872      • {replacement}  (`string[]`) Array of lines to use as replacement
2873
2874nvim_buf_set_var({buf}, {name}, {value})                  *nvim_buf_set_var()*
2875    Sets a buffer-scoped (b:) variable
2876
2877    Attributes: ~
2878        Since: 0.1.0
2879
2880    Parameters: ~
2881      • {buf}    (`integer`) Buffer id, or 0 for current buffer
2882      • {name}   (`string`) Variable name
2883      • {value}  (`any`) Variable value
2884
2885
2886==============================================================================
2887Command Functions                                                *api-command*
2888
2889                                              *nvim_buf_create_user_command()*
2890nvim_buf_create_user_command({buf}, {name}, {cmd}, {opts})
2891    Creates a buffer-local command |user-commands|.
2892
2893    Attributes: ~
2894        Since: 0.7.0
2895
2896    Parameters: ~
2897      • {buf}   (`integer`) Buffer id, or 0 for current buffer.
2898      • {name}  (`string`)
2899      • {cmd}   (`any`)
2900      • {opts}  (`vim.api.keyset.user_command?`)
2901
2902    See also: ~
2903      • nvim_create_user_command
2904
2905nvim_buf_del_user_command({buf}, {name})         *nvim_buf_del_user_command()*
2906    Delete a buffer-local user-defined command.
2907
2908    Only commands created with |:command-buffer| or
2909    |nvim_buf_create_user_command()| can be deleted with this function.
2910
2911    Attributes: ~
2912        Since: 0.7.0
2913
2914    Parameters: ~
2915      • {buf}   (`integer`) Buffer id, or 0 for current buffer.
2916      • {name}  (`string`) Name of the command to delete.
2917
2918nvim_buf_get_commands({buf}, {opts})                 *nvim_buf_get_commands()*
2919    Gets a map of buffer-local |user-commands|.
2920
2921    Attributes: ~
2922        Since: 0.3.0
2923
2924    Parameters: ~
2925      • {buf}   (`integer`) Buffer id, or 0 for current buffer
2926      • {opts}  (`vim.api.keyset.get_commands?`) Optional parameters.
2927                Currently not used.
2928
2929    Return: ~
2930        (`vim.api.keyset.command_info`) Map of maps describing commands.
2931
2932nvim_cmd({cmd}, {opts})                                           *nvim_cmd()*
2933    Executes an Ex command `cmd`, specified as a Dict with the same structure
2934    as returned by |nvim_parse_cmd()|.
2935
2936    Use `magic={…=false}` to disable special chars (see also |open-file|): >lua
2937        vim.api.nvim_cmd({
2938            cmd = 'edit',
2939            args = { '%foo"|bar#baz"' },
2940            magic = { file = false, bar = false }
2941          },
2942          {}
2943        )
2944<
2945    • See |nvim_parse_cmd()| to parse a cmdline string (which can then be
2946      passed to `nvim_cmd`).
2947    • See |nvim_command()| to execute a cmdline string.
2948
2949    On execution error: fails with Vimscript error, updates v:errmsg.
2950
2951    Attributes: ~
2952        Since: 0.8.0
2953
2954    Parameters: ~
2955      • {cmd}   (`vim.api.keyset.cmd`) Command to execute, a Dict with the
2956                same structure as the return value of |nvim_parse_cmd()|
2957                (except "addr", "nargs" and "nextcmd" are ignored). All keys
2958                except "cmd" are optional.
2959      • {opts}  (`vim.api.keyset.cmd_opts?`) Optional parameters.
2960                • output: (boolean, default false) Whether to return command
2961                  output.
2962
2963    Return: ~
2964        (`string`) Command output (non-error, non-shell |:!|) if `output` is
2965        true, else empty string.
2966
2967    See also: ~
2968      • |nvim_command()|
2969      • |nvim_exec2()|
2970      • |nvim_parse_cmd()|
2971
2972                                                  *nvim_create_user_command()*
2973nvim_create_user_command({name}, {cmd}, {opts})
2974    Creates a global |user-commands| command.
2975
2976    For Lua usage see |lua-guide-commands-create|.
2977
2978    Example: >vim
2979        :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true})
2980        :SayHello
2981        Hello world!
2982<
2983
2984    Attributes: ~
2985        Since: 0.7.0
2986
2987    Parameters: ~
2988      • {name}  (`string`) Command name. First char must be uppercase.
2989      • {cmd}   (`string|fun(args: vim.api.keyset.create_user_command.command_args)`)
2990                Command or Lua function, executed when the command is invoked.
2991                Lua function receives a table with keys:
2992                • args: (string) Args passed to the command, if any. <args>
2993                • bang: (boolean) true if the command was executed with "!".
2994                  <bang>
2995                • count: (number) Count, if any. <count>
2996                • fargs: (table) Args split by unescaped whitespace (when more
2997                  than one arg is allowed), if any. <f-args>
2998                • line1: (number) Start of the command range. <line1>
2999                • line2: (number) End of the command range. <line2>
3000                • mods: (string) Command modifiers (unstructured string), if
3001                  any. <mods>
3002                • name: (string) Command name.
3003                • nargs: (string) Number of arguments allowed by the command.
3004                  |:command-nargs|
3005                • range: (number) Number of items in the command range: 0, 1,
3006                  or 2. <range>
3007                • reg: (string) Register name, if any. <reg>
3008                • smods: (table) Command modifiers (structured), same as
3009                  "mods" in |nvim_parse_cmd()|.
3010      • {opts}  (`vim.api.keyset.user_command?`) Optional flags:
3011                • `addr` |:command-addr|
3012                • `complete` |:command-complete| command or function
3013                  |:command-completion-customlist|.
3014                • `count` |:command-count|
3015                • `desc` (string) Command description.
3016                • `force` (boolean, default true) Override the existing
3017                  definition, if any.
3018                • `nargs` Number of arguments allowed by the command.
3019                  |:command-nargs|
3020                • `preview` (function) Preview handler for 'inccommand'.
3021                  |:command-preview|
3022                • `range` |:command-range|
3023                • boolean |command-attributes| such as |:command-bang| or
3024                  |:command-bar| (but not |:command-buffer|, use
3025                  |nvim_buf_create_user_command()| instead).
3026
3027nvim_del_user_command({name})                        *nvim_del_user_command()*
3028    Delete a user-defined command.
3029
3030    Attributes: ~
3031        Since: 0.7.0
3032
3033    Parameters: ~
3034      • {name}  (`string`) Name of the command to delete.
3035
3036nvim_get_commands({opts})                                *nvim_get_commands()*
3037    Gets a map of global (non-buffer-local) Ex commands.
3038
3039    Currently only |user-commands| are supported, not builtin Ex commands.
3040
3041    Attributes: ~
3042        Since: 0.3.0
3043
3044    Parameters: ~
3045      • {opts}  (`vim.api.keyset.get_commands?`) Optional parameters.
3046                Currently only supports {"builtin":false}
3047
3048    Return: ~
3049        (`table<string,vim.api.keyset.command_info>`) Map of maps describing
3050        commands.
3051
3052    See also: ~
3053      • |nvim_get_all_options_info()|
3054
3055nvim_parse_cmd({str}, {opts})                               *nvim_parse_cmd()*
3056    Parse command line.
3057
3058    Doesn't check the validity of command arguments.
3059
3060    Attributes: ~
3061        |api-fast|
3062        Since: 0.8.0
3063
3064    Parameters: ~
3065      • {str}   (`string`) Command line string to parse. Cannot contain "\n".
3066      • {opts}  (`vim.api.keyset.empty?`) Optional parameters. Reserved for
3067                future use.
3068
3069    Return: ~
3070        (`vim.api.keyset.cmd`) Dict containing command information, with these
3071        keys:
3072        • cmd: (string) Command name.
3073        • range: (array) (optional) Command range (<line1> <line2>). Omitted
3074          if command doesn't accept a range. Otherwise, has no elements if no
3075          range was specified, one element if only a single range item was
3076          specified, or two elements if both range items were specified.
3077        • count: (number) (optional) Command <count>. Omitted if command
3078          cannot take a count.
3079        • reg: (string) (optional) Command <register>. Omitted if command
3080          cannot take a register.
3081        • bang: (boolean) Whether command contains a <bang> (!) modifier.
3082        • args: (array) Command arguments.
3083        • addr: (string) Value of |:command-addr|. Uses short name or "line"
3084          for -addr=lines.
3085        • nargs: (string) Value of |:command-nargs|.
3086        • nextcmd: (string) Next command if there are multiple commands
3087          separated by a |:bar|. Empty if there isn't a next command.
3088        • magic: (dict) Which characters have special meaning in the command
3089          arguments.
3090          • file: (boolean) The command expands filenames. Which means
3091            characters such as "%", "#" and wildcards are expanded.
3092          • bar: (boolean) The "|" character is treated as a command separator
3093            and the double quote character (") is treated as the start of a
3094            comment.
3095        • mods: (dict) |:command-modifiers|.
3096          • filter: (dict) |:filter|.
3097            • pattern: (string) Filter pattern. Empty string if there is no
3098              filter.
3099            • force: (boolean) Whether filter is inverted or not.
3100          • silent: (boolean) |:silent|.
3101          • emsg_silent: (boolean) |:silent!|.
3102          • unsilent: (boolean) |:unsilent|.
3103          • sandbox: (boolean) |:sandbox|.
3104          • noautocmd: (boolean) |:noautocmd|.
3105          • browse: (boolean) |:browse|.
3106          • confirm: (boolean) |:confirm|.
3107          • hide: (boolean) |:hide|.
3108          • horizontal: (boolean) |:horizontal|.
3109          • keepalt: (boolean) |:keepalt|.
3110          • keepjumps: (boolean) |:keepjumps|.
3111          • keepmarks: (boolean) |:keepmarks|.
3112          • keeppatterns: (boolean) |:keeppatterns|.
3113          • lockmarks: (boolean) |:lockmarks|.
3114          • noswapfile: (boolean) |:noswapfile|.
3115          • tab: (integer) |:tab|. -1 when omitted.
3116          • verbose: (integer) |:verbose|. -1 when omitted.
3117          • vertical: (boolean) |:vertical|.
3118          • split: (string) Split modifier string, is an empty string when
3119            there's no split modifier. If there is a split modifier it can be
3120            one of:
3121            • "aboveleft": |:aboveleft|.
3122            • "belowright": |:belowright|.
3123            • "topleft": |:topleft|.
3124            • "botright": |:botright|.
3125
3126
3127==============================================================================
3128Extmark Functions                                                *api-extmark*
3129
3130                                                  *nvim_buf_clear_namespace()*
3131nvim_buf_clear_namespace({buf}, {ns_id}, {line_start}, {line_end})
3132    Clears |namespace|d objects (highlights, |extmarks|, virtual text) from a
3133    region.
3134
3135    Lines are 0-indexed. |api-indexing| To clear the namespace in the entire
3136    buffer, specify line_start=0 and line_end=-1.
3137
3138    Attributes: ~
3139        Since: 0.3.2
3140
3141    Parameters: ~
3142      • {buf}         (`integer`) Buffer id, or 0 for current buffer
3143      • {ns_id}       (`integer`) Namespace to clear, or -1 to clear all
3144                      namespaces.
3145      • {line_start}  (`integer`) Start of range of lines to clear
3146      • {line_end}    (`integer`) End of range of lines to clear (exclusive)
3147                      or -1 to clear to end of buffer.
3148
3149nvim_buf_del_extmark({buf}, {ns_id}, {id})            *nvim_buf_del_extmark()*
3150    Removes an |extmark|.
3151
3152    Attributes: ~
3153        Since: 0.5.0
3154
3155    Parameters: ~
3156      • {buf}    (`integer`) Buffer id, or 0 for current buffer
3157      • {ns_id}  (`integer`) |namespace| id
3158      • {id}     (`integer`) Extmark id
3159
3160    Return: ~
3161        (`boolean`) true if the extmark was found, else false
3162
3163                                                *nvim_buf_get_extmark_by_id()*
3164nvim_buf_get_extmark_by_id({buf}, {ns_id}, {id}, {opts})
3165    Gets the position (0-indexed) of an |extmark|.
3166
3167    Attributes: ~
3168        Since: 0.5.0
3169
3170    Parameters: ~
3171      • {buf}    (`integer`) Buffer id, or 0 for current buffer
3172      • {ns_id}  (`integer`) |namespace| id
3173      • {id}     (`integer`) Extmark id
3174      • {opts}   (`vim.api.keyset.get_extmark?`) Optional parameters. Keys:
3175                 • details: Whether to include the details dict
3176                 • hl_name: Whether to include highlight group name instead of
3177                   id, true if omitted
3178
3179    Return: ~
3180        (`[integer, integer, vim.api.keyset.extmark_details?]`) 0-indexed
3181        (row, col, details?) tuple or empty list () if extmark id was absent.
3182        The optional `details` dictionary contains the same keys as `opts` in
3183        |nvim_buf_set_extmark()|, except for `id`, `conceal_lines` and
3184        `ephemeral`. It also contains the following keys:
3185        • ns_id: |namespace| id
3186        • invalid: boolean that indicates whether the mark is hidden because
3187          the entirety of text span range is deleted. See also the key
3188          `invalidate` in |nvim_buf_set_extmark()|.
3189
3190                                                     *nvim_buf_get_extmarks()*
3191nvim_buf_get_extmarks({buf}, {ns_id}, {start}, {end}, {opts})
3192    Gets |extmarks| in "traversal order" from a |charwise| region defined by
3193    buffer positions (inclusive, 0-indexed |api-indexing|).
3194
3195    Region can be given as (row,col) tuples, or valid extmark ids (whose
3196    positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
3197    respectively, thus the following are equivalent: >lua
3198        vim.api.nvim_buf_get_extmarks(0, my_ns, 0, -1)
3199        vim.api.nvim_buf_get_extmarks(0, my_ns, {0,0}, {-1,-1})
3200<
3201
3202    If `end` is less than `start`, marks are returned in reverse order.
3203    (Useful with `limit`, to get the first marks prior to a given position.)
3204
3205    Note:
3206    • For a reverse range, `limit` does not actually affect the traversed
3207      range, just how many marks are returned
3208    • When using extmark ranges (marks with a end_row/end_col position) the
3209      `overlap` option might be useful. Otherwise only the start position of
3210      an extmark will be considered.
3211    • The |:marks| command can list extmarks.
3212    • Legacy signs placed through the |:sign| commands are implemented as
3213      extmarks. Their details array will contain a `sign_name` field.
3214
3215    Example: >lua
3216        local api = vim.api
3217        local pos = api.nvim_win_get_cursor(0)
3218        local ns  = api.nvim_create_namespace('my-plugin')
3219        -- Create new extmark at line 1, column 1.
3220        local m1  = api.nvim_buf_set_extmark(0, ns, 0, 0)
3221        -- Create new extmark at line 3, column 1.
3222        local m2  = api.nvim_buf_set_extmark(0, ns, 2, 0)
3223        -- Get extmarks only from line 3.
3224        local ms  = api.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0})
3225        -- Get all marks in this buffer + namespace.
3226        local all = api.nvim_buf_get_extmarks(0, ns, 0, -1)
3227        vim.print(ms)
3228<
3229
3230    Attributes: ~
3231        Since: 0.5.0
3232
3233    Parameters: ~
3234      • {buf}    (`integer`) Buffer id, or 0 for current buffer
3235      • {ns_id}  (`integer`) |namespace| id, or -1 for all namespaces
3236      • {start}  (`any`) Start of range: a 0-indexed (row, col) or valid
3237                 extmark id (whose position defines the bound). |api-indexing|
3238      • {end}    (`any`) End of range (inclusive): a 0-indexed (row, col) or
3239                 valid extmark id (whose position defines the bound).
3240                 |api-indexing|
3241      • {opts}   (`vim.api.keyset.get_extmarks?`) Optional parameters. Keys:
3242                 • details: Whether to include the details dict
3243                 • hl_name: Whether to include highlight group name instead of
3244                   id, true if omitted
3245                 • limit: Maximum number of marks to return
3246                 • overlap: Also include marks which overlap the range, even
3247                   if their start position is less than `start`
3248                 • type: Filter marks by type: "highlight", "sign",
3249                   "virt_text" and "virt_lines"
3250
3251    Return: ~
3252        (`vim.api.keyset.get_extmark_item[]`) List of
3253        `[extmark_id, row, col, details?]` tuples in "traversal order". For
3254        the `details` dictionary, see |nvim_buf_get_extmark_by_id()|.
3255
3256                                                      *nvim_buf_set_extmark()*
3257nvim_buf_set_extmark({buf}, {ns_id}, {line}, {col}, {opts})
3258    Creates or updates an |extmark|.
3259
3260    By default a new extmark is created when no id is passed in, but it is
3261    also possible to create a new mark by passing in a previously unused id or
3262    move an existing mark by passing in its id. The caller must then keep
3263    track of existing and unused ids itself. (Useful over RPC, to avoid
3264    waiting for the return value.)
3265
3266    Using the optional arguments, it is possible to use this to highlight a
3267    range of text, and also to associate virtual text to the mark.
3268
3269    If present, the position defined by `end_col` and `end_row` should be
3270    after the start position in order for the extmark to cover a range. An
3271    earlier end position is not an error, but then it behaves like an empty
3272    range (no highlighting).
3273
3274    Attributes: ~
3275        Since: 0.5.0
3276
3277    Parameters: ~
3278      • {buf}    (`integer`) Buffer id, or 0 for current buffer
3279      • {ns_id}  (`integer`) |namespace| id
3280      • {line}   (`integer`) Line where to place the mark, 0-based.
3281                 |api-indexing|
3282      • {col}    (`integer`) Column where to place the mark, 0-based.
3283                 |api-indexing|
3284      • {opts}   (`vim.api.keyset.set_extmark?`) Optional parameters:
3285                 • conceal: (boolean|string)
3286                   • string: Single char or empty string, enables conceal
3287                     similar to |:syn-conceal|. Non-empty char is used as
3288                     |:syn-cchar|. Highlighted with "hl_group" if defined,
3289                     else defaults to |hl-Conceal|.
3290                   • boolean: true is equivalent to "", false removes any
3291                     existing conceal.
3292                 • conceal_lines: (string) Line-level conceal. When set to an
3293                   empty string (other values reserved for future use), the
3294                   lines in the extmark range are not drawn; the next
3295                   non-concealed line is drawn in their place. Requires
3296                   'conceallevel' >= 2; subject to 'concealcursor' on the
3297                   cursor line.
3298                 • cursorline_hl_group: Highlight group used for the
3299                   'signcolumn' text when the cursor is on the same line as
3300                   the mark and 'cursorline' is enabled.
3301                 • end_col: End-column of the mark, 0-based exclusive, or -1
3302                   to extend the range to end of line (if strict=false).
3303                 • end_right_gravity: (boolean, default: false) Indicates
3304                   which direction the extmark end-position (if any) will be
3305                   shifted when new text is inserted (true=right, false=left).
3306                 • end_row: End-line of the mark, 0-based inclusive.
3307                 • ephemeral: For use with |nvim_set_decoration_provider()|
3308                   callbacks. The mark will only be used for the current
3309                   redraw cycle, and not stored in the buffer.
3310                 • hl_eol: When true, for a multiline highlight covering the
3311                   EOL of a line, continue the highlight for the rest of the
3312                   screen line (just like for diff and cursorline highlight).
3313                 • hl_group: Highlight group for the text range. This and
3314                   below highlight groups can be given as a string or as an
3315                   integer (|nvim_get_hl_id_by_name()|). Multiple highlight
3316                   groups can be stacked by passing an array (highest-priority
3317                   last).
3318                 • hl_mode: Controls how highlights are combined with the
3319                   highlights of the text. Only affects virt_text highlights,
3320                   but might affect `hl_group` in the future.
3321                   • "replace": Only show the virt_text color. This is the
3322                     default.
3323                   • "combine": Combine with background text color.
3324                   • "blend": Blend with background text color. Not supported
3325                     for "inline" virt_text.
3326                 • id: Update this extmark instead of creating a new one.
3327                 • invalidate: (boolean) Indicates whether to hide the extmark
3328                   if the entirety of its range is deleted. For hidden marks,
3329                   an "invalid" key is added to the "details" array of
3330                   |nvim_buf_get_extmarks()| and family. If "undo_restore" is
3331                   false, the extmark is deleted instead.
3332                 • line_hl_group: Highlight group used for the whole line.
3333                 • number_hl_group: Highlight group used for the number
3334                   column.
3335                 • priority: Priority of the highlight group, sign attribute
3336                   or virtual text. For virtual text, the highest-priority
3337                   item is drawn last. For example treesitter highlighting
3338                   uses a value of 100.
3339                 • right_gravity: (boolean, default: true) Indicates which
3340                   direction the extmark will be shifted when new text is
3341                   inserted (true=right, false=left).
3342                 • sign_hl_group: Highlight group for `sign_text`.
3343                 • sign_text: (string, length 1-2) Displayed in 'signcolumn'.
3344                 • spell: (boolean) Indicates that spell checking should be
3345                   performed within this extmark.
3346                 • strict: (boolean, default: true) Indicates extmark should
3347                   not be placed if the line or column value is past
3348                   end-of-buffer or end-of-line respectively.
3349                 • ui_watched: (boolean) Indicates the mark should be drawn by
3350                   a UI; activates `win_extmark` |ui-multigrid| events. Note:
3351                   the mark is positioned by virt_text attributes. Can be used
3352                   with virt_text.
3353                 • undo_restore: (default: true) Restore the exact position of
3354                   the mark if text around the mark was deleted and then
3355                   restored by undo.
3356                 • url: URL stored on this extmark. In the TUI, the OSC 8
3357                   control sequence is used to generate a clickable hyperlink
3358                   to this URL.
3359                 • virt_lines: List of virtual lines to place next to the
3360                   mark, where each line is a list of `[text_chunk, hl]`
3361                   tuples. Buffer and window options do not affect the display
3362                   of the text, except 'tabstop' is used for hard tabs. The
3363                   'wrap' and 'linebreak' options do not take effect, so the
3364                   number of extra screen lines will match the list-size (but
3365                   see `virt_lines_overflow`). By default lines are placed
3366                   below the marked line. Special case: If the last
3367                   `text_chunk` is empty, the corresponding `hl` will extend
3368                   to the end of the line.
3369                 • virt_lines_above: Place virtual lines above instead.
3370                 • virt_lines_leftcol: Place virtual lines in the leftmost
3371                   column of the window, bypassing sign and number columns.
3372                 • virt_lines_overflow: Controls display of virtual lines
3373                   exceeding the viewport:
3374                   • "auto": Decided by the 'wrap' option.
3375                   • "scroll": Scroll horizontally with 'nowrap', otherwise
3376                     the same as "trunc".
3377                   • "trunc": Truncate on the right (default).
3378                   • "wrap": Always wrap (regardless of the 'wrap' option).
3379                 • virt_text: *virtual-text* stored and displayed by this
3380                   mark. List of `[text, hl]` tuples, each representing a text
3381                   chunk with a highlight `hl` which may be a single highlight
3382                   group or a list of stacked highlight groups
3383                   (highest-priority last).
3384                 • virt_text_hide: Hide the virtual text when the background
3385                   text is selected or hidden because of scrolling with
3386                   'nowrap' or 'smoothscroll'. Currently only affects
3387                   "overlay" virt_text.
3388                 • virt_text_pos: Position of virtual text:
3389                   • "eol": Right after EOL character (default).
3390                   • "eol_right_align": Display right-aligned in the window
3391                     unless the virtual text is longer than the space
3392                     available. If the virtual text is too long, it is
3393                     truncated to fit in the window after the EOL character.
3394                     If the line is wrapped, the virtual text is shown after
3395                     the end of the line rather than the previous screen line.
3396                   • "overlay": Display over the specified column, without
3397                     shifting the underlying text.
3398                   • "right_align": Display right-aligned in the window.
3399                   • "inline": Display at the specified column, and
3400                     right-shift the buffer text as needed.
3401                 • virt_text_repeat_linebreak: Repeat the virtual text on
3402                   wrapped lines.
3403                 • virt_text_win_col: Position the virtual text at a fixed
3404                   window column (starting from the first text column of the
3405                   screen line) instead of "virt_text_pos".
3406
3407    Return: ~
3408        (`integer`) Id of the created/updated extmark
3409
3410nvim_create_namespace({name})                        *nvim_create_namespace()*
3411    Creates a new namespace or gets an existing one.               *namespace*
3412
3413    Namespaces are used for buffer highlights and virtual text, see
3414    |nvim_buf_set_extmark()|.
3415
3416    Namespaces can be named or anonymous. If `name` matches an existing
3417    namespace, the associated id is returned. If `name` is an empty string a
3418    new, anonymous namespace is created.
3419
3420    Attributes: ~
3421        Since: 0.3.2
3422
3423    Parameters: ~
3424      • {name}  (`string`) Namespace name or empty string
3425
3426    Return: ~
3427        (`integer`) Namespace id
3428
3429nvim_get_namespaces()                                  *nvim_get_namespaces()*
3430    Gets existing, non-anonymous |namespace|s.
3431
3432    Attributes: ~
3433        Since: 0.3.2
3434
3435    Return: ~
3436        (`table<string,integer>`) dict that maps from names to namespace ids.
3437
3438                                              *nvim_set_decoration_provider()*
3439nvim_set_decoration_provider({ns_id}, {opts})
3440    Set or change decoration provider for a |namespace|
3441
3442    This is a very general purpose interface for having Lua callbacks being
3443    triggered during the redraw code.
3444
3445    The expected usage is to set |extmarks| for the currently redrawn buffer.
3446    |nvim_buf_set_extmark()| can be called to add marks on a per-window or
3447    per-lines basis. Use the `ephemeral` key to only use the mark for the
3448    current screen redraw (the callback will be called again for the next
3449    redraw).
3450
3451    Note: this function should not be called often. Rather, the callbacks
3452    themselves can be used to throttle unneeded callbacks. the `on_start`
3453    callback can return `false` to disable the provider until the next redraw.
3454    Similarly, return `false` in `on_win` will skip the `on_line` and
3455    `on_range` calls for that window (but any extmarks set in `on_win` will
3456    still be used). A plugin managing multiple sources of decoration should
3457    ideally only set one provider, and merge the sources internally. You can
3458    use multiple `ns_id` for the extmarks set/modified inside the callback
3459    anyway.
3460
3461    Note: doing anything other than setting extmarks is considered
3462    experimental. Doing things like changing options are not explicitly
3463    forbidden, but is likely to have unexpected consequences (such as 100% CPU
3464    consumption). Doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is
3465    quite dubious for the moment.
3466
3467    Note: It is not allowed to remove or update extmarks in `on_line` or
3468    `on_range` callbacks.
3469
3470    Note: Callbacks will not run for |window-hidden|, as they are not redrawn.
3471
3472    Attributes: ~
3473        Lua |vim.api| only
3474        Since: 0.5.0
3475
3476    Parameters: ~
3477      • {ns_id}  (`integer`) |namespace| id
3478      • {opts}   (`vim.api.keyset.set_decoration_provider?`) Table of
3479                 callbacks:
3480                 • on_buf: called for each buffer being redrawn (once per
3481                   edit, before window callbacks) >
3482                    ["buf", bufnr, tick]
3483<
3484                 • on_end: called at the end of a redraw cycle >
3485                    ["end", tick]
3486<
3487                 • on_line: (deprecated, use on_range instead) >
3488                    ["line", winid, bufnr, row]
3489<
3490                 • on_range: called for each buffer range being redrawn. Range
3491                   is end-exclusive and may span multiple lines. Range bounds
3492                   point to the first byte of a character. An end position of
3493                   the form (lnum, 0), including (number of lines, 0), is
3494                   valid and indicates that EOL of the preceding line is
3495                   included. >
3496                    ["range", winid, bufnr, begin_row, begin_col, end_row, end_col]
3497<
3498                   In addition to returning a boolean, it is also allowed to
3499                   return a `skip_row, skip_col` pair of integers. This
3500                   implies that this function does not need to be called until
3501                   a range which continues beyond the skipped position. A
3502                   single integer return value `skip_row` is short for
3503                   `skip_row, 0`
3504                 • on_start: called first on each screen redraw >
3505                    ["start", tick]
3506<
3507                 • on_win: called when starting to redraw a specific window. >
3508                    ["win", winid, bufnr, toprow, botrow]
3509<
3510
3511nvim__ns_get({ns_id})                                         *nvim__ns_get()*
3512    WARNING: This feature is experimental/unstable.
3513
3514    Get the properties for namespace
3515
3516    Parameters: ~
3517      • {ns_id}  (`integer`) Namespace
3518
3519    Return: ~
3520        (`vim.api.keyset.ns_opts`) Map defining the namespace properties, see
3521        |nvim__ns_set()|
3522
3523nvim__ns_set({ns_id}, {opts})                                 *nvim__ns_set()*
3524    WARNING: This feature is experimental/unstable.
3525
3526    Set some properties for namespace
3527
3528    Parameters: ~
3529      • {ns_id}  (`integer`) Namespace
3530      • {opts}   (`vim.api.keyset.ns_opts?`) Optional parameters to set:
3531                 • wins: a list of windows to be scoped in
3532
3533
3534==============================================================================
3535Options Functions                                                *api-options*
3536
3537nvim_get_all_options_info()                      *nvim_get_all_options_info()*
3538    Gets the option information for all options.
3539
3540    The dict has the full option names as keys and option metadata dicts as
3541    detailed at |nvim_get_option_info2()|.
3542
3543    Attributes: ~
3544        Since: 0.5.0
3545
3546    Return: ~
3547        (`table<string,any>`) dict of all options
3548
3549    See also: ~
3550      • |nvim_get_commands()|
3551
3552nvim_get_option_info2({name}, {opts})                *nvim_get_option_info2()*
3553    Gets the option information for one option from arbitrary buffer or window
3554
3555    Resulting dict has keys:
3556    • name: Name of the option (like 'filetype')
3557    • shortname: Shortened name of the option (like 'ft')
3558    • type: type of option ("string", "number" or "boolean")
3559    • default: The default value for the option
3560    • was_set: Whether the option was set.
3561    • last_set_sid: Last set script id (if any)
3562    • last_set_linenr: line number where option was set
3563    • last_set_chan: Channel where option was set (0 for local)
3564    • scope: one of "global", "win", "buf", or "tab"
3565    • global_local: whether win or buf option has a global value
3566    • commalist: List of comma separated values
3567    • flaglist: List of single char flags
3568
3569    When {scope} is not provided, the last set information applies to the
3570    local value in the current buffer or window if it is available, otherwise
3571    the global value information is returned. This behavior can be disabled by
3572    explicitly specifying {scope} in the {opts} table.
3573
3574    Attributes: ~
3575        Since: 0.9.0
3576
3577    Parameters: ~
3578      • {name}  (`string`) Option name
3579      • {opts}  (`vim.api.keyset.option?`) Optional parameters
3580                • buf: Buffer number. Used for getting buffer local options.
3581                  Implies {scope} is "local".
3582                • scope: One of "global" or "local". Analogous to |:setglobal|
3583                  and |:setlocal|, respectively.
3584                • win: |window-ID|. Used for getting window local options.
3585
3586    Return: ~
3587        (`vim.api.keyset.get_option_info`) Option Information
3588
3589nvim_get_option_value({name}, {opts})                *nvim_get_option_value()*
3590    Gets the value of an option. The behavior of this function matches that of
3591    |:set|: the local value of an option is returned if it exists; otherwise,
3592    the global value is returned. Local values always correspond to the
3593    current buffer or window, unless "buf" or "win" is set in {opts}.
3594
3595    Attributes: ~
3596        Since: 0.7.0
3597
3598    Parameters: ~
3599      • {name}  (`string`) Option name
3600      • {opts}  (`vim.api.keyset.option?`) Optional parameters
3601                • buf: Buffer number. Used for getting buffer local options.
3602                  Implies {scope} is "local".
3603                • filetype: |filetype|. Used to get the default option for a
3604                  specific filetype. Cannot be used with any other option.
3605                  Note: this will trigger |ftplugin| and all |FileType|
3606                  autocommands for the corresponding filetype.
3607                • scope: One of "global" or "local". Analogous to |:setglobal|
3608                  and |:setlocal|, respectively.
3609                • tab: |tab-ID| for tab-local options. Currently only supports
3610                  "cmdheight". Tabpage `0` means the current tabpage.
3611                • win: |window-ID|. Used for getting window local options.
3612
3613    Return: ~
3614        (`any`) Option value
3615
3616                                                     *nvim_set_option_value()*
3617nvim_set_option_value({name}, {value}, {opts})
3618    Sets the value of an option. The behavior of this function matches that of
3619    |:set|: for global-local options, both the global and local value are set
3620    unless otherwise specified with {scope}.
3621
3622    Note the options {win} and {buf} cannot be used together.
3623
3624    Attributes: ~
3625        Since: 0.7.0
3626
3627    Parameters: ~
3628      • {name}   (`string`) Option name
3629      • {value}  (`any`) New option value
3630      • {opts}   (`vim.api.keyset.option?`) Optional parameters
3631                 • buf: Buffer number. Used for setting buffer local option.
3632                 • dry_run: (`boolean?`, default: false) If true, validates
3633                   the option value without setting it.
3634                 • operation: One of "set", "append", "prepend", or "remove".
3635                   Corresponds to |:set=|, |:set+=|, |:set^=|, and |:set-=|.
3636                   Default is "set".
3637                 • scope: One of "global" or "local". Analogous to
3638                   |:setglobal| and |:setlocal|, respectively.
3639                 • tab: |tab-ID| for tab-local options (currently only
3640                   'cmdheight'). Tabpage 0 means the current tabpage. If a
3641                   non-current tab is given, the value will take effect when
3642                   it is switched-to.
3643                 • win: |window-ID|. Used for setting window local option.
3644
3645    Return: ~
3646        (`any`) Option value
3647
3648
3649==============================================================================
3650Tabpage Functions                                                *api-tabpage*
3651
3652nvim_open_tabpage({buf}, {enter}, {config})              *nvim_open_tabpage()*
3653    Opens a new tabpage.
3654
3655    Attributes: ~
3656        not allowed when |textlock| is active
3657        Since: 0.12.0
3658
3659    Parameters: ~
3660      • {buf}     (`integer`) Buffer to open in the first window of the new
3661                  tabpage. Use 0 for current buffer.
3662      • {enter}   (`boolean`) Enter the tabpage (make it the current tabpage).
3663      • {config}  (`vim.api.keyset.tabpage_config`) Configuration for the new
3664                  tabpage. Keys:
3665                  • after: Position to insert tabpage (default: -1; after
3666                    current). 0 = first, N = after Nth.
3667
3668    Return: ~
3669        (`integer`) |tab-ID| of the new tabpage
3670
3671nvim_tabpage_del_var({tabpage}, {name})               *nvim_tabpage_del_var()*
3672    Removes a tab-scoped (t:) variable
3673
3674    Attributes: ~
3675        Since: 0.1.0
3676
3677    Parameters: ~
3678      • {tabpage}  (`integer`) |tab-ID|, or 0 for current tabpage
3679      • {name}     (`string`) Variable name
3680
3681nvim_tabpage_get_number({tabpage})                 *nvim_tabpage_get_number()*
3682    Gets the tabpage number
3683
3684    Attributes: ~
3685        Since: 0.1.0
3686
3687    Parameters: ~
3688      • {tabpage}  (`integer`) |tab-ID|, or 0 for current tabpage
3689
3690    Return: ~
3691        (`integer`) Tabpage number
3692
3693nvim_tabpage_get_var({tabpage}, {name})               *nvim_tabpage_get_var()*
3694    Gets a tab-scoped (t:) variable
3695
3696    Attributes: ~
3697        Since: 0.1.0
3698
3699    Parameters: ~
3700      • {tabpage}  (`integer`) |tab-ID|, or 0 for current tabpage
3701      • {name}     (`string`) Variable name
3702
3703    Return: ~
3704        (`any`) Variable value
3705
3706nvim_tabpage_get_win({tabpage})                       *nvim_tabpage_get_win()*
3707    Gets the current window in a tabpage
3708
3709    Attributes: ~
3710        Since: 0.1.0
3711
3712    Parameters: ~
3713      • {tabpage}  (`integer`) |tab-ID|, or 0 for current tabpage
3714
3715    Return: ~
3716        (`integer`) |window-ID|
3717
3718nvim_tabpage_is_valid({tabpage})                     *nvim_tabpage_is_valid()*
3719    Checks if a tabpage is valid
3720
3721    Attributes: ~
3722        Since: 0.1.0
3723
3724    Parameters: ~
3725      • {tabpage}  (`integer`) |tab-ID|, or 0 for current tabpage
3726
3727    Return: ~
3728        (`boolean`) true if the tabpage is valid, false otherwise
3729
3730nvim_tabpage_list_wins({tabpage})                   *nvim_tabpage_list_wins()*
3731    Gets the windows in a tabpage
3732
3733    Attributes: ~
3734        Since: 0.1.0
3735
3736    Parameters: ~
3737      • {tabpage}  (`integer`) |tab-ID|, or 0 for current tabpage
3738
3739    Return: ~
3740        (`integer[]`) List of windows in `tabpage`
3741
3742                                                      *nvim_tabpage_set_var()*
3743nvim_tabpage_set_var({tabpage}, {name}, {value})
3744    Sets a tab-scoped (t:) variable
3745
3746    Attributes: ~
3747        Since: 0.1.0
3748
3749    Parameters: ~
3750      • {tabpage}  (`integer`) |tab-ID|, or 0 for current tabpage
3751      • {name}     (`string`) Variable name
3752      • {value}    (`any`) Variable value
3753
3754nvim_tabpage_set_win({tabpage}, {win})                *nvim_tabpage_set_win()*
3755    Sets the current window in a tabpage
3756
3757    Attributes: ~
3758        Since: 0.10.0
3759
3760    Parameters: ~
3761      • {tabpage}  (`integer`) |tab-ID|, or 0 for current tabpage
3762      • {win}      (`integer`) |window-ID|, must already belong to {tabpage}
3763
3764
3765==============================================================================
3766UI Functions                                                          *api-ui*
3767
3768nvim_ui_attach({width}, {height}, {options})                *nvim_ui_attach()*
3769    Activates UI events on the channel.
3770
3771    Entry point of all UI clients. Allows |--embed| to continue startup.
3772    Implies that the client is ready to show the UI. Adds the client to the
3773    list of UIs. |nvim_list_uis()|
3774
3775    Note: ~
3776      • If multiple UI clients are attached, the global screen dimensions
3777        degrade to the smallest client. E.g. if client A requests 80x40 but
3778        client B requests 200x100, the global screen has size 80x40.
3779
3780    Attributes: ~
3781        |RPC| only
3782        Since: 0.1.0
3783
3784    Parameters: ~
3785      • {width}    (`integer`) Requested screen columns
3786      • {height}   (`integer`) Requested screen rows
3787      • {options}  (`table<string,any>`) |ui-option| map
3788
3789nvim_ui_detach()                                            *nvim_ui_detach()*
3790    Deactivates UI events on the channel.
3791
3792    Removes the client from the list of UIs. |nvim_list_uis()|
3793
3794    Attributes: ~
3795        |RPC| only
3796        Since: 0.1.0
3797
3798                                                    *nvim_ui_pum_set_bounds()*
3799nvim_ui_pum_set_bounds({width}, {height}, {row}, {col})
3800    Tells Nvim the geometry of the popupmenu, to align floating windows with
3801    an external popup menu.
3802
3803    Note that this method is not to be confused with
3804    |nvim_ui_pum_set_height()|, which sets the number of visible items in the
3805    popup menu, while this function sets the bounding box of the popup menu,
3806    including visual elements such as borders and sliders. Floats need not use
3807    the same font size, nor be anchored to exact grid corners, so one can set
3808    floating-point numbers to the popup menu geometry.
3809
3810    Attributes: ~
3811        |RPC| only
3812        Since: 0.5.0
3813
3814    Parameters: ~
3815      • {width}   (`number`) Popupmenu width.
3816      • {height}  (`number`) Popupmenu height.
3817      • {row}     (`number`) Popupmenu row.
3818      • {col}     (`number`) Popupmenu height.
3819
3820nvim_ui_pum_set_height({height})                    *nvim_ui_pum_set_height()*
3821    Tells Nvim the number of elements displaying in the popupmenu, to decide
3822    <PageUp> and <PageDown> movement.
3823
3824    Attributes: ~
3825        |RPC| only
3826        Since: 0.4.0
3827
3828    Parameters: ~
3829      • {height}  (`integer`) Popupmenu height, must be greater than zero.
3830
3831nvim_ui_send({content})                                       *nvim_ui_send()*
3832    Sends arbitrary data to a UI. Use this instead of |nvim_chan_send()| or
3833    `io.stdout:write()`, if you really want to write to the |TUI| host
3834    terminal.
3835
3836    Emits a "ui_send" event to all UIs with the "stdout_tty" |ui-option| set.
3837    UIs are expected to write the received data to a connected TTY if one
3838    exists.
3839
3840    Attributes: ~
3841        Since: 0.12.0
3842
3843    Parameters: ~
3844      • {content}  (`string`) Content to write to the TTY
3845
3846nvim_ui_set_focus({gained})                              *nvim_ui_set_focus()*
3847    Tells the nvim server if focus was gained or lost by the GUI
3848
3849    Attributes: ~
3850        |RPC| only
3851        Since: 0.9.0
3852
3853    Parameters: ~
3854      • {gained}  (`boolean`)
3855
3856nvim_ui_set_option({name}, {value})                     *nvim_ui_set_option()*
3857
3858    Attributes: ~
3859        |RPC| only
3860        Since: 0.1.0
3861
3862    Parameters: ~
3863      • {name}   (`string`)
3864      • {value}  (`any`)
3865
3866nvim_ui_try_resize({width}, {height})                   *nvim_ui_try_resize()*
3867
3868    Attributes: ~
3869        |RPC| only
3870        Since: 0.1.0
3871
3872    Parameters: ~
3873      • {width}   (`integer`)
3874      • {height}  (`integer`)
3875
3876                                                   *nvim_ui_try_resize_grid()*
3877nvim_ui_try_resize_grid({grid}, {width}, {height})
3878    Tell Nvim to resize a grid. Triggers a grid_resize event with the
3879    requested grid size or the maximum size if it exceeds size limits.
3880
3881    On invalid grid handle, fails with error.
3882
3883    Attributes: ~
3884        |RPC| only
3885        Since: 0.4.0
3886
3887    Parameters: ~
3888      • {grid}    (`integer`) The handle of the grid to be changed.
3889      • {width}   (`integer`) The new requested width.
3890      • {height}  (`integer`) The new requested height.
3891
3892
3893==============================================================================
3894Win_config Functions                                          *api-win_config*
3895
3896nvim_open_win({buf}, {enter}, {config})                      *nvim_open_win()*
3897    Opens a new split window, floating window, or external window.
3898    • Specify `relative` to create a floating window. Floats are drawn over
3899      the split layout, relative to a position in some other window. See
3900      |api-floatwin|.
3901      • Floats must specify `width` and `height`.
3902    • Specify `external` to create an external window. External windows are
3903      displayed as separate top-level windows managed by the |ui-multigrid| UI
3904      (not Nvim).
3905    • If `relative` and `external` are omitted, a normal "split" window is
3906      created.
3907      • The `win` key decides which window to split. If nil or 0, the split
3908        will be adjacent to the current window. If -1, a top-level split will
3909        be created.
3910      • Use `vertical` and `split` to control split direction. For `vertical`,
3911        the exact direction is determined by 'splitright' and 'splitbelow'.
3912      • Split windows cannot have `bufpos`, `row`, `col`, `border`, `title`,
3913        `footer`.
3914
3915    With relative=editor (row=0,col=0) refers to the top-left corner of the
3916    screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right
3917    corner. Fractional values are allowed, but the builtin implementation
3918    (used by non-multigrid UIs) will always round down to nearest integer.
3919
3920    Out-of-bounds values, and configurations that make the float not fit
3921    inside the main editor, are allowed. The builtin implementation truncates
3922    values so floats are fully within the main screen grid. External GUIs
3923    could let floats hover outside of the main window like a tooltip, but this
3924    should not be used to specify arbitrary WM screen positions.
3925
3926    Examples: >lua
3927        -- Window-relative float with 'statusline' enabled:
3928        local w1 = vim.api.nvim_open_win(0, false,
3929          {relative='win', row=3, col=3, width=40, height=4})
3930        vim.wo[w1].statusline = vim.o.statusline
3931
3932        -- Buffer-relative float (travels as buffer is scrolled):
3933        vim.api.nvim_open_win(0, false,
3934          {relative='win', width=40, height=4, bufpos={100,10}})
3935
3936        -- Vertical split left of the current window:
3937        vim.api.nvim_open_win(0, false, { split = 'left', win = 0, })
3938<
3939
3940    Attributes: ~
3941        not allowed when |textlock| is active
3942        Since: 0.4.0
3943
3944    Parameters: ~
3945      • {buf}     (`integer`) Buffer to display, or 0 for current buffer
3946      • {enter}   (`boolean`) Enter the window (make it the current window)
3947      • {config}  (`vim.api.keyset.win_config`) Map defining the window
3948                  configuration. Keys:
3949                  • anchor: Decides which corner of the float to place at
3950                    (row,col):
3951                    • "NW" northwest (default)
3952                    • "NE" northeast
3953                    • "SW" southwest
3954                    • "SE" southeast
3955                  • border: (`string|string[]`, default: 'winborder' option)
3956                    Window border. The string form accepts the same values as
3957                    the 'winborder' option. The array form must have a length
3958                    of eight or any divisor of eight, specifying the chars
3959                    that form the border in a clockwise fashion starting from
3960                    the top-left corner. For example, the double-box style can
3961                    be specified as: >
3962                    [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ].
3963<
3964                    If fewer than eight chars are given, they will be
3965                    repeated. An ASCII border could be specified as: >
3966                    [ "/", "-", \"\\\\\", "|" ],
3967<
3968                    Or one char for all sides: >
3969                    [ "x" ].
3970<
3971                    Empty string can be used to hide a specific border. This
3972                    example will show only vertical borders, not horizontal: >
3973                    [ "", "", "", ">", "", "", "", "<" ]
3974<
3975                    By default, |hl-FloatBorder| highlight is used, which
3976                    links to |hl-WinSeparator| when not defined. Each border
3977                    side can specify an optional highlight: >
3978                    [ ["+", "MyCorner"], ["x", "MyBorder"] ].
3979<
3980                  • bufpos: Places float relative to buffer text (only when
3981                    relative="win"). Takes a tuple of zero-indexed
3982                    `[line, column]`. `row` and `col` if given are applied
3983                    relative to this position, else they default to:
3984                    • `row=1` and `col=0` if `anchor` is "NW" or "NE"
3985                    • `row=0` and `col=0` if `anchor` is "SW" or "SE" (thus
3986                      like a tooltip near the buffer text).
3987                  • col: Column position in units of screen cell width, may be
3988                    fractional.
3989                  • external: GUI should display the window as an external
3990                    top-level window. Currently accepts no other positioning
3991                    configuration together with this.
3992                  • fixed: If true when anchor is NW or SW, the float window
3993                    would be kept fixed even if the window would be truncated.
3994                  • focusable: (default: true) Enable focus by user actions
3995                    (wincmds, mouse events). Non-|focusable| windows can be
3996                    entered by |nvim_set_current_win()|, or by mouse events if
3997                    `mouse=true`.
3998                  • footer: (`string|string[]?`) Footer in window border:
3999                    string or list of `[text, highlight]` tuples. Default
4000                    highlight group is `FloatFooter`.
4001                  • footer_pos: (default: "left") Footer position. One of:
4002                    "left", "center", "right". The `footer` field must be set
4003                    also.
4004                  • height: Window height (in character cells). Minimum of 1.
4005                  • hide: Hides the floating window. |window-hidden|
4006                  • mouse: (default: `focusable` value) If true, mouse events
4007                    interact with the window normally; if false, they pass
4008                    through to the window behind it.
4009                  • noautocmd: Block all autocommands for the duration of the
4010                    call. Cannot be changed by |nvim_win_set_config()|.
4011                  • relative: Sets the window layout to "floating", placed at
4012                    (row,col) coordinates relative to:
4013                    • "cursor" Cursor position in current window.
4014                    • "editor" The global editor grid.
4015                    • "laststatus" 'laststatus' if present, or last row.
4016                    • "mouse" Mouse position.
4017                    • "tabline" Tabline if present, or first row.
4018                    • "win" Window given by the `win` field, or current
4019                      window.
4020                  • row: Row position in units of "screen cell height", may be
4021                    fractional.
4022                  • split: Split direction: "left", "right", "above", "below".
4023                  • style: (optional) Configure the appearance of the window:
4024                    • "" No special style.
4025                    • "minimal" Nvim will display the window with many UI
4026                      options disabled. This is useful when displaying a
4027                      temporary float where the text should not be edited.
4028                      Disables 'number', 'relativenumber', 'cursorline',
4029                      'cursorcolumn', 'foldcolumn', 'spell' and 'list'
4030                      options. 'signcolumn' is changed to `auto` and
4031                      'colorcolumn' is cleared. 'statuscolumn' is changed to
4032                      empty. The end-of-buffer region is hidden by setting
4033                      `eob` flag of 'fillchars' to a space char, and clearing
4034                      the |hl-EndOfBuffer| region in 'winhighlight'.
4035                  • title: (optional) Title in window border, string or list.
4036                    List should consist of `[text, highlight]` tuples. If
4037                    string, or a tuple lacks a highlight, the default
4038                    highlight group is `FloatTitle`.
4039                  • title_pos: (default: "left") Title position. One of:
4040                    "left", "center", "right". The `title` field must be set
4041                    also.
4042                  • vertical: Split vertically |:vertical|.
4043                  • width: Window width (in character cells). Minimum of 1.
4044                  • win: |window-ID| target window. Can be in a different tab
4045                    page. Determines the window to split (negative values act
4046                    like |:topleft|, |:botright|), the relative window for a
4047                    `relative="win"` float, or just the target tab page
4048                    (inferred from the window) for others.
4049                  • zindex: (positive integer, default: 50) Stacking order.
4050                    Floats with higher `zindex` overlay floats with lower
4051                    indices. Below 100 is recommended, unless there is a good
4052                    reason to overshadow builtin elements. The cursor is
4053                    dimmed if an unfocused float above the cursor exceeds the
4054                    zindex of the current window by 50. These screen elements
4055                    have hard-coded z-indices:
4056                    • 100: |ins-completion-menu| popupmenu
4057                    • 200: message scrollback (|pager|)
4058                    • 250: |cmdline-completion| popupmenu (wildoptions=pum)
4059                  • _cmdline_offset: (EXPERIMENTAL) When provided, anchor the
4060                    |cmdline-completion| popupmenu to this window, with an
4061                    offset in screen cell width.
4062
4063    Return: ~
4064        (`integer`) |window-ID|, or 0 on error
4065
4066nvim_win_get_config({win})                             *nvim_win_get_config()*
4067    Gets window config as a dict which can be passed to |nvim_open_win()| as
4068    the `config` parameter.
4069
4070    For non-floating windows, `relative` is empty, thus you can check that
4071    field to detect if a window is a floatwin: >lua
4072        vim.print(vim.api.nvim_win_get_config(0).relative == '' and 'non-float' or 'float')
4073        -- Or use win_gettype().
4074        vim.print(vim.fn.win_gettype())
4075<
4076
4077    Attributes: ~
4078        Since: 0.4.0
4079
4080    Parameters: ~
4081      • {win}  (`integer`) |window-ID|, or 0 for current window
4082
4083    Return: ~
4084        (`vim.api.keyset.win_config`) Map defining the window configuration,
4085        see |nvim_open_win()|
4086
4087nvim_win_set_config({win}, {config})                   *nvim_win_set_config()*
4088    Reconfigures the layout and properties of a window.
4089    • Updates only the given keys; unspecified (`nil`) keys will not be
4090      changed.
4091    • Can move a window to another tabpage.
4092    • Can transform a window to/from a float.
4093    • Keys `row` / `col` / `relative` must be specified together.
4094    • Cannot move the last window in a tabpage to a different one.
4095
4096    Example: to convert a floating window to a "normal" split window, specify
4097    the `win` field: >lua
4098        vim.api.nvim_win_set_config(0, { split = 'above', win = vim.fn.win_getid(1), })
4099<
4100
4101    Attributes: ~
4102        Since: 0.4.0
4103
4104    Parameters: ~
4105      • {win}     (`integer`) |window-ID|, or 0 for current window
4106      • {config}  (`vim.api.keyset.win_config`) Map defining the window
4107                  configuration, see |nvim_open_win()|
4108
4109    See also: ~
4110      • |nvim_open_win()|
4111
4112
4113==============================================================================
4114Window Functions                                                  *api-window*
4115
4116nvim_win_call({win}, {fn})                                   *nvim_win_call()*
4117    Calls function `fn` in the context of window `win` and returns its result
4118    (may be multiple values).
4119
4120    Attributes: ~
4121        Lua |vim.api| only
4122        Since: 0.5.0
4123
4124    Parameters: ~
4125      • {win}  (`integer`) |window-ID|, or 0 for current window.
4126      • {fn}   (`function`) Lua function to call inside the window.
4127
4128    Return: ~
4129        (`any`) Value(s) returned by `fn()`.
4130
4131    See also: ~
4132      • |win_execute()|
4133      • |nvim_buf_call()|
4134
4135nvim_win_close({win}, {force})                              *nvim_win_close()*
4136    Closes the window (like |:close| with a |window-ID|).
4137
4138    Attributes: ~
4139        not allowed when |textlock| is active
4140        Since: 0.4.0
4141
4142    Parameters: ~
4143      • {win}    (`integer`) |window-ID|, or 0 for current window
4144      • {force}  (`boolean`) Behave like `:close!` The last window of a buffer
4145                 with unwritten changes can be closed. The buffer will become
4146                 hidden, even if 'hidden' is not set.
4147
4148nvim_win_del_var({win}, {name})                           *nvim_win_del_var()*
4149    Removes a window-scoped (w:) variable
4150
4151    Attributes: ~
4152        Since: 0.1.0
4153
4154    Parameters: ~
4155      • {win}   (`integer`) |window-ID|, or 0 for current window
4156      • {name}  (`string`) Variable name
4157
4158nvim_win_get_buf({win})                                   *nvim_win_get_buf()*
4159    Gets the current buffer in a window
4160
4161    Attributes: ~
4162        Since: 0.1.0
4163
4164    Parameters: ~
4165      • {win}  (`integer`) |window-ID|, or 0 for current window
4166
4167    Return: ~
4168        (`integer`) Buffer id
4169
4170nvim_win_get_cursor({win})                             *nvim_win_get_cursor()*
4171    Gets the (1,0)-indexed, buffer-relative cursor position for a given window
4172    (different windows showing the same buffer have independent cursor
4173    positions). |api-indexing|
4174
4175    Attributes: ~
4176        Since: 0.1.0
4177
4178    Parameters: ~
4179      • {win}  (`integer`) |window-ID|, or 0 for current window
4180
4181    Return: ~
4182        (`[integer, integer]`) (row, col) tuple
4183
4184    See also: ~
4185      • |getcurpos()|
4186
4187nvim_win_get_height({win})                             *nvim_win_get_height()*
4188    Gets the window height
4189
4190    Attributes: ~
4191        Since: 0.1.0
4192
4193    Parameters: ~
4194      • {win}  (`integer`) |window-ID|, or 0 for current window
4195
4196    Return: ~
4197        (`integer`) Height as a count of rows
4198
4199nvim_win_get_number({win})                             *nvim_win_get_number()*
4200    Gets the window number
4201
4202    Attributes: ~
4203        Since: 0.1.0
4204
4205    Parameters: ~
4206      • {win}  (`integer`) |window-ID|, or 0 for current window
4207
4208    Return: ~
4209        (`integer`) Window number
4210
4211nvim_win_get_position({win})                         *nvim_win_get_position()*
4212    Gets the window position in display cells. First position is zero.
4213
4214    Attributes: ~
4215        Since: 0.1.0
4216
4217    Parameters: ~
4218      • {win}  (`integer`) |window-ID|, or 0 for current window
4219
4220    Return: ~
4221        (`[integer, integer]`) (row, col) tuple with the window position
4222
4223nvim_win_get_tabpage({win})                           *nvim_win_get_tabpage()*
4224    Gets the window tabpage
4225
4226    Attributes: ~
4227        Since: 0.1.0
4228
4229    Parameters: ~
4230      • {win}  (`integer`) |window-ID|, or 0 for current window
4231
4232    Return: ~
4233        (`integer`) Tabpage that contains the window
4234
4235nvim_win_get_var({win}, {name})                           *nvim_win_get_var()*
4236    Gets a window-scoped (w:) variable
4237
4238    Attributes: ~
4239        Since: 0.1.0
4240
4241    Parameters: ~
4242      • {win}   (`integer`) |window-ID|, or 0 for current window
4243      • {name}  (`string`) Variable name
4244
4245    Return: ~
4246        (`any`) Variable value
4247
4248nvim_win_get_width({win})                               *nvim_win_get_width()*
4249    Gets the window width
4250
4251    Attributes: ~
4252        Since: 0.1.0
4253
4254    Parameters: ~
4255      • {win}  (`integer`) |window-ID|, or 0 for current window
4256
4257    Return: ~
4258        (`integer`) Width as a count of columns
4259
4260nvim_win_hide({win})                                         *nvim_win_hide()*
4261    Closes the window and hides the buffer it contains (like |:hide| with a
4262    |window-ID|; unrelated to the `hide` flag of |nvim_open_win()|,
4263    |nvim_win_get_config()|).
4264
4265    Compare |:close| and |nvim_win_close()|, which close the buffer instead of
4266    hiding it.
4267
4268    Attributes: ~
4269        not allowed when |textlock| is active
4270        Since: 0.5.0
4271
4272    Parameters: ~
4273      • {win}  (`integer`) |window-ID|, or 0 for current window
4274
4275nvim_win_is_valid({win})                                 *nvim_win_is_valid()*
4276    Checks if a window is valid
4277
4278    Attributes: ~
4279        Since: 0.1.0
4280
4281    Parameters: ~
4282      • {win}  (`integer`) |window-ID|, or 0 for current window
4283
4284    Return: ~
4285        (`boolean`) true if the window is valid, false otherwise
4286
4287nvim_win_resize({win}, {width}, {height}, {opts})          *nvim_win_resize()*
4288    Resizes a window, anchored to a given edge.
4289
4290    The window first takes space from the non-anchored side, and only then
4291    from the anchored side. The "anchor" decides the fixed edge, so a window
4292    can grow or shrink in any direction.
4293
4294    Can set height, width (only for a vertical split), or both. The "anchor"
4295    applies to the matching axis (top/bottom for height, left/right for
4296    width); the other axis uses its default anchor.
4297
4298    Attributes: ~
4299        Since: 0.13.0
4300
4301    Parameters: ~
4302      • {win}     (`integer`) |window-ID|, or 0 for current window
4303      • {width}   (`integer`) New width (columns), or -1 for "no change".
4304      • {height}  (`integer`) New height (rows), or -1 for "no change".
4305      • {opts}    (`vim.api.keyset.win_resize?`) Optional parameters.
4306                  • anchor: Edge that stays fixed while the opposite edge
4307                    moves; the neighbor on the moving side is resized first.
4308                    One of:
4309                    • "top" (default) or "bottom"
4310                    • "left" (default) or "right"
4311
4312nvim_win_set_buf({win}, {buf})                            *nvim_win_set_buf()*
4313    Sets the current buffer in a window.
4314
4315    Note: As a side-effect, this executes |BufEnter| and |BufLeave|
4316    autocommands.
4317
4318    Attributes: ~
4319        not allowed when |textlock| is active
4320        Since: 0.3.2
4321
4322    Parameters: ~
4323      • {win}  (`integer`) |window-ID|, or 0 for current window
4324      • {buf}  (`integer`) Buffer id
4325
4326nvim_win_set_cursor({win}, {pos})                      *nvim_win_set_cursor()*
4327    Sets the (1,0)-indexed cursor position (byte offset) in the window.
4328    |api-indexing| This scrolls the window even if it is not the current one.
4329
4330    Attributes: ~
4331        Since: 0.1.0
4332
4333    Parameters: ~
4334      • {win}  (`integer`) |window-ID|, or 0 for current window
4335      • {pos}  (`[integer, integer]`) (row, col) tuple representing the new
4336               position
4337
4338nvim_win_set_hl_ns({win}, {ns_id})                      *nvim_win_set_hl_ns()*
4339    Set highlight namespace for a window. This will use highlights defined
4340    with |nvim_set_hl()| for this namespace, but fall back to global
4341    highlights (ns=0) when missing.
4342
4343    This takes precedence over the 'winhighlight' option.
4344
4345    Attributes: ~
4346        Since: 0.8.0
4347
4348    Parameters: ~
4349      • {win}    (`integer`)
4350      • {ns_id}  (`integer`) the namespace to use
4351
4352nvim_win_set_var({win}, {name}, {value})                  *nvim_win_set_var()*
4353    Sets a window-scoped (w:) variable
4354
4355    Attributes: ~
4356        Since: 0.1.0
4357
4358    Parameters: ~
4359      • {win}    (`integer`) |window-ID|, or 0 for current window
4360      • {name}   (`string`) Variable name
4361      • {value}  (`any`) Variable value
4362
4363nvim_win_text_height({win}, {opts})                   *nvim_win_text_height()*
4364    Computes the number of screen lines occupied by a range of text in a given
4365    window. Works for off-screen text and takes folds into account.
4366
4367    Diff filler or virtual lines above a line are counted as a part of that
4368    line, unless the line is on "start_row" and "start_vcol" is specified.
4369
4370    Diff filler or virtual lines below the last buffer line are counted in the
4371    result when "end_row" is omitted.
4372
4373    Line indexing is similar to |nvim_buf_get_text()|.
4374
4375    Attributes: ~
4376        Since: 0.10.0
4377
4378    Parameters: ~
4379      • {win}   (`integer`) |window-ID|, or 0 for current window.
4380      • {opts}  (`vim.api.keyset.win_text_height?`) Optional parameters:
4381                • end_row: Ending line index, 0-based inclusive. When omitted
4382                  end at the very bottom.
4383                • end_vcol: Ending virtual column index on "end_row", 0-based
4384                  exclusive, rounded up to full screen lines. When 0 only
4385                  include diff filler and virtual lines above "end_row". When
4386                  omitted include the whole line.
4387                • max_height: Don't add the height of lines below the row for
4388                  which this height is reached. Useful to e.g. limit the
4389                  height to the window height, avoiding unnecessary work. Or
4390                  to find out how many buffer lines beyond "start_row" take up
4391                  a certain number of logical lines (returned in "end_row" and
4392                  "end_vcol").
4393                • start_row: Starting line index, 0-based inclusive. When
4394                  omitted start at the very top.
4395                • start_vcol: Starting virtual column index on "start_row",
4396                  0-based inclusive, rounded down to full screen lines. When
4397                  omitted include the whole line.
4398
4399    Return: ~
4400        (`vim.api.keyset.win_text_height_ret`) Dict containing text height
4401        information, with these keys:
4402        • all: The total number of screen lines occupied by the range.
4403        • fill: The number of diff filler or virtual lines among them.
4404        • end_row: The row on which the returned height is reached (first row
4405          of a closed fold).
4406        • end_vcol: Ending virtual column in "end_row" where "max_height" or
4407          the returned height is reached. 0 if "end_row" is a closed fold.
4408
4409    See also: ~
4410      • |virtcol()| for text width.
4411
4412
4413 vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: