robin/laufey

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

robinmerge: 1dc9728daa1d8a2702

master
113.5 KiB2640 linesraw
1--- @meta _
2--
3-- DO NOT EDIT. GENERATED BY: src/gen/gen_eval_files.lua
4--
5error('Cannot require a meta file')
6
7--- This file embeds vimdoc as the function descriptions
8--- so ignore any doc related errors.
9--- @diagnostic disable: undefined-doc-name,luadoc-miss-symbol
10
11vim.api = {}
12
13--- WARNING: This feature is experimental/unstable.
14---
15--- @param buf integer
16--- @param keys boolean
17--- @param dot boolean
18--- @return string
19function vim.api.nvim__buf_debug_extmarks(buf, keys, dot) end
20
21--- WARNING: This feature is experimental/unstable.
22---
23--- @param buf integer
24--- @return table<string,any>
25function vim.api.nvim__buf_stats(buf) end
26
27--- WARNING: This feature is experimental/unstable.
28---
29--- Records the cmdwin scratchbuf and type, or clears both when type="" / buf=0. Internal use only.
30---
31--- @param type string ':', '/', '?' (first char only); empty to clear.
32--- @param buf integer cmdwin buffer id, or 0 to clear.
33function vim.api.nvim__cmdwin_set(type, buf) end
34
35--- WARNING: This feature is experimental/unstable.
36---
37--- Sets info for the completion item at the given index. If the info text was shown in a window,
38--- returns the window and buffer ids, or empty dict if not shown.
39---
40--- @param index integer Completion candidate index
41--- @param opts vim.api.keyset.complete_set? Optional parameters.
42--- - info: (string) info text.
43--- @return table<string,integer> # Dict containing these keys:
44--- - winid: (integer) floating window id
45--- - bufnr: (integer) buffer id in floating window
46function vim.api.nvim__complete_set(index, opts) end
47
48--- WARNING: This feature is experimental/unstable.
49---
50--- @return string
51function vim.api.nvim__get_lib_dir() end
52
53--- WARNING: This feature is experimental/unstable.
54---
55--- Find files in runtime directories
56---
57--- @param pat string[] pattern of files to search for
58--- @param all boolean whether to return all matches or only the first
59--- @param opts vim.api.keyset.runtime? is_lua: only search Lua subdirs
60--- @return string[] # list of absolute paths to the found files
61function vim.api.nvim__get_runtime(pat, all, opts) end
62
63--- WARNING: This feature is experimental/unstable.
64---
65--- Returns object given as argument.
66---
67--- This API function is used for testing. One should not rely on its presence
68--- in plugins.
69---
70--- @param obj any Object to return.
71--- @return any # its argument.
72function vim.api.nvim__id(obj) end
73
74--- WARNING: This feature is experimental/unstable.
75---
76--- Returns array given as argument.
77---
78--- This API function is used for testing. One should not rely on its presence
79--- in plugins.
80---
81--- @param arr any[] Array to return.
82--- @return any[] # its argument.
83function vim.api.nvim__id_array(arr) end
84
85--- WARNING: This feature is experimental/unstable.
86---
87--- Returns dict given as argument.
88---
89--- This API function is used for testing. One should not rely on its presence
90--- in plugins.
91---
92--- @param dct table<string,any> Dict to return.
93--- @return table<string,any> # its argument.
94function vim.api.nvim__id_dict(dct) end
95
96--- WARNING: This feature is experimental/unstable.
97---
98--- Returns floating-point value given as argument.
99---
100--- This API function is used for testing. One should not rely on its presence
101--- in plugins.
102---
103--- @param flt number Value to return.
104--- @return number # its argument.
105function vim.api.nvim__id_float(flt) end
106
107--- WARNING: This feature is experimental/unstable.
108---
109--- NB: if your UI doesn't use hlstate, this will not return hlstate first time.
110--- @param grid integer
111--- @param row integer
112--- @param col integer
113--- @return any[]
114function vim.api.nvim__inspect_cell(grid, row, col) end
115
116--- WARNING: This feature is experimental/unstable.
117---
118--- For testing. The condition in schar_cache_clear_if_full is hard to
119--- reach, so this function can be used to force a cache clear in a test.
120function vim.api.nvim__invalidate_glyph_cache() end
121
122--- WARNING: This feature is experimental/unstable.
123---
124--- Returns true if a multicursor cascade is in-progress.
125--- @return boolean
126function vim.api.nvim__mcursor_cascading() end
127
128--- WARNING: This feature is experimental/unstable.
129---
130--- Get the properties for namespace
131---
132--- @param ns_id integer Namespace
133--- @return vim.api.keyset.ns_opts # Map defining the namespace properties, see |nvim__ns_set()|
134function vim.api.nvim__ns_get(ns_id) end
135
136--- WARNING: This feature is experimental/unstable.
137---
138--- Set some properties for namespace
139---
140--- @param ns_id integer Namespace
141--- @param opts vim.api.keyset.ns_opts? Optional parameters to set:
142--- - wins: a list of windows to be scoped in
143function vim.api.nvim__ns_set(ns_id, opts) end
144
145--- WARNING: This feature is experimental/unstable.
146---
147--- Instruct Nvim to redraw various components.
148---
149---
150--- @see `:help :redraw`
151--- @param opts vim.api.keyset.redraw? Optional parameters.
152--- - buf: Target a specific buffer number as described below.
153--- - cursor: Immediately update cursor position on the screen in
154---   `win` or the current window.
155--- - flush: Update the screen with pending updates.
156--- - range: Redraw a range in `buf`, the buffer in `win` or the
157---   current buffer (useful for decoration providers). Expects a
158---   tuple `[first, last]` with the first and last line number
159---   of the range, 0-based end-exclusive `api-indexing`.
160--- - statuscolumn: Redraw the 'statuscolumn' in `buf`, `win` or
161---   all windows.
162--- - statusline: Redraw the 'statusline' in `buf`, `win` or all
163---   windows.
164--- - tabline: Redraw the 'tabline'.
165--- - valid: When present mark `win`, `buf`, or all windows for
166---   redraw. When `true`, only redraw changed lines (useful for
167---   decoration providers). When `false`, forcefully redraw.
168--- - win: Target a specific `window-ID` as described below.
169--- - winbar: Redraw the 'winbar' in `buf`, `win` or all windows.
170function vim.api.nvim__redraw(opts) end
171
172--- WARNING: This feature is experimental/unstable.
173---
174--- @return any[]
175function vim.api.nvim__runtime_inspect() end
176
177--- WARNING: This feature is experimental/unstable.
178---
179--- @param path string
180function vim.api.nvim__screenshot(path) end
181
182--- WARNING: This feature is experimental/unstable.
183---
184--- @param progpath string
185--- @param argv any[]
186function vim.api.nvim__set_restart_on_crash(progpath, argv) end
187
188--- WARNING: This feature is experimental/unstable.
189---
190--- Gets internal stats.
191---
192--- @return table<string,any> # Map of various internal stats.
193function vim.api.nvim__stats() end
194
195--- WARNING: This feature is experimental/unstable.
196---
197--- @param str string
198--- @return any
199function vim.api.nvim__unpack(str) end
200
201--- @deprecated
202--- @param buffer integer
203--- @param ns_id integer
204--- @param hl_group string
205--- @param line integer
206--- @param col_start integer
207--- @param col_end integer
208--- @return integer
209function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) end
210
211--- Activates `api-buffer-updates` events on a channel, or as Lua callbacks.
212---
213--- Example (Lua): capture buffer updates in a global `events` variable
214--- (use "vim.print(events)" to see its contents):
215---
216--- ```lua
217--- events = {}
218--- vim.api.nvim_buf_attach(0, false, {
219---   on_lines = function(...)
220---     table.insert(events, {...})
221---   end,
222--- })
223--- ```
224---
225---
226--- @see vim.api.nvim_buf_detach
227--- @see `:help api-buffer-updates-lua`
228--- @param buf integer Buffer id, or 0 for current buffer
229--- @param send_buffer boolean True if the initial notification should contain the
230--- whole buffer: first notification will be `nvim_buf_lines_event`.
231--- Else the first notification will be `nvim_buf_changedtick_event`.
232--- Not for Lua callbacks.
233--- @param opts vim.api.keyset.buf_attach? Optional parameters.
234--- - on_bytes: Called on granular changes (compared to on_lines). Not called on buffer
235---   reload (`:checktime`, `:edit`, …), see `on_reload`. Returning [lua-truthy] deletes
236---   the callback. Args:
237---   - the string "bytes"
238---   - buffer id
239---   - b:changedtick
240---   - start row of the changed text (zero-indexed)
241---   - start column of the changed text
242---   - byte offset of the changed text (from the start of
243---       the buffer)
244---   - old end row of the changed text (offset from start row)
245---   - old end column of the changed text
246---     (if old end row = 0, offset from start column)
247---   - old end byte length of the changed text
248---   - new end row of the changed text (offset from start row)
249---   - new end column of the changed text
250---     (if new end row = 0, offset from start column)
251---   - new end byte length of the changed text
252--- - on_changedtick: Called on [changetick] increment without text change. Args:
253---   - the string "changedtick"
254---   - buffer id
255---   - b:changedtick
256--- - on_detach: Called on detach, or when the buffer is unloaded or deleted. Not called
257---   when a callback returns [lua-truthy] to delete itself. Args:
258---   - the string "detach"
259---   - buffer id
260--- - on_lines: Called on linewise changes. Not called on buffer reload (`:checktime`,
261---   `:edit`, …), see `on_reload`. Returning [lua-truthy] deletes the callback. Args:
262---   - the string "lines"
263---   - buffer id
264---   - b:changedtick
265---   - first line that changed (zero-indexed)
266---   - last line that was changed
267---   - last line in the updated range
268---   - byte count of previous contents
269---   - deleted_codepoints (if `utf_sizes` is true)
270---   - deleted_codeunits (if `utf_sizes` is true)
271--- - on_reload: Called on whole-buffer load (`:checktime`, `:edit`, …). Clients should
272---   typically re-fetch the entire buffer contents. Args:
273---   - the string "reload"
274---   - buffer id
275--- - preview: also attach to command preview (i.e. 'inccommand')
276---   events.
277--- - utf_sizes: include UTF-32 and UTF-16 size of the replaced
278---   region, as args to `on_lines`.
279--- @return boolean # False if attach failed (invalid parameter, or buffer isn't loaded);
280--- otherwise True.
281function vim.api.nvim_buf_attach(buf, send_buffer, opts) end
282
283--- Calls function `fn` in the context of buffer `buf` and returns its result (may be multiple
284--- values).
285---
286--- This temporarily switches current buffer to `buf`.
287--- If the current window already shows `buf`, the window is not switched.
288--- If a window inside the current tabpage (including a float) already shows the
289--- buffer, then one of those windows will be set as current window temporarily.
290--- Otherwise a temporary scratch window (called the "autocmd window" for
291--- historical reasons) will be used.
292---
293--- This is useful e.g. to call Vimscript functions that only work with the
294--- current buffer/window currently, like `jobstart(…, {'term': v:true})`.
295---
296--- @param buf integer Buffer id, or 0 for current buffer.
297--- @param fn function Lua function to call inside the buffer.
298--- @return any # Value(s) returned by `fn()`.
299function vim.api.nvim_buf_call(buf, fn) end
300
301--- @deprecated
302--- @param buffer integer
303--- @param ns_id integer
304--- @param line_start integer
305--- @param line_end integer
306function vim.api.nvim_buf_clear_highlight(buffer, ns_id, line_start, line_end) end
307
308--- Clears `namespace`d objects (highlights, `extmarks`, virtual text) from
309--- a region.
310---
311--- Lines are 0-indexed. `api-indexing`  To clear the namespace in the entire
312--- buffer, specify line_start=0 and line_end=-1.
313---
314--- @param buf integer Buffer id, or 0 for current buffer
315--- @param ns_id integer Namespace to clear, or -1 to clear all namespaces.
316--- @param line_start integer Start of range of lines to clear
317--- @param line_end integer End of range of lines to clear (exclusive) or -1 to clear
318--- to end of buffer.
319function vim.api.nvim_buf_clear_namespace(buf, ns_id, line_start, line_end) end
320
321--- Creates a buffer-local command `user-commands`.
322---
323--- @see vim.api.nvim_create_user_command
324--- @param buf integer Buffer id, or 0 for current buffer.
325--- @param name string
326--- @param cmd any
327--- @param opts vim.api.keyset.user_command?
328function vim.api.nvim_buf_create_user_command(buf, name, cmd, opts) end
329
330--- Removes an `extmark`.
331---
332--- @param buf integer Buffer id, or 0 for current buffer
333--- @param ns_id integer `namespace` id
334--- @param id integer Extmark id
335--- @return boolean # true if the extmark was found, else false
336function vim.api.nvim_buf_del_extmark(buf, ns_id, id) end
337
338--- Unmaps a buffer-local `mapping` for the given mode.
339---
340---
341--- @see vim.api.nvim_del_keymap
342--- @param buf integer Buffer id, or 0 for current buffer
343--- @param mode string Mode short-name ("n", "i", "v", ...)
344--- @param lhs string Left-hand-side `{lhs}` of the mapping.
345--- @param opts vim.api.keyset.keymap_del? Optional parameters.
346--- - lhs: When true, only match {lhs}, not {rhs}.
347function vim.api.nvim_buf_del_keymap(buf, mode, lhs, opts) end
348
349--- Deletes a named mark in the buffer. See `mark-motions`.
350---
351--- Note:
352--- only deletes marks set in the buffer, if the mark is not set
353--- in the buffer it will return false.
354---
355--- @see vim.api.nvim_buf_set_mark
356--- @see vim.api.nvim_del_mark
357--- @param buf integer Buffer to set the mark on
358--- @param name string Mark name
359--- @return boolean # true if the mark was deleted, else false.
360function vim.api.nvim_buf_del_mark(buf, name) end
361
362--- Delete a buffer-local user-defined command.
363---
364--- Only commands created with `:command-buffer` or
365--- `nvim_buf_create_user_command()` can be deleted with this function.
366---
367--- @param buf integer Buffer id, or 0 for current buffer.
368--- @param name string Name of the command to delete.
369function vim.api.nvim_buf_del_user_command(buf, name) end
370
371--- Removes a buffer-scoped (b:) variable
372---
373--- @param buf integer Buffer id, or 0 for current buffer
374--- @param name string Variable name
375function vim.api.nvim_buf_del_var(buf, name) end
376
377--- Deletes a buffer and its metadata (like `:bwipeout`).
378---
379--- To get `:bdelete` behavior, reset 'buflisted' and pass `unload=true`:
380--- ```lua
381--- vim.bo.buflisted = false
382--- vim.api.nvim_buf_delete(0, { unload = true })
383--- ```
384---
385--- @param buf integer Buffer id, or 0 for current buffer
386--- @param opts vim.api.keyset.buf_delete? Optional parameters. Keys:
387--- - force:  Force deletion, ignore unsaved changes.
388--- - unload: Unloaded only (`:bunload`), do not delete.
389function vim.api.nvim_buf_delete(buf, opts) end
390
391--- Gets a changed tick of a buffer
392---
393--- @param buf integer Buffer id, or 0 for current buffer
394--- @return integer # `b:changedtick` value.
395function vim.api.nvim_buf_get_changedtick(buf) end
396
397--- Gets a map of buffer-local `user-commands`.
398---
399--- @param buf integer Buffer id, or 0 for current buffer
400--- @param opts vim.api.keyset.get_commands? Optional parameters. Currently not used.
401--- @return vim.api.keyset.command_info # Map of maps describing commands.
402function vim.api.nvim_buf_get_commands(buf, opts) end
403
404--- Gets the position (0-indexed) of an `extmark`.
405---
406--- @param buf integer Buffer id, or 0 for current buffer
407--- @param ns_id integer `namespace` id
408--- @param id integer Extmark id
409--- @param opts vim.api.keyset.get_extmark? Optional parameters. Keys:
410--- - details: Whether to include the details dict
411--- - hl_name: Whether to include highlight group name instead of id, true if omitted
412--- @return [integer, integer, vim.api.keyset.extmark_details?] # 0-indexed (row, col, details?) tuple or empty list () if extmark id was absent.  The
413--- optional `details` dictionary contains the same keys as `opts` in |nvim_buf_set_extmark()|,
414--- except for `id`, `conceal_lines` and `ephemeral`. It also contains the following keys:
415---
416--- - ns_id: |namespace| id
417--- - invalid: boolean that indicates whether the mark is hidden because the entirety of
418--- text span range is deleted. See also the key `invalidate` in |nvim_buf_set_extmark()|.
419function vim.api.nvim_buf_get_extmark_by_id(buf, ns_id, id, opts) end
420
421--- Gets `extmarks` in "traversal order" from a `charwise` region defined by buffer positions
422--- (inclusive, 0-indexed `api-indexing`).
423---
424--- Region can be given as (row,col) tuples, or valid extmark ids (whose
425--- positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
426--- respectively, thus the following are equivalent:
427---
428--- ```lua
429--- vim.api.nvim_buf_get_extmarks(0, my_ns, 0, -1)
430--- vim.api.nvim_buf_get_extmarks(0, my_ns, {0,0}, {-1,-1})
431--- ```
432---
433--- If `end` is less than `start`, marks are returned in reverse order.
434--- (Useful with `limit`, to get the first marks prior to a given position.)
435---
436--- Note:
437--- - For a reverse range, `limit` does not actually affect the traversed range, just how many marks
438---   are returned
439--- - When using extmark ranges (marks with a end_row/end_col position) the `overlap` option might
440---   be useful. Otherwise only the start position of an extmark will be considered.
441--- - The `:marks` command can list extmarks.
442--- - Legacy signs placed through the `:sign` commands are implemented as extmarks. Their details
443---   array will contain a `sign_name` field.
444---
445--- Example:
446---
447--- ```lua
448--- local api = vim.api
449--- local pos = api.nvim_win_get_cursor(0)
450--- local ns  = api.nvim_create_namespace('my-plugin')
451--- -- Create new extmark at line 1, column 1.
452--- local m1  = api.nvim_buf_set_extmark(0, ns, 0, 0)
453--- -- Create new extmark at line 3, column 1.
454--- local m2  = api.nvim_buf_set_extmark(0, ns, 2, 0)
455--- -- Get extmarks only from line 3.
456--- local ms  = api.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0})
457--- -- Get all marks in this buffer + namespace.
458--- local all = api.nvim_buf_get_extmarks(0, ns, 0, -1)
459--- vim.print(ms)
460--- ```
461---
462--- @param buf integer Buffer id, or 0 for current buffer
463--- @param ns_id integer `namespace` id, or -1 for all namespaces
464--- @param start any Start of range: a 0-indexed (row, col) or valid extmark id
465--- (whose position defines the bound). `api-indexing`
466--- @param end_ any End of range (inclusive): a 0-indexed (row, col) or valid
467--- extmark id (whose position defines the bound). `api-indexing`
468--- @param opts vim.api.keyset.get_extmarks? Optional parameters. Keys:
469--- - details: Whether to include the details dict
470--- - hl_name: Whether to include highlight group name instead of id, true if omitted
471--- - limit:  Maximum number of marks to return
472--- - overlap: Also include marks which overlap the range, even if
473---            their start position is less than `start`
474--- - type: Filter marks by type: "highlight", "sign", "virt_text" and "virt_lines"
475--- @return vim.api.keyset.get_extmark_item[] # List of `[extmark_id, row, col, details?]` tuples in "traversal order". For the
476--- `details` dictionary, see |nvim_buf_get_extmark_by_id()|.
477function vim.api.nvim_buf_get_extmarks(buf, ns_id, start, end_, opts) end
478
479--- Gets a list of buffer-local `mapping` definitions.
480---
481--- @param buf integer Buffer id, or 0 for current buffer
482--- @param mode string Mode short-name ("n", "i", "v", ...)
483--- @return vim.api.keyset.get_keymap[] # Array of |maparg()|-like dictionaries describing mappings.
484--- The "buf" key holds the associated buffer id.
485function vim.api.nvim_buf_get_keymap(buf, mode) end
486
487--- Gets a line-range from the buffer.
488---
489--- Indexing is zero-based, end-exclusive. Negative indices are interpreted
490--- as length+1+index: -1 refers to the index past the end. So to get the
491--- last element use start=-2 and end=-1.
492---
493--- Out-of-bounds indices are clamped to the nearest valid value, unless
494--- `strict_indexing` is set.
495---
496---
497--- @see vim.api.nvim_buf_get_text
498--- @param buf integer Buffer id, or 0 for current buffer
499--- @param start integer First line index
500--- @param end_ integer Last line index, exclusive
501--- @param strict_indexing boolean Whether out-of-bounds should be an error.
502--- @return string[] # Array of lines, or empty array for unloaded buffer.
503function vim.api.nvim_buf_get_lines(buf, start, end_, strict_indexing) end
504
505--- Returns a `(row,col)` tuple representing the position of the named mark.
506--- "End of line" column position is returned as `v:maxcol` (big number).
507--- See `mark-motions`.
508---
509--- Marks are (1,0)-indexed. `api-indexing`
510---
511--- @see vim.api.nvim_buf_set_mark
512--- @see vim.api.nvim_buf_del_mark
513--- @param buf integer Buffer id, or 0 for current buffer
514--- @param name string Mark name
515--- @return [integer, integer] # (row, col) tuple, (0, 0) if the mark is not set, or is an
516--- uppercase/file mark set in another buffer.
517function vim.api.nvim_buf_get_mark(buf, name) end
518
519--- Gets the full/absolute filepath of the buffer, or the buffer name for non-file buffers.
520---
521--- If the buffer represents a directory, the name ends with a path separator,
522--- unless it was changed by `:file` or `nvim_buf_set_name()`.
523---
524--- @param buf integer Buffer id, or 0 for current buffer
525--- @return string # Buffer name
526function vim.api.nvim_buf_get_name(buf) end
527
528--- @deprecated
529--- @param buffer integer
530--- @return integer
531function vim.api.nvim_buf_get_number(buffer) end
532
533--- Returns the byte offset of a line (0-indexed). `api-indexing`
534---
535--- Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte.
536--- 'fileformat' and 'fileencoding' are ignored. The line index just after the
537--- last line gives the total byte-count of the buffer. A final EOL byte is
538--- counted if it would be written, see 'eol'.
539---
540--- Unlike `line2byte()`, throws error for out-of-bounds indexing.
541--- Returns -1 for unloaded buffer.
542---
543--- @param buf integer Buffer id, or 0 for current buffer
544--- @param index integer Line index
545--- @return integer # Integer byte offset, or -1 for unloaded buffer.
546function vim.api.nvim_buf_get_offset(buf, index) end
547
548--- @deprecated
549--- @param buffer integer
550--- @param name string
551--- @return any
552function vim.api.nvim_buf_get_option(buffer, name) end
553
554--- Gets a range from the buffer (may be partial lines, unlike `nvim_buf_get_lines()`).
555---
556--- Indexing is zero-based. Row indices are end-inclusive, and column indices
557--- are end-exclusive.
558---
559--- Prefer `nvim_buf_get_lines()` when retrieving entire lines.
560---
561--- @param buf integer Buffer id, or 0 for current buffer
562--- @param start_row integer First line index
563--- @param start_col integer Starting column (byte offset) on first line
564--- @param end_row integer Last line index, inclusive
565--- @param end_col integer Ending column (byte offset) on last line, exclusive
566--- @param opts vim.api.keyset.empty? Optional parameters. Currently unused.
567--- @return string[] # Array of lines, or empty array for unloaded buffer.
568function vim.api.nvim_buf_get_text(buf, start_row, start_col, end_row, end_col, opts) end
569
570--- Gets a buffer-scoped (b:) variable.
571---
572--- @param buf integer Buffer id, or 0 for current buffer
573--- @param name string Variable name
574--- @return any # Variable value
575function vim.api.nvim_buf_get_var(buf, name) end
576
577--- Checks if a buffer is valid and loaded. See `api-buffer` for more info
578--- about unloaded buffers.
579---
580--- @param buf integer Buffer id, or 0 for current buffer
581--- @return boolean # true if the buffer is valid and loaded, false otherwise.
582function vim.api.nvim_buf_is_loaded(buf) end
583
584--- Checks if a buffer is valid.
585---
586--- Note:
587--- Even if a buffer is valid it may have been unloaded. See |api-buffer|
588--- for more info about unloaded buffers.
589---
590---
591--- @param buf integer Buffer id, or 0 for current buffer
592--- @return boolean # true if the buffer is valid, false otherwise.
593function vim.api.nvim_buf_is_valid(buf) end
594
595--- Returns the number of lines in the given buffer.
596---
597--- @param buf integer Buffer id, or 0 for current buffer
598--- @return integer # Line count, or 0 for unloaded buffer. |api-buffer|
599function vim.api.nvim_buf_line_count(buf) end
600
601--- Creates or updates an `extmark`.
602---
603--- By default a new extmark is created when no id is passed in, but it is also
604--- possible to create a new mark by passing in a previously unused id or move
605--- an existing mark by passing in its id. The caller must then keep track of
606--- existing and unused ids itself. (Useful over RPC, to avoid waiting for the
607--- return value.)
608---
609--- Using the optional arguments, it is possible to use this to highlight
610--- a range of text, and also to associate virtual text to the mark.
611---
612--- If present, the position defined by `end_col` and `end_row` should be after
613--- the start position in order for the extmark to cover a range.
614--- An earlier end position is not an error, but then it behaves like an empty
615--- range (no highlighting).
616---
617--- @param buf integer Buffer id, or 0 for current buffer
618--- @param ns_id integer `namespace` id
619--- @param line integer Line where to place the mark, 0-based. `api-indexing`
620--- @param col integer Column where to place the mark, 0-based. `api-indexing`
621--- @param opts vim.api.keyset.set_extmark? Optional parameters:
622--- - conceal: (boolean|string)
623---     - string: Single char or empty string, enables conceal similar to `:syn-conceal`.
624---       Non-empty char is used as `:syn-cchar`. Highlighted with "hl_group" if
625---       defined, else defaults to `hl-Conceal`.
626---     - boolean: true is equivalent to "", false removes any existing conceal.
627--- - conceal_lines: (string) Line-level conceal. When set to an empty string (other
628---   values reserved for future use), the lines in the extmark range are not drawn;
629---   the next non-concealed line is drawn in their place. Requires 'conceallevel' >=
630---   2; subject to 'concealcursor' on the cursor line.
631--- - cursorline_hl_group: Highlight group used for the 'signcolumn' text when the
632---   cursor is on the same line as the mark and 'cursorline' is enabled.
633--- - end_col: End-column of the mark, 0-based exclusive, or -1 to extend the range to
634---   end of line (if strict=false).
635--- - end_right_gravity: (boolean, default: false) Indicates which direction the extmark
636---   end-position (if any) will be shifted when new text is inserted (true=right, false=left).
637--- - end_row: End-line of the mark, 0-based inclusive.
638--- - ephemeral: For use with `nvim_set_decoration_provider()` callbacks. The mark
639---   will only be used for the current redraw cycle, and not stored in the buffer.
640--- - hl_eol: When true, for a multiline highlight covering the EOL of a line,
641---   continue the highlight for the rest of the screen line (just like for diff and
642---   cursorline highlight).
643--- - hl_group: Highlight group for the text range. This and below highlight groups
644---   can be given as a string or as an integer (`nvim_get_hl_id_by_name()`). Multiple
645---   highlight groups can be stacked by passing an array (highest-priority last).
646--- - hl_mode: Controls how highlights are combined with the highlights of the text.
647---   Only affects virt_text highlights, but might affect `hl_group` in the future.
648---   - "replace": Only show the virt_text color. This is the default.
649---   - "combine": Combine with background text color.
650---   - "blend": Blend with background text color. Not supported for "inline" virt_text.
651--- - id: Update this extmark instead of creating a new one.
652--- - invalidate: (boolean) Indicates whether to hide the extmark if the entirety of
653---   its range is deleted. For hidden marks, an "invalid" key is added to the
654---   "details" array of `nvim_buf_get_extmarks()` and family. If "undo_restore" is
655---   false, the extmark is deleted instead.
656--- - line_hl_group: Highlight group used for the whole line.
657--- - number_hl_group: Highlight group used for the number column.
658--- - priority: Priority of the highlight group, sign attribute or virtual text. For
659---   virtual text, the highest-priority item is drawn last. For example treesitter
660---   highlighting uses a value of 100.
661--- - right_gravity: (boolean, default: true) Indicates which direction the extmark
662---   will be shifted when new text is inserted (true=right, false=left).
663--- - sign_hl_group: Highlight group for `sign_text`.
664--- - sign_text: (string, length 1-2) Displayed in 'signcolumn'.
665--- - spell: (boolean) Indicates that spell checking should be performed within this
666---   extmark.
667--- - strict: (boolean, default: true) Indicates extmark should not be placed if the
668---   line or column value is past end-of-buffer or end-of-line respectively.
669--- - ui_watched: (boolean) Indicates the mark should be drawn by a UI; activates
670---   `win_extmark` [ui-multigrid] events. Note: the mark is positioned by virt_text
671---   attributes. Can be used with virt_text.
672--- - undo_restore: (default: true) Restore the exact position of the mark if text
673---   around the mark was deleted and then restored by undo.
674--- - url: URL stored on this extmark. In the TUI, the OSC 8 control
675---     sequence is used to generate a clickable hyperlink to this URL.
676--- - virt_lines: List of virtual lines to place next to the mark, where each line is
677---   a list of `[text_chunk, hl]` tuples. Buffer and window options do not affect the
678---   display of the text, except 'tabstop' is used for hard tabs. The 'wrap' and
679---   'linebreak' options do not take effect, so the number of extra screen lines will
680---   match the list-size (but see `virt_lines_overflow`). By default lines are placed
681---   below the marked line. Special case: If the last `text_chunk` is empty,
682---   the corresponding `hl` will extend to the end of the line.
683--- - virt_lines_above: Place virtual lines above instead.
684--- - virt_lines_leftcol: Place virtual lines in the leftmost column of the window,
685---   bypassing sign and number columns.
686--- - virt_lines_overflow: Controls display of virtual lines exceeding the viewport:
687---   - "auto": Decided by the 'wrap' option.
688---   - "scroll": Scroll horizontally with 'nowrap', otherwise the same as "trunc".
689---   - "trunc": Truncate on the right (default).
690---   - "wrap": Always wrap (regardless of the 'wrap' option).
691--- - virt_text: [](virtual-text) stored and displayed by this mark. List of `[text, hl]`
692---   tuples, each representing a text chunk with a highlight `hl` which may be
693---   a single highlight group or a list of stacked highlight groups (highest-priority
694---   last).
695--- - virt_text_hide: Hide the virtual text when the background text is selected or
696---   hidden because of scrolling with 'nowrap' or 'smoothscroll'. Currently only
697---   affects "overlay" virt_text.
698--- - virt_text_pos: Position of virtual text:
699---   - "eol": Right after EOL character (default).
700---   - "eol_right_align": Display right-aligned in the window unless the virtual text
701---     is longer than the space available. If the virtual text is too long, it is
702---     truncated to fit in the window after the EOL character. If the line is
703---     wrapped, the virtual text is shown after the end of the line rather than the
704---     previous screen line.
705---   - "overlay": Display over the specified column, without shifting the underlying text.
706---   - "right_align": Display right-aligned in the window.
707---   - "inline": Display at the specified column, and right-shift the buffer text as needed.
708--- - virt_text_repeat_linebreak: Repeat the virtual text on wrapped lines.
709--- - virt_text_win_col: Position the virtual text at a fixed window column (starting
710---   from the first text column of the screen line) instead of "virt_text_pos".
711--- @return integer # Id of the created/updated extmark
712function vim.api.nvim_buf_set_extmark(buf, ns_id, line, col, opts) end
713
714--- Sets a buffer-local `mapping` for the given mode.
715---
716---
717--- @see vim.api.nvim_set_keymap
718--- @param buf integer Buffer id, or 0 for current buffer
719--- @param mode string
720--- @param lhs string
721--- @param rhs string
722--- @param opts vim.api.keyset.keymap?
723function vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, opts) end
724
725--- Sets (replaces) a line-range in the buffer.
726---
727--- Indexing is zero-based, end-exclusive. Negative indices are interpreted
728--- as length+1+index: -1 refers to the index past the end. So to change
729--- or delete the last line use start=-2 and end=-1.
730---
731--- To insert lines at a given index, set `start` and `end` to the same index.
732--- To delete a range of lines, set `replacement` to an empty array.
733---
734--- Out-of-bounds indices are clamped to the nearest valid value, unless
735--- `strict_indexing` is set.
736---
737---
738--- @see vim.api.nvim_buf_set_text
739--- @param buf integer Buffer id, or 0 for current buffer
740--- @param start integer First line index
741--- @param end_ integer Last line index, exclusive
742--- @param strict_indexing boolean Whether out-of-bounds should be an error.
743--- @param replacement string[] Array of lines to use as replacement
744function vim.api.nvim_buf_set_lines(buf, start, end_, strict_indexing, replacement) end
745
746--- Sets a named mark in the given buffer, all marks are allowed
747--- file/uppercase, visual, last change, etc. See `mark-motions`.
748---
749--- Marks are (1,0)-indexed. `api-indexing`
750---
751--- Note:
752--- Passing 0 as line deletes the mark
753---
754---
755--- @see vim.api.nvim_buf_del_mark
756--- @see vim.api.nvim_buf_get_mark
757--- @param buf integer Buffer to set the mark on
758--- @param name string Mark name
759--- @param line integer Line number
760--- @param col integer Column/row number
761--- @param opts vim.api.keyset.empty? Optional parameters. Reserved for future use.
762--- @return boolean # true if the mark was set, else false.
763function vim.api.nvim_buf_set_mark(buf, name, line, col, opts) end
764
765--- Sets the full file name for a buffer, like `:file_f`
766---
767--- @param buf integer Buffer id, or 0 for current buffer
768--- @param name string Buffer name
769function vim.api.nvim_buf_set_name(buf, name) end
770
771--- @deprecated
772--- @param buffer integer
773--- @param name string
774--- @param value any
775function vim.api.nvim_buf_set_option(buffer, name, value) end
776
777--- Sets (replaces) a range in the buffer
778---
779--- This is recommended over `nvim_buf_set_lines()` when only modifying parts of
780--- a line, as extmarks will be preserved on non-modified parts of the touched
781--- lines.
782---
783--- Indexing is zero-based. Row indices are end-inclusive, and column indices
784--- are end-exclusive.
785---
786--- To insert text at a given `(row, column)` location, use `start_row = end_row
787--- = row` and `start_col = end_col = col`. To delete the text in a range, use
788--- `replacement = {}`.
789---
790--- Note:
791--- Prefer |nvim_buf_set_lines()| (for performance) to add or delete entire lines.
792--- Prefer |nvim_paste()| or |nvim_put()| to insert (instead of replace) text at cursor.
793---
794---
795--- @param buf integer Buffer id, or 0 for current buffer
796--- @param start_row integer First line index
797--- @param start_col integer Starting column (byte offset) on first line
798--- @param end_row integer Last line index, inclusive
799--- @param end_col integer Ending column (byte offset) on last line, exclusive
800--- @param replacement string[] Array of lines to use as replacement
801function vim.api.nvim_buf_set_text(buf, start_row, start_col, end_row, end_col, replacement) end
802
803--- Sets a buffer-scoped (b:) variable
804---
805--- @param buf integer Buffer id, or 0 for current buffer
806--- @param name string Variable name
807--- @param value any Variable value
808function vim.api.nvim_buf_set_var(buf, name, value) end
809
810--- @deprecated
811--- @param buffer integer
812--- @param src_id integer
813--- @param line integer
814--- @param chunks any[]
815--- @param opts vim.api.keyset.empty?
816--- @return integer
817function vim.api.nvim_buf_set_virtual_text(buffer, src_id, line, chunks, opts) end
818
819--- Calls a Vimscript `Dictionary-function` with the given arguments.
820---
821--- On execution error: fails with Vimscript error, updates v:errmsg.
822---
823--- @param dict any Dict, or String evaluating to a Vimscript `self` dict
824--- @param fn string Name of the function defined on the Vimscript dict
825--- @param args any[] Function arguments packed in an Array
826--- @return any # Result of the function call
827function vim.api.nvim_call_dict_function(dict, fn, args) end
828
829--- Calls a Vimscript function with the given arguments.
830---
831--- On execution error: fails with Vimscript error, updates v:errmsg.
832---
833--- @param fn string Function to call
834--- @param args any[] Function arguments packed in an Array
835--- @return any # Result of the function call
836function vim.api.nvim_call_function(fn, args) end
837
838--- Sends raw data to channel `chan`. `channel-bytes`
839--- - For a job, it writes it to the stdin of the process.
840--- - For the stdio channel `channel-stdio`, it writes to Nvim's stdout.
841--- - For an internal terminal instance (`nvim_open_term()`) it writes directly to terminal output.
842---
843--- This function writes raw data, not RPC messages. Use `vim.rpcrequest()` and `vim.rpcnotify()` if
844--- the channel expects RPC messages (i.e. it was created with `rpc=true`).
845---
846--- To write data to the `TUI` host terminal, see `nvim_ui_send()`.
847---
848--- @param chan integer Channel id
849--- @param data string Data to write. 8-bit clean: may contain NUL bytes.
850function vim.api.nvim_chan_send(chan, data) end
851
852--- Clears all autocommands matching the {opts} query. To delete autocmds see `nvim_del_autocmd()`.
853---
854--- @param opts vim.api.keyset.clear_autocmds? Optional parameters:
855--- - buf: (`integer?`) Select `autocmd-buflocal` autocommands. Not allowed with {pattern}.
856--- - event: (`vim.api.keyset.events|vim.api.keyset.events[]?`)
857---   Examples:
858---   - event: "pat1"
859---   - event: { "pat1" }
860---   - event: { "pat1", "pat2", "pat3" }
861--- - group: (`string|int?`) Group name or id.
862---   - NOTE: If not given, matches autocmds *not* in any group.
863--- - pattern: (`string|table?`) Filter by patterns (exact match). Not allowed with {buf}.
864---   - Example: if you have `*.py` as that pattern for the autocmd, you must pass `*.py`
865---     exactly to clear it. `test.py` will not match the pattern.
866function vim.api.nvim_clear_autocmds(opts) end
867
868--- Executes an Ex command `cmd`, specified as a Dict with the same structure as returned by
869--- `nvim_parse_cmd()`.
870---
871--- Use `magic={…=false}` to disable special chars (see also `open-file`):
872--- ```lua
873--- vim.api.nvim_cmd({
874---     cmd = 'edit',
875---     args = { '%foo"|bar#baz"' },
876---     magic = { file = false, bar = false }
877---   },
878---   {}
879--- )
880--- ```
881---
882--- - See `nvim_parse_cmd()` to parse a cmdline string (which can then be passed to `nvim_cmd`).
883--- - See `nvim_command()` to execute a cmdline string.
884---
885--- On execution error: fails with Vimscript error, updates v:errmsg.
886---
887---
888--- @see vim.api.nvim_command
889--- @see vim.api.nvim_exec2
890--- @see vim.api.nvim_parse_cmd
891--- @param cmd vim.api.keyset.cmd Command to execute, a Dict with the same structure as the return value of
892--- `nvim_parse_cmd()` (except "addr", "nargs" and "nextcmd" are ignored).
893--- All keys except "cmd" are optional.
894--- @param opts vim.api.keyset.cmd_opts? Optional parameters.
895--- - output: (boolean, default false) Whether to return command output.
896--- @return string # Command output (non-error, non-shell |:!|) if `output` is true, else empty string.
897function vim.api.nvim_cmd(cmd, opts) end
898
899--- Executes an Ex command.
900---
901--- On execution error: fails with Vimscript error, updates v:errmsg.
902---
903--- Prefer `nvim_cmd()` or `nvim_exec2()` instead. To modify an Ex command in a structured way
904--- before executing it, modify the result of `nvim_parse_cmd()` then pass it to `nvim_cmd()`.
905---
906--- @param cmd string Ex command string
907function vim.api.nvim_command(cmd) end
908
909--- @deprecated
910--- @see vim.api.nvim_exec2
911--- @param command string
912--- @return string
913function vim.api.nvim_command_output(command) end
914
915--- Create or get an autocommand group `autocmd-groups`.
916---
917--- To get an existing group id, do:
918---
919--- ```lua
920--- local id = vim.api.nvim_create_augroup('my.lsp.config', {
921---   clear = false
922--- })
923--- ```
924---
925--- @see `:help autocmd-groups`
926--- @param name string Group name
927--- @param opts vim.api.keyset.create_augroup? Optional parameters:
928--- - clear (`boolean?`, default: true) Clear existing commands in the group `autocmd-groups`.
929--- @return integer # Group id.
930function vim.api.nvim_create_augroup(name, opts) end
931
932--- Creates an `autocommand` event handler, defined by `callback` (Lua function or Vimscript
933--- function _name_ string) or `command` (Ex command string).
934---
935--- Example using Lua callback:
936---
937--- ```lua
938--- vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
939---   pattern = {'*.c', '*.h'},
940---   callback = function(ev)
941---     print(string.format('event fired: %s', vim.inspect(ev)))
942---   end
943--- })
944--- ```
945---
946--- Example using an Ex command as the handler:
947---
948--- ```lua
949--- vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
950---   pattern = {'*.c', '*.h'},
951---   command = "echo 'Entering a C or C++ file'",
952--- })
953--- ```
954---
955--- Note: `pattern` is NOT automatically expanded (unlike with `:autocmd`), thus names like "$HOME"
956--- and "~" must be expanded explicitly:
957---
958--- ```lua
959--- pattern = vim.fn.expand('~') .. '/some/path/*.py'
960--- ```
961---
962--- @see `:help autocommand`
963--- @see vim.api.nvim_del_autocmd
964--- @param event vim.api.keyset.events|vim.api.keyset.events[] Event(s) that will trigger the handler (`callback` or `command`): one handler is
965--- created for each event name.
966--- @param opts vim.api.keyset.create_autocmd? Options dict:
967--- - buf (`integer?`) Buffer id for buffer-local autocommands `autocmd-buflocal`.
968---   Not allowed with {pattern}.
969--- - callback (`function|string?`) Lua function (or Vimscript function name, if string)
970---   called when the event(s) is triggered. Lua callback can return `lua-truthy` to delete
971---   the autocommand. Callback receives one argument, a table with keys: [event-args]()
972---     - buf: (`integer`) [<abuf>]
973---     - data: (`any`) Arbitrary data passed from [nvim_exec_autocmds()] [event-data]()
974---     - event: (`vim.api.keyset.events`) Name of the triggered event `autocmd-events`
975---     - file: (`string`) [<afile>] (not expanded to a full path)
976---     - group: (`integer?`) Group id, if any
977---     - id: (`integer`) Autocommand id
978---     - match: (`string`) [<amatch>] (expanded to a full path)
979---     - win: (`integer`) id of the window for the event, see `window-ID`
980--- - command (string?) Vim command executed on event. Not allowed with {callback}.
981--- - desc (`string?`) Description (for documentation and troubleshooting).
982--- - group (`string|integer?`) Group name or id to match against.
983--- - nested (`boolean?`, default: false) Run nested autocommands `autocmd-nested`.
984--- - once (`boolean?`, default: false) Handle the event only once `autocmd-once`. If {event}
985---   is a list, each handler will fire once.
986--- - pattern (`string|array?`) Pattern(s) to match literally `autocmd-pattern`.
987--- @return integer # Autocommand id (number)
988function vim.api.nvim_create_autocmd(event, opts) end
989
990--- Creates a new, empty, unnamed buffer.
991---
992--- @param listed boolean Sets 'buflisted'
993--- @param scratch boolean Creates a "throwaway" `scratch-buffer` for temporary work
994--- (always 'nomodified'). Also sets 'nomodeline' on the buffer.
995--- @return integer # Buffer id, or 0 on error
996function vim.api.nvim_create_buf(listed, scratch) end
997
998--- Creates a new namespace or gets an existing one. [namespace]()
999---
1000--- Namespaces are used for buffer highlights and virtual text, see
1001--- `nvim_buf_set_extmark()`.
1002---
1003--- Namespaces can be named or anonymous. If `name` matches an existing
1004--- namespace, the associated id is returned. If `name` is an empty string
1005--- a new, anonymous namespace is created.
1006---
1007--- @param name string Namespace name or empty string
1008--- @return integer # Namespace id
1009function vim.api.nvim_create_namespace(name) end
1010
1011--- Creates a global `user-commands` command.
1012---
1013--- For Lua usage see `lua-guide-commands-create`.
1014---
1015--- Example:
1016---
1017--- ```vim
1018--- :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true})
1019--- :SayHello
1020--- Hello world!
1021--- ```
1022---
1023--- @param name string Command name. First char must be uppercase.
1024--- @param cmd string|fun(args: vim.api.keyset.create_user_command.command_args) Command or Lua function, executed when the command is invoked. Lua function
1025--- receives a table with keys:
1026--- - args: (string) Args passed to the command, if any. [<args>]
1027--- - bang: (boolean) true if the command was executed with "!". [<bang>]
1028--- - count: (number) Count, if any. [<count>]
1029--- - fargs: (table) Args split by unescaped whitespace (when more than one arg is
1030---   allowed), if any. [<f-args>]
1031--- - line1: (number) Start of the command range. [<line1>]
1032--- - line2: (number) End of the command range. [<line2>]
1033--- - mods: (string) Command modifiers (unstructured string), if any. [<mods>]
1034--- - name: (string) Command name.
1035--- - nargs: (string) Number of arguments allowed by the command. `:command-nargs`
1036--- - range: (number) Number of items in the command range: 0, 1, or 2. [<range>]
1037--- - reg: (string) Register name, if any. [<reg>]
1038--- - smods: (table) Command modifiers (structured), same as "mods" in `nvim_parse_cmd()`.
1039--- @param opts vim.api.keyset.user_command? Optional flags:
1040--- - `addr` `:command-addr`
1041--- - `complete` `:command-complete` command or function `:command-completion-customlist`.
1042--- - `count` `:command-count`
1043--- - `desc` (string) Command description.
1044--- - `force` (boolean, default true) Override the existing definition, if any.
1045--- - `nargs` Number of arguments allowed by the command. `:command-nargs`
1046--- - `preview` (function) Preview handler for 'inccommand'. `:command-preview`
1047--- - `range` `:command-range`
1048--- - boolean `command-attributes` such as `:command-bang` or `:command-bar` (but
1049---   not `:command-buffer`, use `nvim_buf_create_user_command()` instead).
1050function vim.api.nvim_create_user_command(name, cmd, opts) end
1051
1052--- Delete an autocommand group by id.
1053---
1054--- To get a group id one can use `nvim_get_autocmds()`.
1055---
1056--- NOTE: behavior differs from `:augroup-delete`. When deleting a group, autocommands contained in
1057--- this group will also be deleted and cleared. This group will no longer exist.
1058--- @see vim.api.nvim_del_augroup_by_name
1059--- @see vim.api.nvim_create_augroup
1060--- @param id integer Group id.
1061function vim.api.nvim_del_augroup_by_id(id) end
1062
1063--- Delete an autocommand group by name.
1064---
1065--- NOTE: behavior differs from `:augroup-delete`. When deleting a group, autocommands contained in
1066--- this group will also be deleted and cleared. This group will no longer exist.
1067--- @see `:help autocmd-groups`
1068--- @param name string Group name.
1069function vim.api.nvim_del_augroup_by_name(name) end
1070
1071--- Deletes an autocommand by id.
1072---
1073--- @param id integer Autocommand id returned by `nvim_create_autocmd()`
1074function vim.api.nvim_del_autocmd(id) end
1075
1076--- Deletes the current line.
1077---
1078function vim.api.nvim_del_current_line() end
1079
1080--- Unmaps a global `mapping` for the given mode.
1081---
1082--- To unmap a buffer-local mapping, use `nvim_buf_del_keymap()`.
1083---
1084--- @see vim.api.nvim_set_keymap
1085--- @param mode string Mode short-name ("n", "i", "v", ...)
1086--- @param lhs string Left-hand-side `{lhs}` of the mapping.
1087--- @param opts vim.api.keyset.keymap_del? Optional parameters.
1088--- - lhs: When true, only match {lhs}, not {rhs}.
1089function vim.api.nvim_del_keymap(mode, lhs, opts) end
1090
1091--- Deletes an uppercase/file named mark. See `mark-motions`.
1092---
1093--- Note:
1094--- Lowercase name (or other buffer-local mark) is an error.
1095---
1096--- @see vim.api.nvim_buf_del_mark
1097--- @see vim.api.nvim_get_mark
1098--- @param name string Mark name
1099--- @return boolean # true if the mark was deleted, else false.
1100function vim.api.nvim_del_mark(name) end
1101
1102--- Delete a user-defined command.
1103---
1104--- @param name string Name of the command to delete.
1105function vim.api.nvim_del_user_command(name) end
1106
1107--- Removes a global (g:) variable.
1108---
1109--- @param name string Variable name
1110function vim.api.nvim_del_var(name) end
1111
1112--- Prints a message given by a list of `[text, hl_group]` "chunks". Emits a `Progress` event if
1113--- `kind='progress'`.
1114---
1115--- Returns a message-id, which can be given in later calls to update an existing message. The
1116--- message-id is an autogenerated integer, or a user-defined string. The id "address space" is
1117--- global, so plugins specifying a string id should use qualified names such as "my.msg.id" to
1118--- avoid unintentional conflicts.
1119---
1120--- Example:
1121--- ```lua
1122--- vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true)
1123--- ```
1124---
1125--- @param chunks [string, integer|string?][] List of `[text, hl_group]` pairs, where each is a `text` string highlighted by
1126--- the (optional) name or ID `hl_group`.
1127--- @param history boolean if true, add to `message-history`.
1128--- @param opts vim.api.keyset.echo_opts? Optional parameters.
1129--- - data (`table?`) Dict of arbitrary data, available in `Progress` `event-data`.
1130--- - err (`boolean?`)  Treat the message like `:echoerr`. Sets `hl_group` to `hl-ErrorMsg` by default.
1131--- - id (`integer|string?`) Message-id returned by a previous `nvim_echo` call, or
1132---   a user-defined id (string). If existing message has this id, it will be updated
1133---   instead of creating a new message.
1134--- - kind (`string?`) Decides the `ui-messages` kind in the emitted message. Set "progress"
1135---   to emit a `progress-message`.
1136--- - percent (`integer?`) `progress-message` percentage, or nil to signal "unknown progress".
1137--- - source (`string?`) `progress-message` source.
1138--- - status (`string?`) `progress-message` status:
1139---   - "success": Process completed successfully.
1140---   - "running": Process is ongoing.
1141---   - "failed": Process failed.
1142---   - "cancel": Process should be cancelled. Progress owner must handle the `Progress`
1143---     event to perform the cancellation.
1144--- - title (`string?`) Message title. Only for `progress-message` currently.
1145--- - verbose (`boolean?`) Message is controlled by the 'verbose' option. `nvim -V3log` will write the
1146---   message to the "log" file instead of standard output.
1147--- @return integer|string # Message-id, or -1 if message wasn't shown.
1148function vim.api.nvim_echo(chunks, history, opts) end
1149
1150--- @deprecated
1151--- @param str string
1152function vim.api.nvim_err_write(str) end
1153
1154--- @deprecated
1155--- @param str string
1156function vim.api.nvim_err_writeln(str) end
1157
1158--- Evaluates a Vimscript `expression`. Dicts and Lists are recursively expanded.
1159---
1160--- On execution error: fails with Vimscript error, updates v:errmsg.
1161---
1162--- @param expr string Vimscript expression string
1163--- @return any # Evaluation result or expanded object
1164function vim.api.nvim_eval(expr) end
1165
1166--- Evaluates statusline string.
1167---
1168--- @param str string Statusline string (see 'statusline').
1169--- @param opts vim.api.keyset.eval_statusline? Optional parameters.
1170--- - fillchar: (string) Character to fill blank spaces in the statusline (see
1171---                      'fillchars'). Treated as single-width even if it isn't.
1172--- - highlights: (boolean) Return highlight information.
1173--- - maxwidth: (number) Maximum width of statusline.
1174--- - use_statuscol_lnum: (number) Evaluate statuscolumn for this line number instead of statusline.
1175--- - use_tabline: (boolean) Evaluate tabline instead of statusline. When true, {winid}
1176---                          is ignored. Mutually exclusive with {use_winbar}.
1177--- - use_winbar: (boolean) Evaluate winbar instead of statusline.
1178--- - winid: (number) `window-ID` of the window to use as context for statusline.
1179--- @return vim.api.keyset.eval_statusline_ret # Dict containing statusline information, with these keys:
1180--- - str: (string) Characters that will be displayed on the statusline.
1181--- - width: (number) Display width of the statusline.
1182--- - highlights: Array containing highlight information of the statusline. Only included when
1183---               the "highlights" key in {opts} is true. Each element of the array is a
1184---               |Dict| with these keys:
1185---     - start: (number) Byte index (0-based) of first character that uses the highlight.
1186---     - group: (string) Deprecated. Use `groups` instead.
1187---     - groups: (array) Names of stacked highlight groups (highest priority last).
1188function vim.api.nvim_eval_statusline(str, opts) end
1189
1190--- @deprecated
1191--- @see vim.api.nvim_exec2
1192--- @param src string
1193--- @param output boolean
1194--- @return string
1195function vim.api.nvim_exec(src, output) end
1196
1197--- Executes Vimscript (multiline block of Ex commands), like anonymous
1198--- `:source`.
1199---
1200--- Unlike `nvim_command()` this function supports heredocs, script-scope (s:),
1201--- etc.
1202---
1203--- On execution error: fails with Vimscript error, updates v:errmsg.
1204---
1205---
1206--- @see `:help execute()`
1207--- @see vim.api.nvim_command
1208--- @see vim.api.nvim_cmd
1209--- @param src string Vimscript code
1210--- @param opts vim.api.keyset.exec_opts? Optional parameters.
1211--- - output: (boolean, default false) Whether to capture and return
1212---           all (non-error, non-shell `:!`) output.
1213--- @return table<string,any> # Dict containing information about execution, with these keys:
1214--- - output: (string|nil) Output if `opts.output` is true.
1215function vim.api.nvim_exec2(src, opts) end
1216
1217--- Executes {event} handlers matching the {opts} query, in the context of {buf} (if given). `autocmd-execute`
1218---
1219--- @see `:help :doautocmd`
1220--- @param event vim.api.keyset.events|vim.api.keyset.events[] Event(s) to execute.
1221--- @param opts vim.api.keyset.exec_autocmds? Optional filters:
1222--- - buf (`integer?`) Buffer where the event is applied. `autocmd-buflocal` Not allowed with {pattern}.
1223--- - data (`any`): Arbitrary data passed to the callback. See `nvim_create_autocmd()`.
1224--- - group (`string|integer?`) Group name or id to match against. `autocmd-groups`.
1225--- - modeline (`boolean?`, default: true) Process the modeline after the autocommands
1226---   [<nomodeline>]. Ignored if `buf` is given.
1227--- - pattern (`string|array?`, default: current file name) `autocmd-pattern`. Not allowed with {buf}.
1228function vim.api.nvim_exec_autocmds(event, opts) end
1229
1230--- Sends input-keys to Nvim, subject to various quirks controlled by `mode` flags. This is
1231--- a blocking call, unlike `nvim_input()`.
1232---
1233--- On execution error: does not fail, but updates v:errmsg.
1234---
1235--- To input keycodes like [<C-o>], pass the result of `nvim_replace_termcodes()`:
1236---
1237--- ```vim
1238--- :let key = nvim_replace_termcodes('<C-o>', v:true, v:false, v:true)
1239--- :call nvim_feedkeys(key, 'n', v:false)
1240--- ```
1241---
1242--- @see feedkeys()
1243--- @see vim_strsave_escape_ks
1244--- @param keys string Keys to send as input.
1245--- @param mode string Behavior flags, see `feedkeys()`.
1246--- @param escape_ks boolean If true, escape K_SPECIAL bytes in `keys`. Should be false if you used
1247--- `nvim_replace_termcodes()`, else true.
1248function vim.api.nvim_feedkeys(keys, mode, escape_ks) end
1249
1250--- Gets the option information for all options.
1251---
1252--- The dict has the full option names as keys and option metadata dicts as detailed at
1253--- `nvim_get_option_info2()`.
1254---
1255---
1256--- @see vim.api.nvim_get_commands
1257--- @return table<string,any> # dict of all options
1258function vim.api.nvim_get_all_options_info() end
1259
1260--- Gets all autocommands matching ALL criteria in the {opts} query.
1261---
1262--- Note: When multiple patterns or events are provided they have "OR" semantics (any combination
1263--- is matched).
1264---
1265--- Examples:
1266---
1267--- ```lua
1268--- -- Matches all criteria
1269--- autocommands = vim.api.nvim_get_autocmds({
1270---   group = 'MyGroup',
1271---   event = {'BufEnter', 'BufWinEnter'},
1272---   pattern = {'*.c', '*.h'}
1273--- })
1274---
1275--- -- All commands from one group
1276--- autocommands = vim.api.nvim_get_autocmds({
1277---   group = 'MyGroup',
1278--- })
1279--- ```
1280---
1281--- @param opts vim.api.keyset.get_autocmds? Dict with at least one of these keys:
1282--- - buf: (`integer[]|integer?`) Buffer id or list of buffer ids, for buffer-local autocommands
1283---   `autocmd-buflocal`. Not allowed with {pattern}.
1284--- - event: (`vim.api.keyset.events|vim.api.keyset.events[]?`) Event(s) to match `autocmd-events`.
1285--- - group: (`string|table?`) Group name or id to match.
1286--- - id: (`integer?`) Autocommand ID to match.
1287--- - pattern: (`string|table?`) Pattern(s) to match `autocmd-pattern`. Not allowed with {buf}.
1288--- @return vim.api.keyset.get_autocmds.ret[] # Array of matching autocommands, where each item has:
1289--- - buf (`integer?`): Buffer id (only for |autocmd-buffer-local|).
1290--- - buflocal (`boolean?`): true if the autocommand is buffer-local |autocmd-buffer-local|.
1291--- - callback: (`function|string?`): Event handler: a Lua function or Vimscript function name.
1292--- - command: (`string`) Event handler: an Ex-command. Empty if a `callback` is set.
1293--- - desc: (`string`) Description.
1294--- - event: (`vim.api.keyset.events`) Event name(s).
1295--- - group: (`integer`) Group id.
1296--- - group_name: (`string`) Group name.
1297--- - id: (`integer`) Autocommand id (only when defined with the API).
1298--- - once: (`boolean`) true if |autocmd-once| was set.
1299--- - pattern: (`string`) Autocommand pattern.
1300function vim.api.nvim_get_autocmds(opts) end
1301
1302--- Gets information about a channel.
1303---
1304--- See `nvim_list_uis()` for an example of how to get channel info.
1305---
1306--- @param chan integer channel_id, or 0 for current channel
1307--- @return table<string,any> # Channel info dict with these keys:
1308--- - "id"       Channel id.
1309--- - "argv"     (optional) Job arguments list.
1310--- - "stream"   Stream underlying the channel.
1311---      - "stdio"      stdin and stdout of this Nvim instance
1312---      - "stderr"     stderr of this Nvim instance
1313---      - "socket"     TCP/IP socket or named pipe
1314---      - "job"        Job with communication over its stdio.
1315--- - "mode"     How data received on the channel is interpreted.
1316---      - "bytes"      Send and receive raw bytes.
1317---      - "terminal"   |terminal| instance interprets ASCII sequences.
1318---      - "rpc"        |RPC| communication on the channel is active.
1319--- - "pty"      (optional) Name of pseudoterminal. On a POSIX system this is a device path like
1320---              "/dev/pts/1". If unknown, the key will still be present if a pty is used (e.g.
1321---              for conpty on Windows).
1322--- - "buf"      (optional) Buffer connected to |terminal| instance.
1323--- - "buffer"   (optional) Deprecated alias for `buf`.
1324--- - "client"   (optional) Info about the peer (client on the other end of the channel), as set
1325---              by |nvim_set_client_info()|.
1326--- - "exitcode" (optional) Exit code of the |terminal| process.
1327---
1328function vim.api.nvim_get_chan_info(chan) end
1329
1330--- Returns the 24-bit RGB value of a `nvim_get_color_map()` color name or
1331--- "#rrggbb" hexadecimal string.
1332---
1333--- Example:
1334---
1335--- ```vim
1336--- :echo nvim_get_color_by_name("Pink")
1337--- :echo nvim_get_color_by_name("#cbcbcb")
1338--- ```
1339---
1340--- @param name string Color name or "#rrggbb" string
1341--- @return integer # 24-bit RGB value, or -1 for invalid argument.
1342function vim.api.nvim_get_color_by_name(name) end
1343
1344--- Returns a map of color names and RGB values.
1345---
1346--- Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values
1347--- (e.g. 65535).
1348---
1349--- @return table<string,integer> # Map of color names and RGB values.
1350function vim.api.nvim_get_color_map() end
1351
1352--- Gets a map of global (non-buffer-local) Ex commands.
1353---
1354--- Currently only `user-commands` are supported, not builtin Ex commands.
1355---
1356---
1357--- @see vim.api.nvim_get_all_options_info
1358--- @param opts vim.api.keyset.get_commands? Optional parameters. Currently only supports
1359--- {"builtin":false}
1360--- @return table<string,vim.api.keyset.command_info> # Map of maps describing commands.
1361function vim.api.nvim_get_commands(opts) end
1362
1363--- Gets a map (msgpack encoding) of the current editor state:
1364---
1365--- - "bufs"    [buffer-list]
1366--- - "funcs"   Vimscript global and [script-local] functions
1367--- - "gvars"   [global-variable]s
1368--- - "jumps"   [jumplist]
1369--- - "regs"    [registers]
1370--- - "sfuncs"  Vimscript [script-local] functions
1371---
1372--- @param opts vim.api.keyset.context? Optional parameters.
1373--- - types:  List of context types (see above) to gather, or empty for "all".
1374--- @return table<string,any> # Editor state as a msgpack-encoded map.
1375function vim.api.nvim_get_context(opts) end
1376
1377--- Gets the current buffer.
1378---
1379--- @return integer # Buffer id
1380function vim.api.nvim_get_current_buf() end
1381
1382--- Gets the current line.
1383---
1384--- @return string # Current line string
1385function vim.api.nvim_get_current_line() end
1386
1387--- Gets the current tabpage.
1388---
1389--- @return integer # |tab-ID|
1390function vim.api.nvim_get_current_tabpage() end
1391
1392--- Gets the current window.
1393---
1394--- @return integer # |window-ID|
1395function vim.api.nvim_get_current_win() end
1396
1397--- Gets all or specific highlight groups in a namespace.
1398---
1399--- Note:
1400--- When the `link` attribute is defined in the highlight definition
1401--- map, other attributes will not be taking effect (see |:hi-link|).
1402---
1403---
1404--- @param ns_id integer Get highlight groups for namespace ns_id `nvim_get_namespaces()`.
1405--- Use 0 to get global highlight groups `:highlight`.
1406--- @param opts vim.api.keyset.get_highlight? Options dict:
1407--- - create: (boolean, default true) When highlight group doesn't exist create it.
1408--- - id: (integer) Get a highlight definition by id.
1409--- - link: (boolean, default true) Show linked group name instead of effective definition `:hi-link`.
1410--- - name: (string) Get a highlight definition by name.
1411--- @return vim.api.keyset.get_hl_info # Highlight groups as a map from group name to a highlight definition map as in |nvim_set_hl()|,
1412--- or only a single highlight definition map if requested by name or id.
1413function vim.api.nvim_get_hl(ns_id, opts) end
1414
1415--- @deprecated
1416--- @see vim.api.nvim_get_hl_by_name
1417--- @param hl_id integer
1418--- @param rgb boolean
1419--- @return table<string,any>
1420function vim.api.nvim_get_hl_by_id(hl_id, rgb) end
1421
1422--- @deprecated
1423--- @see vim.api.nvim_get_hl_by_id
1424--- @param name string
1425--- @param rgb boolean
1426--- @return table<string,any>
1427function vim.api.nvim_get_hl_by_name(name, rgb) end
1428
1429--- Gets a highlight group by name
1430---
1431--- similar to `hlID()`, but allocates a new ID if not present.
1432--- @param name string
1433--- @return integer
1434function vim.api.nvim_get_hl_id_by_name(name) end
1435
1436--- Gets the active highlight namespace.
1437---
1438--- @param opts vim.api.keyset.get_ns? Optional parameters
1439--- - winid: (number) `window-ID` for retrieving a window's highlight
1440---   namespace. A value of -1 is returned when `nvim_win_set_hl_ns()`
1441---   has not been called for the window (or was called with a namespace
1442---   of -1).
1443--- @return integer # Namespace id, or -1
1444function vim.api.nvim_get_hl_ns(opts) end
1445
1446--- Gets a list of global (non-buffer-local) `mapping` definitions.
1447---
1448--- @param mode string Mode short-name ("n", "i", "v", ...)
1449--- @return vim.api.keyset.get_keymap[] # Array of |maparg()|-like dictionaries describing mappings.
1450--- The "buf" key is always zero.
1451function vim.api.nvim_get_keymap(mode) end
1452
1453--- Returns a `(row, col, buffer, buffername)` tuple representing the position
1454--- of the uppercase/file named mark. "End of line" column position is returned
1455--- as `v:maxcol` (big number). See `mark-motions`.
1456---
1457--- Marks are (1,0)-indexed. `api-indexing`
1458---
1459--- Note:
1460--- Lowercase name (or other buffer-local mark) is an error.
1461---
1462--- @see vim.api.nvim_buf_set_mark
1463--- @see vim.api.nvim_del_mark
1464--- @param name string Mark name
1465--- @param opts vim.api.keyset.empty? Optional parameters. Reserved for future use.
1466--- @return [integer, integer, integer, string] # 4-tuple (row, col, buffer, buffername), (0, 0, 0, '') if the mark is
1467--- not set.
1468function vim.api.nvim_get_mark(name, opts) end
1469
1470--- Gets the current mode. `mode()`
1471--- "blocking" is true if Nvim is waiting for input.
1472---
1473--- @return vim.api.keyset.get_mode # Dict { "mode": String, "blocking": Boolean }
1474function vim.api.nvim_get_mode() end
1475
1476--- Gets existing, non-anonymous `namespace`s.
1477---
1478--- @return table<string,integer> # dict that maps from names to namespace ids.
1479function vim.api.nvim_get_namespaces() end
1480
1481--- @deprecated
1482--- @param name string
1483--- @return any
1484function vim.api.nvim_get_option(name) end
1485
1486--- @deprecated
1487--- @param name string
1488--- @return vim.api.keyset.get_option_info
1489function vim.api.nvim_get_option_info(name) end
1490
1491--- Gets the option information for one option from arbitrary buffer or window
1492---
1493--- Resulting dict has keys:
1494--- - name: Name of the option (like 'filetype')
1495--- - shortname: Shortened name of the option (like 'ft')
1496--- - type: type of option ("string", "number" or "boolean")
1497--- - default: The default value for the option
1498--- - was_set: Whether the option was set.
1499---
1500--- - last_set_sid: Last set script id (if any)
1501--- - last_set_linenr: line number where option was set
1502--- - last_set_chan: Channel where option was set (0 for local)
1503---
1504--- - scope: one of "global", "win", "buf", or "tab"
1505--- - global_local: whether win or buf option has a global value
1506---
1507--- - commalist: List of comma separated values
1508--- - flaglist: List of single char flags
1509---
1510--- When {scope} is not provided, the last set information applies to the local
1511--- value in the current buffer or window if it is available, otherwise the
1512--- global value information is returned. This behavior can be disabled by
1513--- explicitly specifying {scope} in the {opts} table.
1514---
1515--- @param name string Option name
1516--- @param opts vim.api.keyset.option? Optional parameters
1517--- - buf: Buffer number. Used for getting buffer local options.
1518---        Implies {scope} is "local".
1519--- - scope: One of "global" or "local". Analogous to
1520--- `:setglobal` and `:setlocal`, respectively.
1521--- - win: `window-ID`. Used for getting window local options.
1522--- @return vim.api.keyset.get_option_info # Option Information
1523function vim.api.nvim_get_option_info2(name, opts) end
1524
1525--- Gets the value of an option. The behavior of this function matches that of
1526--- `:set`: the local value of an option is returned if it exists; otherwise,
1527--- the global value is returned. Local values always correspond to the current
1528--- buffer or window, unless "buf" or "win" is set in {opts}.
1529---
1530--- @param name string Option name
1531--- @param opts vim.api.keyset.option? Optional parameters
1532--- - buf: Buffer number. Used for getting buffer local options.
1533---        Implies {scope} is "local".
1534--- - filetype: `filetype`. Used to get the default option for a
1535---   specific filetype. Cannot be used with any other option.
1536---   Note: this will trigger `ftplugin` and all `FileType`
1537---   autocommands for the corresponding filetype.
1538--- - scope: One of "global" or "local". Analogous to
1539--- `:setglobal` and `:setlocal`, respectively.
1540--- - tab: `tab-ID` for tab-local options. Currently only
1541---   supports "cmdheight". Tabpage `0` means the current tabpage.
1542--- - win: `window-ID`. Used for getting window local options.
1543--- @return any # Option value
1544function vim.api.nvim_get_option_value(name, opts) end
1545
1546--- Gets info describing process `pid`.
1547---
1548--- @param pid integer
1549--- @return any # Map of process properties, or NIL if process not found.
1550function vim.api.nvim_get_proc(pid) end
1551
1552--- Gets the immediate children of process `pid`.
1553---
1554--- @param pid integer
1555--- @return any[] # Array of child process ids, empty if process not found.
1556function vim.api.nvim_get_proc_children(pid) end
1557
1558--- Finds files in runtime directories, in 'runtimepath' order.
1559---
1560--- "name" can contain wildcards. For example
1561--- `nvim_get_runtime_file("colors/*.{vim,lua}", true)` will return all color
1562--- scheme files. Always use forward slashes (/) in the search pattern for
1563--- subdirectories regardless of platform.
1564---
1565--- It is not an error to not find any files. An empty array is returned then.
1566---
1567--- @param name string pattern of files to search for
1568--- @param all boolean whether to return all matches or only the first
1569--- @return string[] # list of absolute paths to the found files
1570function vim.api.nvim_get_runtime_file(name, all) end
1571
1572--- Gets a global (g:) variable.
1573---
1574--- @param name string Variable name
1575--- @return any # Variable value
1576function vim.api.nvim_get_var(name) end
1577
1578--- Gets a v: variable.
1579---
1580--- @param name string Variable name
1581--- @return any # Variable value
1582function vim.api.nvim_get_vvar(name) end
1583
1584--- Queues raw user-input. Unlike `nvim_feedkeys()`, this uses a low-level input buffer and the call
1585--- is non-blocking (input is processed asynchronously by the eventloop).
1586---
1587--- To input blocks of text, `nvim_paste()` is much faster and should be preferred.
1588---
1589--- On execution error: does not fail, but updates v:errmsg.
1590---
1591--- Note:
1592--- |keycodes| like [<CR>] are translated, so "<" is special.
1593--- To input a literal "<", send [<LT>].
1594---
1595--- For mouse events use |nvim_input_mouse()|. The pseudokey form
1596--- `<LeftMouse><col,row>` is deprecated since |api-level| 6.
1597---
1598---
1599--- @param keys string to be typed
1600--- @return integer # Number of bytes actually written (can be fewer than
1601--- requested if the buffer becomes full).
1602function vim.api.nvim_input(keys) end
1603
1604--- Send mouse event from GUI.
1605---
1606--- Non-blocking: does not wait on any result, but queues the event to be
1607--- processed soon by the event loop.
1608---
1609--- Note:
1610--- Currently this doesn't support "scripting" multiple mouse events
1611--- by calling it multiple times in a loop: the intermediate mouse
1612--- positions will be ignored. It should be used to implement real-time
1613--- mouse input in a GUI. The deprecated pseudokey form
1614--- (`<LeftMouse><col,row>`) of |nvim_input()| has the same limitation.
1615---
1616---
1617--- @param button string Mouse button: one of "left", "right", "middle", "wheel", "move",
1618--- "x1", "x2".
1619--- @param action string For ordinary buttons, one of "press", "drag", "release".
1620--- For the wheel, one of "up", "down", "left", "right". Ignored for "move".
1621--- @param modifier string String of modifiers each represented by a single char.
1622--- The same specifiers are used as for a key press, except
1623--- that the "-" separator is optional, so "C-A-", "c-a"
1624--- and "CA" can all be used to specify Ctrl+Alt+click.
1625--- @param grid integer Grid number (used by `ui-multigrid` client), or 0 to let Nvim decide positioning of
1626--- windows. For more information, see [dev-ui-multigrid]
1627--- @param row integer Mouse row-position (zero-based, like redraw events)
1628--- @param col integer Mouse column-position (zero-based, like redraw events)
1629function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end
1630
1631--- Gets the current list of buffers.
1632---
1633--- Includes unlisted (unloaded/deleted) buffers, like `:ls!`.
1634--- Use `nvim_buf_is_loaded()` to check if a buffer is loaded.
1635---
1636--- @return integer[] # List of buffer ids
1637function vim.api.nvim_list_bufs() end
1638
1639--- Get information about all open channels.
1640---
1641--- @return table<string,any>[] # Array of Dictionaries, each describing a channel with
1642--- the format specified at |nvim_get_chan_info()|.
1643function vim.api.nvim_list_chans() end
1644
1645--- Gets the paths contained in `runtime-search-path`.
1646---
1647--- @return string[] # List of paths
1648function vim.api.nvim_list_runtime_paths() end
1649
1650--- Gets the current list of `tab-ID`s.
1651---
1652--- @return integer[] # List of |tab-ID|s
1653function vim.api.nvim_list_tabpages() end
1654
1655--- Gets a list of dictionaries representing attached UIs.
1656---
1657--- Example: The Nvim builtin `TUI` sets its channel info as described in `startup-tui`. In
1658--- particular, it sets `client.name` to "nvim-tui". So you can check if the TUI is running by
1659--- inspecting the client name of each UI:
1660---
1661--- ```lua
1662--- vim.print(vim.api.nvim_get_chan_info(vim.api.nvim_list_uis()[1].chan).client.name)
1663--- ```
1664---
1665--- @return table<string,any>[] # Array of UI dictionaries, each with these keys:
1666--- - "height"  Requested height of the UI
1667--- - "width"   Requested width of the UI
1668--- - "rgb"     true if the UI uses RGB colors (false implies |cterm-colors|)
1669--- - "ext_..." Requested UI extensions, see |ui-option|
1670--- - "chan"    |channel-id| of remote UI
1671function vim.api.nvim_list_uis() end
1672
1673--- Gets the current list of all `window-ID`s in all tabpages.
1674---
1675--- @return integer[] # List of |window-ID|s
1676function vim.api.nvim_list_wins() end
1677
1678--- Sets the current editor state from the given map.
1679---
1680--- @param dict table<string,any> Msgpack-encoded editor state, in the form returned by [nvim_get_context()].
1681--- @return any
1682function vim.api.nvim_load_context(dict) end
1683
1684--- @deprecated
1685--- @param msg string
1686--- @param log_level integer
1687--- @param opts table<string,any>
1688--- @return any
1689function vim.api.nvim_notify(msg, log_level, opts) end
1690
1691--- Opens a new tabpage.
1692---
1693--- @param buf integer Buffer to open in the first window of the new tabpage.
1694--- Use 0 for current buffer.
1695--- @param enter boolean Enter the tabpage (make it the current tabpage).
1696--- @param config vim.api.keyset.tabpage_config Configuration for the new tabpage. Keys:
1697--- - after: Position to insert tabpage (default: -1; after current).
1698---          0 = first, N = after Nth.
1699--- @return integer # |tab-ID| of the new tabpage
1700function vim.api.nvim_open_tabpage(buf, enter, config) end
1701
1702--- Open a terminal instance in a buffer
1703---
1704--- By default (and currently the only option) the terminal will not be
1705--- connected to an external process. Instead, input sent on the channel
1706--- will be echoed directly by the terminal. This is useful to display
1707--- ANSI terminal sequences returned as part of an RPC message, or similar.
1708---
1709--- Note: `:ls` reports the buffer as "R" (running) until the channel is closed. `chanclose()`
1710---
1711--- Note: To initialize the terminal size, display the buffer in a window first. E.g. for a floating display,
1712--- 1. Create an empty buffer using `nvim_create_buf()`.
1713--- 2. Display it with `nvim_open_win()`.
1714--- 3. Call nvim_open_term().
1715--- 4. Then calling `nvim_chan_send()` will process sequences in a virtual terminal with the
1716---    intended size (defined by the window width/height).
1717---
1718--- Example: this `TermHl` command can be used to display and highlight raw ANSI termcodes, so you
1719--- can use Nvim as a "scrollback pager" (for terminals like kitty): [ansi-colorize]()
1720--- [terminal-scrollback-pager]()
1721---
1722--- ```lua
1723--- vim.api.nvim_create_user_command('TermHl', function()
1724---   vim.api.nvim_open_term(0)
1725--- end, { desc = 'Highlights ANSI termcodes in curbuf' })
1726--- ```
1727---
1728--- @param buf integer Buffer which displays the PTY output. The initial buffer contents (if any) will be
1729--- written to the PTY.
1730--- @param opts vim.api.keyset.open_term? Optional parameters.
1731--- - force_crlf: (boolean, default: true) Convert "\n" to "\r\n".
1732--- - on_input: (`fun("input", chan: integer, buf: integer, data: string)`) Function invoked
1733---   when the terminal emits bytes, see above. `textlock` applies. May call
1734---   `nvim_chan_send()` directly.
1735--- @return integer # Channel id, or 0 on error
1736function vim.api.nvim_open_term(buf, opts) end
1737
1738--- Opens a new split window, floating window, or external window.
1739---
1740--- - Specify `relative` to create a floating window. Floats are drawn over the split layout,
1741---   relative to a position in some other window. See `api-floatwin`.
1742---   - Floats must specify `width` and `height`.
1743--- - Specify `external` to create an external window. External windows are displayed as separate
1744---   top-level windows managed by the `ui-multigrid` UI (not Nvim).
1745--- - If `relative` and `external` are omitted, a normal "split" window is created.
1746---   - The `win` key decides which window to split. If nil or 0, the split will be adjacent to
1747---     the current window. If -1, a top-level split will be created.
1748---   - Use `vertical` and `split` to control split direction. For `vertical`, the exact direction
1749---     is determined by 'splitright' and 'splitbelow'.
1750---   - Split windows cannot have `bufpos`, `row`, `col`, `border`, `title`, `footer`.
1751---
1752--- With relative=editor (row=0,col=0) refers to the top-left corner of the
1753--- screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right
1754--- corner. Fractional values are allowed, but the builtin implementation
1755--- (used by non-multigrid UIs) will always round down to nearest integer.
1756---
1757--- Out-of-bounds values, and configurations that make the float not fit inside
1758--- the main editor, are allowed. The builtin implementation truncates values
1759--- so floats are fully within the main screen grid. External GUIs
1760--- could let floats hover outside of the main window like a tooltip, but
1761--- this should not be used to specify arbitrary WM screen positions.
1762---
1763--- Examples:
1764---
1765--- ```lua
1766--- -- Window-relative float with 'statusline' enabled:
1767--- local w1 = vim.api.nvim_open_win(0, false,
1768---   {relative='win', row=3, col=3, width=40, height=4})
1769--- vim.wo[w1].statusline = vim.o.statusline
1770---
1771--- -- Buffer-relative float (travels as buffer is scrolled):
1772--- vim.api.nvim_open_win(0, false,
1773---   {relative='win', width=40, height=4, bufpos={100,10}})
1774---
1775--- -- Vertical split left of the current window:
1776--- vim.api.nvim_open_win(0, false, { split = 'left', win = 0, })
1777--- ```
1778---
1779--- @param buf integer Buffer to display, or 0 for current buffer
1780--- @param enter boolean Enter the window (make it the current window)
1781--- @param config vim.api.keyset.win_config Map defining the window configuration. Keys:
1782--- - anchor: Decides which corner of the float to place at (row,col):
1783---    - "NW" northwest (default)
1784---    - "NE" northeast
1785---    - "SW" southwest
1786---    - "SE" southeast
1787--- - border: (`string|string[]`, default: 'winborder' option) Window border. The string form
1788---   accepts the same values as the 'winborder' option. The array form must have a length of
1789---   eight or any divisor of eight, specifying the chars that form the border in a clockwise
1790---   fashion starting from the top-left corner. For example, the double-box style can be
1791---   specified as:
1792---   ```
1793---   [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ].
1794---   ```
1795---   If fewer than eight chars are given, they will be repeated. An ASCII border could be
1796---   specified as:
1797---   ```
1798---   [ "/", "-", \"\\\\\", "|" ],
1799---   ```
1800---   Or one char for all sides:
1801---   ```
1802---   [ "x" ].
1803---   ```
1804---   Empty string can be used to hide a specific border. This example will show only vertical
1805---   borders, not horizontal:
1806---   ```
1807---   [ "", "", "", ">", "", "", "", "<" ]
1808---   ```
1809---   By default, `hl-FloatBorder` highlight is used, which links to `hl-WinSeparator` when not
1810---   defined. Each border side can specify an optional highlight:
1811---   ```
1812---   [ ["+", "MyCorner"], ["x", "MyBorder"] ].
1813---   ```
1814--- - bufpos: Places float relative to buffer text (only when
1815---     relative="win"). Takes a tuple of zero-indexed `[line, column]`.
1816---     `row` and `col` if given are applied relative to this
1817---     position, else they default to:
1818---     - `row=1` and `col=0` if `anchor` is "NW" or "NE"
1819---     - `row=0` and `col=0` if `anchor` is "SW" or "SE"
1820---       (thus like a tooltip near the buffer text).
1821--- - col: Column position in units of screen cell width, may be fractional.
1822--- - external: GUI should display the window as an external
1823---     top-level window. Currently accepts no other positioning
1824---     configuration together with this.
1825--- - fixed: If true when anchor is NW or SW, the float window
1826---          would be kept fixed even if the window would be truncated.
1827--- - focusable: (default: true) Enable focus by user actions (wincmds, mouse events).
1828---   Non-`focusable` windows can be entered by `nvim_set_current_win()`, or by mouse events if
1829---   `mouse=true`.
1830--- - footer: (`string|string[]?`) Footer in window border: string or list of `[text, highlight]`
1831---   tuples. Default highlight group is `FloatFooter`.
1832--- - footer_pos: (default: "left") Footer position. One of: "left", "center", "right". The
1833---  `footer` field must be set also.
1834--- - height: Window height (in character cells). Minimum of 1.
1835--- - hide: Hides the floating window. `window-hidden`
1836--- - mouse: (default: `focusable` value) If true, mouse events interact with the window
1837---   normally; if false, they pass through to the window behind it.
1838--- - noautocmd: Block all autocommands for the duration of the call. Cannot be changed by
1839---   `nvim_win_set_config()`.
1840--- - relative: Sets the window layout to "floating", placed at (row,col) coordinates relative to:
1841---    - "cursor"     Cursor position in current window.
1842---    - "editor"     The global editor grid.
1843---    - "laststatus" 'laststatus' if present, or last row.
1844---    - "mouse"      Mouse position.
1845---    - "tabline"    Tabline if present, or first row.
1846---    - "win"        Window given by the `win` field, or current window.
1847--- - row: Row position in units of "screen cell height", may be fractional.
1848--- - split: Split direction: "left", "right", "above", "below".
1849--- - style: (optional) Configure the appearance of the window:
1850---     - ""         No special style.
1851---     - "minimal"  Nvim will display the window with many UI options
1852---                  disabled. This is useful when displaying a temporary
1853---                  float where the text should not be edited. Disables
1854---                  'number', 'relativenumber', 'cursorline', 'cursorcolumn',
1855---                  'foldcolumn', 'spell' and 'list' options. 'signcolumn'
1856---                  is changed to `auto` and 'colorcolumn' is cleared.
1857---                  'statuscolumn' is changed to empty. The end-of-buffer
1858---                   region is hidden by setting `eob` flag of
1859---                  'fillchars' to a space char, and clearing the
1860---                  `hl-EndOfBuffer` region in 'winhighlight'.
1861--- - title: (optional) Title in window border, string or list.
1862---     List should consist of `[text, highlight]` tuples.
1863---     If string, or a tuple lacks a highlight, the default highlight group is `FloatTitle`.
1864--- - title_pos: (default: "left") Title position. One of: "left", "center", "right". The `title`
1865---   field must be set also.
1866--- - vertical: Split vertically `:vertical`.
1867--- - width: Window width (in character cells). Minimum of 1.
1868--- - win: `window-ID` target window. Can be in a different tab page. Determines the window to
1869---     split (negative values act like `:topleft`, `:botright`), the relative window for a
1870---     `relative="win"` float, or just the target tab page (inferred from the window) for others.
1871--- - zindex: (positive integer, default: 50) Stacking order. Floats with higher `zindex` overlay
1872---   floats with lower indices. Below 100 is recommended, unless there is a good reason to
1873---   overshadow builtin elements. The cursor is dimmed if an unfocused float above the cursor
1874---   exceeds the zindex of the current window by 50. These screen elements have hard-coded
1875---   z-indices:
1876---     - 100: `ins-completion-menu` popupmenu
1877---     - 200: message scrollback (`pager`)
1878---     - 250: `cmdline-completion` popupmenu (wildoptions=pum)
1879--- - _cmdline_offset: (EXPERIMENTAL) When provided, anchor the `cmdline-completion`
1880---   popupmenu to this window, with an offset in screen cell width.
1881--- @return integer # |window-ID|, or 0 on error
1882function vim.api.nvim_open_win(buf, enter, config) end
1883
1884--- @deprecated
1885--- @param str string
1886function vim.api.nvim_out_write(str) end
1887
1888--- Parse command line.
1889---
1890--- Doesn't check the validity of command arguments.
1891---
1892--- @param str string Command line string to parse. Cannot contain "\n".
1893--- @param opts vim.api.keyset.empty? Optional parameters. Reserved for future use.
1894--- @return vim.api.keyset.cmd_ret # Dict containing command information, with these keys:
1895--- - cmd: (string) Command name.
1896--- - range: (array) (optional) Command range ([<line1>] [<line2>]).
1897---                  Omitted if command doesn't accept a range.
1898---                  Otherwise, has no elements if no range was specified, one element if
1899---                  only a single range item was specified, or two elements if both range
1900---                  items were specified.
1901--- - count: (number) (optional) Command [<count>].
1902---                   Omitted if command cannot take a count.
1903--- - reg: (string) (optional) Command [<register>].
1904---                 Omitted if command cannot take a register.
1905--- - bang: (boolean) Whether command contains a [<bang>] (!) modifier.
1906--- - args: (array) Command arguments.
1907--- - addr: (string) Value of |:command-addr|. Uses short name or "line" for -addr=lines.
1908--- - nargs: (string) Value of |:command-nargs|.
1909--- - nextcmd: (string) Next command if there are multiple commands separated by a |:bar|.
1910---                     Empty if there isn't a next command.
1911--- - magic: (dict) Which characters have special meaning in the command arguments.
1912---     - file: (boolean) The command expands filenames. Which means characters such as "%",
1913---                       "#" and wildcards are expanded.
1914---     - bar: (boolean) The "|" character is treated as a command separator and the double
1915---                      quote character (") is treated as the start of a comment.
1916--- - mods: (dict) |:command-modifiers|.
1917---     - filter: (dict) |:filter|.
1918---         - pattern: (string) Filter pattern. Empty string if there is no filter.
1919---         - force: (boolean) Whether filter is inverted or not.
1920---     - silent: (boolean) |:silent|.
1921---     - emsg_silent: (boolean) |:silent!|.
1922---     - unsilent: (boolean) |:unsilent|.
1923---     - sandbox: (boolean) |:sandbox|.
1924---     - noautocmd: (boolean) |:noautocmd|.
1925---     - browse: (boolean) |:browse|.
1926---     - confirm: (boolean) |:confirm|.
1927---     - hide: (boolean) |:hide|.
1928---     - horizontal: (boolean) |:horizontal|.
1929---     - keepalt: (boolean) |:keepalt|.
1930---     - keepjumps: (boolean) |:keepjumps|.
1931---     - keepmarks: (boolean) |:keepmarks|.
1932---     - keeppatterns: (boolean) |:keeppatterns|.
1933---     - lockmarks: (boolean) |:lockmarks|.
1934---     - noswapfile: (boolean) |:noswapfile|.
1935---     - tab: (integer) |:tab|. -1 when omitted.
1936---     - verbose: (integer) |:verbose|. -1 when omitted.
1937---     - vertical: (boolean) |:vertical|.
1938---     - split: (string) Split modifier string, is an empty string when there's no split
1939---                       modifier. If there is a split modifier it can be one of:
1940---       - "aboveleft": |:aboveleft|.
1941---       - "belowright": |:belowright|.
1942---       - "topleft": |:topleft|.
1943---       - "botright": |:botright|.
1944function vim.api.nvim_parse_cmd(str, opts) end
1945
1946--- Parse a Vimscript expression.
1947---
1948--- @param expr string Expression to parse. Always treated as a single line.
1949--- @param flags string Flags:
1950--- - "E" if EOC tokens are not allowed (determines whether
1951---   they will stop parsing process or be recognized as an
1952---   operator/space, though also yielding an error).
1953--- - "l" when needing to start parsing with lvalues for
1954---   ":let" or ":for".
1955--- - "m" if multiple expressions in a row are allowed (only
1956---   the first one will be parsed),
1957--- - Common flag sets:
1958---   - "E" to parse like for `"<C-r>="`.
1959---   - "lm" to parse for ":let".
1960---   - "m" to parse like for `":echo"`.
1961---   - empty string for ":call".
1962--- @param hl boolean If true, return value will also include "highlight"
1963--- key containing array of 4-tuples (arrays) (Integer,
1964--- Integer, Integer, String), where first three numbers
1965--- define the highlighted region and represent line,
1966--- starting column and ending column (latter exclusive:
1967--- one should highlight region [start_col, end_col)).
1968--- @return table<string,any> #
1969--- - AST: top-level dict with these keys:
1970---   - "error": Dict with error, present only if parser saw some
1971---            error. Contains the following keys:
1972---     - "message": String, error message in printf format, translated.
1973---                  Must contain exactly one `%.*s`.
1974---     - "arg": String, error message argument.
1975---   - "len": Amount of bytes successfully parsed. With flags equal to ""
1976---            that should be equal to the length of expr string.
1977---            ("Successfully parsed" here means "participated in AST
1978---             creation", not "till the first error".)
1979---   - "ast": AST, either nil or a dict with these keys:
1980---     - "type": node type, one of the value names from ExprASTNodeType
1981---               stringified without "kExprNode" prefix.
1982---     - "start": a pair `[line, column]` describing where node is "started"
1983---                where "line" is always 0 (will not be 0 if you will be
1984---                using this API on e.g. ":let", but that is not
1985---                present yet). Both elements are Integers.
1986---     - "len": “length” of the node. This and "start" are there for
1987---              debugging purposes primary (debugging parser and providing
1988---              debug information).
1989---     - "children": a list of nodes described in top/"ast". There always
1990---                   is zero, one or two children, key will not be present
1991---                   if node has no children. Maximum number of children
1992---                   may be found in node_maxchildren array.
1993--- - Local values (present only for certain nodes):
1994---   - "scope": a single Integer, specifies scope for "Option" and
1995---              "PlainIdentifier" nodes. For "Option" it is one of
1996---              ExprOptScope values, for "PlainIdentifier" it is one of
1997---              ExprVarScope values.
1998---   - "ident": identifier (without scope, if any), present for "Option",
1999---              "PlainIdentifier", "PlainKey" and "Environment" nodes.
2000---   - "name": Integer, register name (one character) or -1. Only present
2001---           for "Register" nodes.
2002---   - "cmp_type": String, comparison type, one of the value names from
2003---                 ExprComparisonType, stringified without "kExprCmp"
2004---                 prefix. Only present for "Comparison" nodes.
2005---   - "ccs_strategy": String, case comparison strategy, one of the
2006---                     value names from ExprCaseCompareStrategy,
2007---                     stringified without "kCCStrategy" prefix. Only
2008---                     present for "Comparison" nodes.
2009---   - "augmentation": String, augmentation type for "Assignment" nodes.
2010---                     Is either an empty string, "Add", "Subtract" or
2011---                     "Concat" for "=", "+=", "-=" or ".=" respectively.
2012---   - "invert": Boolean, true if result of comparison needs to be
2013---               inverted. Only present for "Comparison" nodes.
2014---   - "ivalue": Integer, integer value for "Integer" nodes.
2015---   - "fvalue": Float, floating-point value for "Float" nodes.
2016---   - "svalue": String, value for "SingleQuotedString" and
2017---               "DoubleQuotedString" nodes.
2018function vim.api.nvim_parse_expression(expr, flags, hl) end
2019
2020--- Pastes at cursor (in any mode), and sets "redo" so dot (`.`) will repeat the input. UIs call
2021--- this to implement "paste", but it's also intended for use by scripts to input large,
2022--- dot-repeatable blocks of text (as opposed to `nvim_input()` which is subject to mappings/events
2023--- and is thus much slower).
2024---
2025--- Invokes the `vim.paste()` handler, which handles each mode appropriately.
2026---
2027--- Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err` but do not affect the
2028--- return value (which is strictly decided by `vim.paste()`).  On error or cancel, subsequent calls
2029--- are ignored ("drained") until the next paste is initiated (phase 1 or -1).
2030---
2031--- Useful in mappings and scripts to insert multiline text. Example:
2032---
2033--- ```lua
2034--- vim.keymap.set('n', 'x', function()
2035---   vim.api.nvim_paste([[
2036---     line1
2037---     line2
2038---     line3
2039---   ]], false, -1)
2040--- end, { buf = 0 })
2041--- ```
2042---
2043--- @param data string Multiline input. Lines break at LF ("\n"). May be binary (containing NUL bytes).
2044--- @param crlf boolean Also break lines at CR and CRLF.
2045--- @param phase integer -1: paste in a single call (i.e. without streaming).
2046--- To "stream" a paste, call `nvim_paste` sequentially with
2047--- these `phase` values:
2048---   - 1: starts the paste (exactly once)
2049---   - 2: continues the paste (zero or more times)
2050---   - 3: ends the paste (exactly once)
2051--- @return boolean #
2052--- - true: Client may continue pasting.
2053--- - false: Client should cancel the paste.
2054function vim.api.nvim_paste(data, crlf, phase) end
2055
2056--- Puts text at cursor, in any mode. For dot-repeatable input, use `nvim_paste()`.
2057---
2058--- Compare `:put` and `p` which are always linewise.
2059---
2060--- @param lines string[] `readfile()`-style list of lines. `channel-lines`
2061--- @param type string Edit behavior: any `getregtype()` result, or:
2062--- - "b" `blockwise-visual` mode (may include width, e.g. "b3")
2063--- - "c" `charwise` mode
2064--- - "l" `linewise` mode
2065--- - ""  guess by contents, see `setreg()`
2066--- @param after boolean If true insert after cursor (like `p`), or before (like `P`).
2067--- @param follow boolean If true place cursor at end of inserted text.
2068function vim.api.nvim_put(lines, type, after, follow) end
2069
2070--- Converts terminal codes and `keycodes` ([<CR>], [<Esc>], …) in a key sequence, to the internal
2071--- representation. See also Lua `vim.keycode()`.
2072---
2073---
2074--- @see replace_termcodes
2075--- @see cpoptions
2076--- @param str string String to be converted.
2077--- @param from_part boolean Legacy Vim parameter. Usually true.
2078--- @param do_lt boolean Also translate [<lt>]. Ignored if `special` is false.
2079--- @param special boolean Replace `keycodes`, e.g. [<CR>] becomes a "\r" char.
2080--- @return string
2081function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end
2082
2083--- Selects an item in the completion popup menu.
2084---
2085--- If neither `ins-completion` nor `cmdline-completion` popup menu is active
2086--- this API call is silently ignored.
2087--- Useful for an external UI using `ui-popupmenu` to control the popup menu with the mouse.
2088--- Can also be used in a mapping; use [<Cmd>] `:map-cmd` or a Lua mapping to ensure the mapping
2089--- doesn't end completion mode.
2090---
2091--- @param item integer Index (zero-based) of the item to select. Value of -1 selects nothing
2092--- and restores the original text.
2093--- @param insert boolean For `ins-completion`, whether the selection should be inserted in the buffer.
2094--- Ignored for `cmdline-completion`.
2095--- @param finish boolean Finish the completion and dismiss the popup menu. Implies {insert}.
2096--- @param opts vim.api.keyset.empty? Optional parameters. Reserved for future use.
2097function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end
2098
2099--- Sets the current window's buffer to `buf`.
2100---
2101--- @param buf integer Buffer id
2102function vim.api.nvim_set_current_buf(buf) end
2103
2104--- Changes the global working directory.
2105---
2106--- @param dir string Directory path
2107function vim.api.nvim_set_current_dir(dir) end
2108
2109--- Sets the text on the current line.
2110---
2111--- @param line string Line contents
2112function vim.api.nvim_set_current_line(line) end
2113
2114--- Sets the current tabpage.
2115---
2116--- @param tabpage integer `tab-ID` to focus
2117function vim.api.nvim_set_current_tabpage(tabpage) end
2118
2119--- Navigates to the given window (and tabpage, implicitly).
2120---
2121--- @param win integer `window-ID` to focus
2122function vim.api.nvim_set_current_win(win) end
2123
2124--- Set or change decoration provider for a `namespace`
2125---
2126--- This is a very general purpose interface for having Lua callbacks
2127--- being triggered during the redraw code.
2128---
2129--- The expected usage is to set `extmarks` for the currently
2130--- redrawn buffer. `nvim_buf_set_extmark()` can be called to add marks
2131--- on a per-window or per-lines basis. Use the `ephemeral` key to only
2132--- use the mark for the current screen redraw (the callback will be called
2133--- again for the next redraw).
2134---
2135--- Note: this function should not be called often. Rather, the callbacks
2136--- themselves can be used to throttle unneeded callbacks. the `on_start`
2137--- callback can return `false` to disable the provider until the next redraw.
2138--- Similarly, return `false` in `on_win` will skip the `on_line` and `on_range` calls
2139--- for that window (but any extmarks set in `on_win` will still be used).
2140--- A plugin managing multiple sources of decoration should ideally only set
2141--- one provider, and merge the sources internally. You can use multiple `ns_id`
2142--- for the extmarks set/modified inside the callback anyway.
2143---
2144--- Note: doing anything other than setting extmarks is considered experimental.
2145--- Doing things like changing options are not explicitly forbidden, but is
2146--- likely to have unexpected consequences (such as 100% CPU consumption).
2147--- Doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is quite dubious
2148--- for the moment.
2149---
2150--- Note: It is not allowed to remove or update extmarks in `on_line` or `on_range` callbacks.
2151---
2152--- Note: Callbacks will not run for `window-hidden`, as they are not redrawn.
2153---
2154--- @param ns_id integer `namespace` id
2155--- @param opts vim.api.keyset.set_decoration_provider? Table of callbacks:
2156--- - on_buf: called for each buffer being redrawn (once per edit,
2157---   before window callbacks)
2158---   ```
2159---     ["buf", bufnr, tick]
2160---   ```
2161--- - on_end: called at the end of a redraw cycle
2162---   ```
2163---     ["end", tick]
2164---   ```
2165--- - on_line: (deprecated, use on_range instead)
2166---   ```
2167---     ["line", winid, bufnr, row]
2168---   ```
2169--- - on_range: called for each buffer range being redrawn.
2170---   Range is end-exclusive and may span multiple lines. Range
2171---   bounds point to the first byte of a character. An end position
2172---   of the form (lnum, 0), including (number of lines, 0), is valid
2173---   and indicates that EOL of the preceding line is included.
2174---   ```
2175---     ["range", winid, bufnr, begin_row, begin_col, end_row, end_col]
2176---   ```
2177---
2178---   In addition to returning a boolean, it is also allowed to
2179---   return a `skip_row, skip_col` pair of integers. This implies
2180---   that this function does not need to be called until a range
2181---   which continues beyond the skipped position. A single integer
2182---   return value `skip_row` is short for `skip_row, 0`
2183---
2184--- - on_start: called first on each screen redraw
2185---   ```
2186---     ["start", tick]
2187---   ```
2188--- - on_win: called when starting to redraw a specific window.
2189---   ```
2190---     ["win", winid, bufnr, toprow, botrow]
2191---   ```
2192function vim.api.nvim_set_decoration_provider(ns_id, opts) end
2193
2194--- Sets a highlight group. By default, replaces the entire definition (e.g. `nvim_set_hl(0, 'Visual', {})`
2195--- will clear the "Visual" group), unless `update` is specified.
2196---
2197--- Note:
2198--- The fg and bg keys also accept the string values `"fg"` or `"bg"`
2199--- which act as aliases to the corresponding foreground and background
2200--- values of the Normal group. If the Normal group has not been defined,
2201--- using these values results in an error.
2202---
2203--- If `link` is used in combination with other attributes; only the
2204--- `link` will take effect (see |:hi-link|).
2205---
2206---
2207--- @param ns_id integer Namespace id for this highlight `nvim_create_namespace()`.
2208--- Use 0 to set a highlight group globally `:highlight`.
2209--- Highlights from non-global namespaces are not active by default, use
2210--- `nvim_set_hl_ns()` or `nvim_win_set_hl_ns()` to activate them.
2211--- @param name string Highlight group name, e.g. "ErrorMsg"
2212--- @param val vim.api.keyset.highlight Highlight definition map, accepts the following keys:
2213--- - altfont: boolean
2214--- - bg: color name or "#RRGGBB", see note.
2215--- - bg_indexed: boolean. If true, `bg` is an RGB approximation of `ctermbg`
2216---   (a palette index). UIs rendering cterm natively may prefer `ctermbg`.
2217--- - blend: integer between 0 and 100
2218--- - blink: boolean
2219--- - bold: boolean
2220--- - conceal: boolean Concealment at the UI level (terminal SGR), unrelated to `:syn-conceal`.
2221--- - cterm: cterm attribute map, like `highlight-args`. If not set, cterm attributes
2222---   will match those from the attribute map documented above.
2223--- - ctermbg: Sets background of cterm color `ctermbg`
2224--- - ctermfg: Sets foreground of cterm color `ctermfg`
2225--- - default: boolean Don't override existing definition `:hi-default`
2226--- - dim: boolean
2227--- - fg: Color name or "#RRGGBB", see note.
2228--- - fg_indexed: boolean. Same as `bg_indexed`, for `fg` and `ctermfg`.
2229--- - font: GUI font name (string). Sets `highlight-font`. Use "NONE" to clear.
2230--- - force: (boolean, default: false) Update the highlight group even if it already exists.
2231--- - italic: boolean
2232--- - link: Name of highlight group to link to. `:hi-link`
2233--- - link_global: Like "link", but always resolved in the global namespace (ns=0).
2234--- - nocombine: boolean
2235--- - overline: boolean
2236--- - reverse: boolean
2237--- - sp: Color name or "#RRGGBB"
2238--- - standout: boolean
2239--- - strikethrough: boolean
2240--- - undercurl: boolean
2241--- - underdashed: boolean
2242--- - underdotted: boolean
2243--- - underdouble: boolean
2244--- - underline: boolean
2245--- - update: (boolean, default: false) Update specified attributes only, leave others unchanged.
2246function vim.api.nvim_set_hl(ns_id, name, val) end
2247
2248--- Set active namespace for highlights defined with `nvim_set_hl()`. This can be set for
2249--- a single window, see `nvim_win_set_hl_ns()`.
2250---
2251--- @param ns_id integer the namespace to use
2252function vim.api.nvim_set_hl_ns(ns_id) end
2253
2254--- Set active namespace for highlights defined with `nvim_set_hl()` while redrawing.
2255---
2256--- This function is meant to be called while redrawing, primarily from
2257--- `nvim_set_decoration_provider()` on_win and on_line callbacks, which
2258--- are allowed to change the namespace during a redraw cycle.
2259---
2260--- @param ns_id integer the namespace to activate
2261function vim.api.nvim_set_hl_ns_fast(ns_id) end
2262
2263--- Sets a global `mapping` for the given mode.
2264---
2265--- To set a buffer-local mapping, use `nvim_buf_set_keymap()`.
2266---
2267--- Unlike `:map`, leading/trailing whitespace is accepted as part of the {lhs} or {rhs}.
2268--- Empty {rhs} is [<Nop>]. `keycodes` are replaced as usual.
2269---
2270--- Example:
2271---
2272--- ```vim
2273--- call nvim_set_keymap('n', ' <NL>', '', {'nowait': v:true})
2274--- ```
2275---
2276--- is equivalent to:
2277---
2278--- ```vim
2279--- nmap <nowait> <Space><NL> <Nop>
2280--- ```
2281---
2282--- @param mode string Mode short-name (map command prefix: "n", "i", "v", "x", …)
2283--- or "!" for `:map!`, or empty string for `:map`.
2284--- "ia", "ca" or "!a" for abbreviation in Insert mode, Cmdline mode, or both, respectively
2285--- @param lhs string Left-hand-side `{lhs}` of the mapping.
2286--- @param rhs string Right-hand-side `{rhs}` of the mapping.
2287--- @param opts vim.api.keyset.keymap? Optional parameters map: Accepts all `:map-arguments` as keys except [<buffer>],
2288--- values are booleans (default false). Also:
2289--- - "callback" Lua function called in place of {rhs}.
2290--- - "desc" human-readable description.
2291--- - "noremap" disables `recursive_mapping`, like `:noremap`
2292--- - "replace_keycodes" (boolean) When "expr" is true, replace keycodes in the
2293---   resulting string (see `nvim_replace_termcodes()`). Returning nil from the Lua
2294---   "callback" is equivalent to returning an empty string.
2295function vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end
2296
2297--- @deprecated
2298--- @param name string
2299--- @param value any
2300function vim.api.nvim_set_option(name, value) end
2301
2302--- Sets the value of an option. The behavior of this function matches that of
2303--- `:set`: for global-local options, both the global and local value are set
2304--- unless otherwise specified with {scope}.
2305---
2306--- Note the options {win} and {buf} cannot be used together.
2307---
2308--- @param name string Option name
2309--- @param value any New option value
2310--- @param opts vim.api.keyset.option? Optional parameters
2311--- - buf: Buffer number. Used for setting buffer local option.
2312--- - dry_run: (`boolean?`, default: false) If true, validates the
2313---   option value without setting it.
2314--- - operation: One of "set", "append", "prepend", or "remove".
2315---   Corresponds to `:set=`, `:set+=`, `:set^=`, and `:set-=`.
2316---   Default is "set".
2317--- - scope: One of "global" or "local". Analogous to
2318--- `:setglobal` and `:setlocal`, respectively.
2319--- - tab: `tab-ID` for tab-local options (currently only 'cmdheight'). Tabpage 0
2320---   means the current tabpage. If a non-current tab is given, the value will take
2321---   effect when it is switched-to.
2322--- - win: `window-ID`. Used for setting window local option.
2323--- @return any # Option value
2324function vim.api.nvim_set_option_value(name, value, opts) end
2325
2326--- Sets a global (g:) variable.
2327---
2328--- @param name string Variable name
2329--- @param value any Variable value
2330function vim.api.nvim_set_var(name, value) end
2331
2332--- Sets a v: variable, if it is not readonly.
2333---
2334--- @param name string Variable name
2335--- @param value any Variable value
2336function vim.api.nvim_set_vvar(name, value) end
2337
2338--- Calculates the number of display cells occupied by `text`.
2339--- Control characters including [<Tab>] count as one cell.
2340---
2341--- @param text string Some text
2342--- @return integer # Number of cells
2343function vim.api.nvim_strwidth(text) end
2344
2345--- Removes a tab-scoped (t:) variable
2346---
2347--- @param tabpage integer `tab-ID`, or 0 for current tabpage
2348--- @param name string Variable name
2349function vim.api.nvim_tabpage_del_var(tabpage, name) end
2350
2351--- Gets the tabpage number
2352---
2353--- @param tabpage integer `tab-ID`, or 0 for current tabpage
2354--- @return integer # Tabpage number
2355function vim.api.nvim_tabpage_get_number(tabpage) end
2356
2357--- Gets a tab-scoped (t:) variable
2358---
2359--- @param tabpage integer `tab-ID`, or 0 for current tabpage
2360--- @param name string Variable name
2361--- @return any # Variable value
2362function vim.api.nvim_tabpage_get_var(tabpage, name) end
2363
2364--- Gets the current window in a tabpage
2365---
2366--- @param tabpage integer `tab-ID`, or 0 for current tabpage
2367--- @return integer # |window-ID|
2368function vim.api.nvim_tabpage_get_win(tabpage) end
2369
2370--- Checks if a tabpage is valid
2371---
2372--- @param tabpage integer `tab-ID`, or 0 for current tabpage
2373--- @return boolean # true if the tabpage is valid, false otherwise
2374function vim.api.nvim_tabpage_is_valid(tabpage) end
2375
2376--- Gets the windows in a tabpage
2377---
2378--- @param tabpage integer `tab-ID`, or 0 for current tabpage
2379--- @return integer[] # List of windows in `tabpage`
2380function vim.api.nvim_tabpage_list_wins(tabpage) end
2381
2382--- Sets a tab-scoped (t:) variable
2383---
2384--- @param tabpage integer `tab-ID`, or 0 for current tabpage
2385--- @param name string Variable name
2386--- @param value any Variable value
2387function vim.api.nvim_tabpage_set_var(tabpage, name, value) end
2388
2389--- Sets the current window in a tabpage
2390---
2391--- @param tabpage integer `tab-ID`, or 0 for current tabpage
2392--- @param win integer `window-ID`, must already belong to {tabpage}
2393function vim.api.nvim_tabpage_set_win(tabpage, win) end
2394
2395--- Sends arbitrary data to a UI. Use this instead of `nvim_chan_send()` or `io.stdout:write()`, if
2396--- you really want to write to the `TUI` host terminal.
2397---
2398--- Emits a "ui_send" event to all UIs with the "stdout_tty" `ui-option` set. UIs are expected to
2399--- write the received data to a connected TTY if one exists.
2400---
2401--- @param content string Content to write to the TTY
2402function vim.api.nvim_ui_send(content) end
2403
2404--- Calls function `fn` in the context of window `win` and returns its result (may be multiple
2405--- values).
2406---
2407---
2408--- @see `:help win_execute()`
2409--- @see vim.api.nvim_buf_call
2410--- @param win integer `window-ID`, or 0 for current window.
2411--- @param fn function Lua function to call inside the window.
2412--- @return any # Value(s) returned by `fn()`.
2413function vim.api.nvim_win_call(win, fn) end
2414
2415--- Closes the window (like `:close` with a `window-ID`).
2416---
2417--- @param win integer `window-ID`, or 0 for current window
2418--- @param force boolean Behave like `:close!` The last window of a buffer with
2419--- unwritten changes can be closed. The buffer will become
2420--- hidden, even if 'hidden' is not set.
2421function vim.api.nvim_win_close(win, force) end
2422
2423--- Removes a window-scoped (w:) variable
2424---
2425--- @param win integer `window-ID`, or 0 for current window
2426--- @param name string Variable name
2427function vim.api.nvim_win_del_var(win, name) end
2428
2429--- Gets the current buffer in a window
2430---
2431--- @param win integer `window-ID`, or 0 for current window
2432--- @return integer # Buffer id
2433function vim.api.nvim_win_get_buf(win) end
2434
2435--- Gets window config as a dict which can be passed to `nvim_open_win()` as the `config` parameter.
2436---
2437--- For non-floating windows, `relative` is empty, thus you can check that field to detect if
2438--- a window is a floatwin:
2439--- ```lua
2440--- vim.print(vim.api.nvim_win_get_config(0).relative == '' and 'non-float' or 'float')
2441--- -- Or use win_gettype().
2442--- vim.print(vim.fn.win_gettype())
2443--- ```
2444---
2445--- @param win integer `window-ID`, or 0 for current window
2446--- @return vim.api.keyset.win_config_ret # Map defining the window configuration, see |nvim_open_win()|
2447function vim.api.nvim_win_get_config(win) end
2448
2449--- Gets the (1,0)-indexed, buffer-relative cursor position for a given window
2450--- (different windows showing the same buffer have independent cursor
2451--- positions). `api-indexing`
2452---
2453---
2454--- @see `:help getcurpos()`
2455--- @param win integer `window-ID`, or 0 for current window
2456--- @return [integer, integer] # (row, col) tuple
2457function vim.api.nvim_win_get_cursor(win) end
2458
2459--- Gets the window height
2460---
2461--- @param win integer `window-ID`, or 0 for current window
2462--- @return integer # Height as a count of rows
2463function vim.api.nvim_win_get_height(win) end
2464
2465--- Gets the window number
2466---
2467--- @param win integer `window-ID`, or 0 for current window
2468--- @return integer # Window number
2469function vim.api.nvim_win_get_number(win) end
2470
2471--- @deprecated
2472--- @param window integer
2473--- @param name string
2474--- @return any
2475function vim.api.nvim_win_get_option(window, name) end
2476
2477--- Gets the window position in display cells. First position is zero.
2478---
2479--- @param win integer `window-ID`, or 0 for current window
2480--- @return [integer, integer] # (row, col) tuple with the window position
2481function vim.api.nvim_win_get_position(win) end
2482
2483--- Gets the window tabpage
2484---
2485--- @param win integer `window-ID`, or 0 for current window
2486--- @return integer # Tabpage that contains the window
2487function vim.api.nvim_win_get_tabpage(win) end
2488
2489--- Gets a window-scoped (w:) variable
2490---
2491--- @param win integer `window-ID`, or 0 for current window
2492--- @param name string Variable name
2493--- @return any # Variable value
2494function vim.api.nvim_win_get_var(win, name) end
2495
2496--- Gets the window width
2497---
2498--- @param win integer `window-ID`, or 0 for current window
2499--- @return integer # Width as a count of columns
2500function vim.api.nvim_win_get_width(win) end
2501
2502--- Closes the window and hides the buffer it contains (like `:hide` with a `window-ID`; unrelated
2503--- to the `hide` flag of `nvim_open_win()`, `nvim_win_get_config()`).
2504---
2505--- Compare `:close` and `nvim_win_close()`, which close the buffer instead of hiding it.
2506---
2507--- @param win integer `window-ID`, or 0 for current window
2508function vim.api.nvim_win_hide(win) end
2509
2510--- Checks if a window is valid
2511---
2512--- @param win integer `window-ID`, or 0 for current window
2513--- @return boolean # true if the window is valid, false otherwise
2514function vim.api.nvim_win_is_valid(win) end
2515
2516--- Resizes a window, anchored to a given edge.
2517---
2518--- The window first takes space from the non-anchored side, and only then from the anchored side.
2519--- The "anchor" decides the fixed edge, so a window can grow or shrink in any direction.
2520---
2521--- Can set height, width (only for a vertical split), or both. The "anchor" applies to the matching
2522--- axis (top/bottom for height, left/right for width); the other axis uses its default anchor.
2523---
2524--- @param win integer `window-ID`, or 0 for current window
2525--- @param width integer New width (columns), or -1 for "no change".
2526--- @param height integer New height (rows), or -1 for "no change".
2527--- @param opts vim.api.keyset.win_resize? Optional parameters.
2528--- - anchor: Edge that stays fixed while the opposite edge moves; the
2529---   neighbor on the moving side is resized first. One of:
2530---   - "top" (default) or "bottom"
2531---   - "left" (default) or "right"
2532function vim.api.nvim_win_resize(win, width, height, opts) end
2533
2534--- Sets the current buffer in a window.
2535---
2536--- Note: As a side-effect, this executes `BufEnter` and `BufLeave` autocommands.
2537--- @param win integer `window-ID`, or 0 for current window
2538--- @param buf integer Buffer id
2539function vim.api.nvim_win_set_buf(win, buf) end
2540
2541--- Reconfigures the layout and properties of a window.
2542---
2543--- - Updates only the given keys; unspecified (`nil`) keys will not be changed.
2544--- - Can move a window to another tabpage.
2545--- - Can transform a window to/from a float.
2546--- - Keys `row` / `col` / `relative` must be specified together.
2547--- - Cannot move the last window in a tabpage to a different one.
2548---
2549--- Example: to convert a floating window to a "normal" split window, specify the `win` field:
2550---
2551--- ```lua
2552--- vim.api.nvim_win_set_config(0, { split = 'above', win = vim.fn.win_getid(1), })
2553--- ```
2554---
2555---
2556--- @see vim.api.nvim_open_win
2557--- @param win integer `window-ID`, or 0 for current window
2558--- @param config vim.api.keyset.win_config Map defining the window configuration, see [nvim_open_win()]
2559function vim.api.nvim_win_set_config(win, config) end
2560
2561--- Sets the (1,0)-indexed cursor position (byte offset) in the window. `api-indexing`
2562--- This scrolls the window even if it is not the current one.
2563---
2564--- @param win integer `window-ID`, or 0 for current window
2565--- @param pos [integer, integer] (row, col) tuple representing the new position
2566function vim.api.nvim_win_set_cursor(win, pos) end
2567
2568--- @deprecated
2569--- @param win integer
2570--- @param height integer
2571function vim.api.nvim_win_set_height(win, height) end
2572
2573--- Set highlight namespace for a window. This will use highlights defined with
2574--- `nvim_set_hl()` for this namespace, but fall back to global highlights (ns=0) when
2575--- missing.
2576---
2577--- This takes precedence over the 'winhighlight' option.
2578---
2579--- @param win integer
2580--- @param ns_id integer the namespace to use
2581function vim.api.nvim_win_set_hl_ns(win, ns_id) end
2582
2583--- @deprecated
2584--- @param window integer
2585--- @param name string
2586--- @param value any
2587function vim.api.nvim_win_set_option(window, name, value) end
2588
2589--- Sets a window-scoped (w:) variable
2590---
2591--- @param win integer `window-ID`, or 0 for current window
2592--- @param name string Variable name
2593--- @param value any Variable value
2594function vim.api.nvim_win_set_var(win, name, value) end
2595
2596--- @deprecated
2597--- @param win integer
2598--- @param width integer
2599function vim.api.nvim_win_set_width(win, width) end
2600
2601--- Computes the number of screen lines occupied by a range of text in a given window.
2602--- Works for off-screen text and takes folds into account.
2603---
2604--- Diff filler or virtual lines above a line are counted as a part of that line,
2605--- unless the line is on "start_row" and "start_vcol" is specified.
2606---
2607--- Diff filler or virtual lines below the last buffer line are counted in the result
2608--- when "end_row" is omitted.
2609---
2610--- Line indexing is similar to `nvim_buf_get_text()`.
2611---
2612--- @see `:help virtcol()` for text width.
2613--- @param win integer `window-ID`, or 0 for current window.
2614--- @param opts vim.api.keyset.win_text_height? Optional parameters:
2615--- - end_row: Ending line index, 0-based inclusive.
2616---            When omitted end at the very bottom.
2617--- - end_vcol: Ending virtual column index on "end_row",
2618---             0-based exclusive, rounded up to full screen lines.
2619---             When 0 only include diff filler and virtual lines above
2620---             "end_row". When omitted include the whole line.
2621--- - max_height: Don't add the height of lines below the row
2622---               for which this height is reached. Useful to e.g. limit the
2623---               height to the window height, avoiding unnecessary work. Or
2624---               to find out how many buffer lines beyond "start_row" take
2625---               up a certain number of logical lines (returned in
2626---               "end_row" and "end_vcol").
2627--- - start_row: Starting line index, 0-based inclusive.
2628---              When omitted start at the very top.
2629--- - start_vcol: Starting virtual column index on "start_row",
2630---               0-based inclusive, rounded down to full screen lines.
2631---               When omitted include the whole line.
2632--- @return vim.api.keyset.win_text_height_ret # Dict containing text height information, with these keys:
2633--- - all: The total number of screen lines occupied by the range.
2634--- - fill: The number of diff filler or virtual lines among them.
2635--- - end_row: The row on which the returned height is reached (first row of
2636---   a closed fold).
2637--- - end_vcol: Ending virtual column in "end_row" where "max_height" or the returned
2638---   height is reached. 0 if "end_row" is a closed fold.
2639---
2640function vim.api.nvim_win_text_height(win, opts) end