diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
commit | 931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch) | |
tree | d8c1843a95da5ea0bb4acc09f7e37843d9995c86 /runtime/lua/vim/_meta | |
parent | 142d9041391780ac15b89886a54015fdc5c73995 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-userreg.tar.gz rneovim-userreg.tar.bz2 rneovim-userreg.zip |
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'runtime/lua/vim/_meta')
-rw-r--r-- | runtime/lua/vim/_meta/api.lua | 2102 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/api_keysets.lua | 267 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/base64.lua | 13 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/builtin.lua | 289 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/builtin_types.lua | 129 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/diff.lua | 70 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/json.lua | 39 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/lpeg.lua | 323 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/misc.lua | 15 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/mpack.lua | 15 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/options.lua | 7958 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/regex.lua | 36 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/spell.lua | 32 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 10689 |
14 files changed, 21977 insertions, 0 deletions
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua new file mode 100644 index 0000000000..49269ba631 --- /dev/null +++ b/runtime/lua/vim/_meta/api.lua @@ -0,0 +1,2102 @@ +--- @meta _ +-- THIS FILE IS GENERATED +-- DO NOT EDIT +error('Cannot require a meta file') + +vim.api = {} + +--- @private +--- @param buffer integer +--- @param keys boolean +--- @param dot boolean +--- @return string +function vim.api.nvim__buf_debug_extmarks(buffer, keys, dot) end + +--- @private +--- @param buffer integer +--- @param first integer +--- @param last integer +function vim.api.nvim__buf_redraw_range(buffer, first, last) end + +--- @private +--- @param buffer integer +--- @return table<string,any> +function vim.api.nvim__buf_stats(buffer) end + +--- @private +--- @return string +function vim.api.nvim__get_lib_dir() end + +--- @private +--- Find files in runtime directories +--- +--- @param pat any[] pattern of files to search for +--- @param all boolean whether to return all matches or only the first +--- @param opts vim.api.keyset.runtime is_lua: only search Lua subdirs +--- @return string[] +function vim.api.nvim__get_runtime(pat, all, opts) end + +--- @private +--- Returns object given as argument. +--- This API function is used for testing. One should not rely on its presence +--- in plugins. +--- +--- @param obj any Object to return. +--- @return any +function vim.api.nvim__id(obj) end + +--- @private +--- Returns array given as argument. +--- This API function is used for testing. One should not rely on its presence +--- in plugins. +--- +--- @param arr any[] Array to return. +--- @return any[] +function vim.api.nvim__id_array(arr) end + +--- @private +--- Returns dictionary given as argument. +--- This API function is used for testing. One should not rely on its presence +--- in plugins. +--- +--- @param dct table<string,any> Dictionary to return. +--- @return table<string,any> +function vim.api.nvim__id_dictionary(dct) end + +--- @private +--- Returns floating-point value given as argument. +--- This API function is used for testing. One should not rely on its presence +--- in plugins. +--- +--- @param flt number Value to return. +--- @return number +function vim.api.nvim__id_float(flt) end + +--- @private +--- @param grid integer +--- @param row integer +--- @param col integer +--- @return any[] +function vim.api.nvim__inspect_cell(grid, row, col) end + +--- @private +--- For testing. The condition in schar_cache_clear_if_full is hard to reach, +--- so this function can be used to force a cache clear in a test. +--- +function vim.api.nvim__invalidate_glyph_cache() end + +--- @private +--- @return any[] +function vim.api.nvim__runtime_inspect() end + +--- @private +--- @param path string +function vim.api.nvim__screenshot(path) end + +--- @private +--- Gets internal stats. +--- +--- @return table<string,any> +function vim.api.nvim__stats() end + +--- @private +--- @param str string +--- @return any +function vim.api.nvim__unpack(str) end + +--- Adds a highlight to buffer. +--- Useful for plugins that dynamically generate highlights to a buffer (like +--- a semantic highlighter or linter). The function adds a single highlight to +--- a buffer. Unlike `matchaddpos()` highlights follow changes to line +--- numbering (as lines are inserted/removed above the highlighted line), like +--- signs and marks do. +--- Namespaces are used for batch deletion/updating of a set of highlights. To +--- create a namespace, use `nvim_create_namespace()` which returns a +--- namespace id. Pass it in to this function as `ns_id` to add highlights to +--- the namespace. All highlights in the same namespace can then be cleared +--- with single call to `nvim_buf_clear_namespace()`. If the highlight never +--- will be deleted by an API call, pass `ns_id = -1`. +--- As a shorthand, `ns_id = 0` can be used to create a new namespace for the +--- highlight, the allocated id is then returned. If `hl_group` is the empty +--- string no highlight is added, but a new `ns_id` is still returned. This is +--- supported for backwards compatibility, new code should use +--- `nvim_create_namespace()` to create a new empty namespace. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param ns_id integer namespace to use or -1 for ungrouped highlight +--- @param hl_group string Name of the highlight group to use +--- @param line integer Line to highlight (zero-indexed) +--- @param col_start integer Start of (byte-indexed) column range to highlight +--- @param col_end integer End of (byte-indexed) column range to highlight, or -1 to +--- highlight to end of line +--- @return integer +function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) end + +--- Activates buffer-update events on a channel, or as Lua callbacks. +--- Example (Lua): capture buffer updates in a global `events` variable (use +--- "vim.print(events)" to see its contents): +--- +--- ```lua +--- events = {} +--- vim.api.nvim_buf_attach(0, false, { +--- on_lines = function(...) +--- table.insert(events, {...}) +--- end, +--- }) +--- ``` +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param send_buffer boolean True if the initial notification should contain the +--- whole buffer: first notification will be +--- `nvim_buf_lines_event`. Else the first notification +--- will be `nvim_buf_changedtick_event`. Not for Lua +--- callbacks. +--- @param opts table<string,function> Optional parameters. +--- • on_lines: Lua callback invoked on change. Return `true` to detach. Args: +--- • the string "lines" +--- • buffer handle +--- • b:changedtick +--- • first line that changed (zero-indexed) +--- • last line that was changed +--- • last line in the updated range +--- • byte count of previous contents +--- • deleted_codepoints (if `utf_sizes` is true) +--- • deleted_codeunits (if `utf_sizes` is true) +--- +--- • on_bytes: Lua callback invoked on change. This +--- callback receives more granular information about the +--- change compared to on_lines. Return `true` to detach. Args: +--- • the string "bytes" +--- • buffer handle +--- • b:changedtick +--- • start row of the changed text (zero-indexed) +--- • start column of the changed text +--- • byte offset of the changed text (from the start of +--- the buffer) +--- • old end row of the changed text +--- • old end column of the changed text +--- • old end byte length of the changed text +--- • new end row of the changed text +--- • new end column of the changed text +--- • new end byte length of the changed text +--- +--- • on_changedtick: Lua callback invoked on changedtick +--- increment without text change. Args: +--- • the string "changedtick" +--- • buffer handle +--- • b:changedtick +--- +--- • on_detach: Lua callback invoked on detach. Args: +--- • the string "detach" +--- • buffer handle +--- +--- • on_reload: Lua callback invoked on reload. The entire +--- buffer content should be considered changed. Args: +--- • the string "reload" +--- • buffer handle +--- +--- • utf_sizes: include UTF-32 and UTF-16 size of the +--- replaced region, as args to `on_lines`. +--- • preview: also attach to command preview (i.e. +--- 'inccommand') events. +--- @return boolean +function vim.api.nvim_buf_attach(buffer, send_buffer, opts) end + +--- call a function with buffer as temporary current buffer +--- This temporarily switches current buffer to "buffer". If the current +--- window already shows "buffer", the window is not switched If a window +--- inside the current tabpage (including a float) already shows the buffer +--- One of these windows will be set as current window temporarily. Otherwise +--- a temporary scratch window (called the "autocmd window" for historical +--- reasons) will be used. +--- This is useful e.g. to call Vimscript functions that only work with the +--- current buffer/window currently, like `termopen()`. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param fun function Function to call inside the buffer (currently Lua callable +--- only) +--- @return any +function vim.api.nvim_buf_call(buffer, fun) end + +--- @deprecated +--- @param buffer integer +--- @param ns_id integer +--- @param line_start integer +--- @param line_end integer +function vim.api.nvim_buf_clear_highlight(buffer, ns_id, line_start, line_end) end + +--- Clears `namespace`d objects (highlights, `extmarks`, virtual text) from a +--- region. +--- Lines are 0-indexed. `api-indexing` To clear the namespace in the entire +--- buffer, specify line_start=0 and line_end=-1. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param ns_id integer Namespace to clear, or -1 to clear all namespaces. +--- @param line_start integer Start of range of lines to clear +--- @param line_end integer End of range of lines to clear (exclusive) or -1 to +--- clear to end of buffer. +function vim.api.nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) end + +--- Creates a buffer-local command `user-commands`. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer. +--- @param name string +--- @param command any +--- @param opts vim.api.keyset.user_command +function vim.api.nvim_buf_create_user_command(buffer, name, command, opts) end + +--- Removes an `extmark`. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param ns_id integer Namespace id from `nvim_create_namespace()` +--- @param id integer Extmark id +--- @return boolean +function vim.api.nvim_buf_del_extmark(buffer, ns_id, id) end + +--- Unmaps a buffer-local `mapping` for the given mode. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param mode string +--- @param lhs string +function vim.api.nvim_buf_del_keymap(buffer, mode, lhs) end + +--- Deletes a named mark in the buffer. See `mark-motions`. +--- +--- @param buffer integer Buffer to set the mark on +--- @param name string Mark name +--- @return boolean +function vim.api.nvim_buf_del_mark(buffer, name) end + +--- Delete a buffer-local user-defined command. +--- Only commands created with `:command-buffer` or +--- `nvim_buf_create_user_command()` can be deleted with this function. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer. +--- @param name string Name of the command to delete. +function vim.api.nvim_buf_del_user_command(buffer, name) end + +--- Removes a buffer-scoped (b:) variable +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param name string Variable name +function vim.api.nvim_buf_del_var(buffer, name) end + +--- Deletes the buffer. See `:bwipeout` +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param opts table<string,any> Optional parameters. Keys: +--- • force: Force deletion and ignore unsaved changes. +--- • unload: Unloaded only, do not delete. See `:bunload` +function vim.api.nvim_buf_delete(buffer, opts) end + +--- Gets a changed tick of a buffer +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @return integer +function vim.api.nvim_buf_get_changedtick(buffer) end + +--- Gets a map of buffer-local `user-commands`. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param opts vim.api.keyset.get_commands Optional parameters. Currently not used. +--- @return table<string,any> +function vim.api.nvim_buf_get_commands(buffer, opts) end + +--- Gets the position (0-indexed) of an `extmark`. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param ns_id integer Namespace id from `nvim_create_namespace()` +--- @param id integer Extmark id +--- @param opts table<string,any> Optional parameters. Keys: +--- • details: Whether to include the details dict +--- • hl_name: Whether to include highlight group name instead +--- of id, true if omitted +--- @return integer[] +function vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, id, opts) end + +--- Gets `extmarks` (including `signs`) in "traversal order" from a `charwise` +--- region defined by buffer positions (inclusive, 0-indexed `api-indexing`). +--- Region can be given as (row,col) tuples, or valid extmark ids (whose +--- positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1) +--- respectively, thus the following are equivalent: +--- +--- ```lua +--- vim.api.nvim_buf_get_extmarks(0, my_ns, 0, -1, {}) +--- vim.api.nvim_buf_get_extmarks(0, my_ns, {0,0}, {-1,-1}, {}) +--- ``` +--- +--- If `end` is less than `start`, traversal works backwards. (Useful with +--- `limit`, to get the first marks prior to a given position.) +--- Note: when using extmark ranges (marks with a end_row/end_col position) +--- the `overlap` option might be useful. Otherwise only the start position of +--- an extmark will be considered. +--- Example: +--- +--- ```lua +--- local api = vim.api +--- local pos = api.nvim_win_get_cursor(0) +--- local ns = api.nvim_create_namespace('my-plugin') +--- -- Create new extmark at line 1, column 1. +--- local m1 = api.nvim_buf_set_extmark(0, ns, 0, 0, {}) +--- -- Create new extmark at line 3, column 1. +--- local m2 = api.nvim_buf_set_extmark(0, ns, 2, 0, {}) +--- -- Get extmarks only from line 3. +--- local ms = api.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {}) +--- -- Get all marks in this buffer + namespace. +--- local all = api.nvim_buf_get_extmarks(0, ns, 0, -1, {}) +--- vim.print(ms) +--- ``` +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param ns_id integer Namespace id from `nvim_create_namespace()` or -1 for all +--- namespaces +--- @param start any Start of range: a 0-indexed (row, col) or valid extmark id +--- (whose position defines the bound). `api-indexing` +--- @param end_ any End of range (inclusive): a 0-indexed (row, col) or valid +--- extmark id (whose position defines the bound). +--- `api-indexing` +--- @param opts vim.api.keyset.get_extmarks Optional parameters. Keys: +--- • limit: Maximum number of marks to return +--- • details: Whether to include the details dict +--- • hl_name: Whether to include highlight group name instead +--- of id, true if omitted +--- • overlap: Also include marks which overlap the range, even +--- if their start position is less than `start` +--- • type: Filter marks by type: "highlight", "sign", +--- "virt_text" and "virt_lines" +--- @return any[] +function vim.api.nvim_buf_get_extmarks(buffer, ns_id, start, end_, opts) end + +--- Gets a list of buffer-local `mapping` definitions. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param mode string Mode short-name ("n", "i", "v", ...) +--- @return table<string,any>[] +function vim.api.nvim_buf_get_keymap(buffer, mode) end + +--- Gets a line-range from the buffer. +--- Indexing is zero-based, end-exclusive. Negative indices are interpreted as +--- length+1+index: -1 refers to the index past the end. So to get the last +--- element use start=-2 and end=-1. +--- Out-of-bounds indices are clamped to the nearest valid value, unless +--- `strict_indexing` is set. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param start integer First line index +--- @param end_ integer Last line index, exclusive +--- @param strict_indexing boolean Whether out-of-bounds should be an error. +--- @return string[] +function vim.api.nvim_buf_get_lines(buffer, start, end_, strict_indexing) end + +--- Returns a `(row,col)` tuple representing the position of the named mark. +--- "End of line" column position is returned as `v:maxcol` (big number). See +--- `mark-motions`. +--- Marks are (1,0)-indexed. `api-indexing` +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param name string Mark name +--- @return integer[] +function vim.api.nvim_buf_get_mark(buffer, name) end + +--- Gets the full file name for the buffer +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @return string +function vim.api.nvim_buf_get_name(buffer) end + +--- @deprecated +--- @param buffer integer +--- @return integer +function vim.api.nvim_buf_get_number(buffer) end + +--- Returns the byte offset of a line (0-indexed). `api-indexing` +--- Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte. +--- 'fileformat' and 'fileencoding' are ignored. The line index just after the +--- last line gives the total byte-count of the buffer. A final EOL byte is +--- counted if it would be written, see 'eol'. +--- Unlike `line2byte()`, throws error for out-of-bounds indexing. Returns -1 +--- for unloaded buffer. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param index integer Line index +--- @return integer +function vim.api.nvim_buf_get_offset(buffer, index) end + +--- @deprecated +--- @param buffer integer +--- @param name string +--- @return any +function vim.api.nvim_buf_get_option(buffer, name) end + +--- Gets a range from the buffer. +--- This differs from `nvim_buf_get_lines()` in that it allows retrieving only +--- portions of a line. +--- Indexing is zero-based. Row indices are end-inclusive, and column indices +--- are end-exclusive. +--- Prefer `nvim_buf_get_lines()` when retrieving entire lines. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param start_row integer First line index +--- @param start_col integer Starting column (byte offset) on first line +--- @param end_row integer Last line index, inclusive +--- @param end_col integer Ending column (byte offset) on last line, exclusive +--- @param opts table<string,any> Optional parameters. Currently unused. +--- @return string[] +function vim.api.nvim_buf_get_text(buffer, start_row, start_col, end_row, end_col, opts) end + +--- Gets a buffer-scoped (b:) variable. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param name string Variable name +--- @return any +function vim.api.nvim_buf_get_var(buffer, name) end + +--- Checks if a buffer is valid and loaded. See `api-buffer` for more info +--- about unloaded buffers. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @return boolean +function vim.api.nvim_buf_is_loaded(buffer) end + +--- Checks if a buffer is valid. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @return boolean +function vim.api.nvim_buf_is_valid(buffer) end + +--- Returns the number of lines in the given buffer. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @return integer +function vim.api.nvim_buf_line_count(buffer) end + +--- Creates or updates an `extmark`. +--- By default a new extmark is created when no id is passed in, but it is +--- also possible to create a new mark by passing in a previously unused id or +--- move an existing mark by passing in its id. The caller must then keep +--- track of existing and unused ids itself. (Useful over RPC, to avoid +--- waiting for the return value.) +--- Using the optional arguments, it is possible to use this to highlight a +--- range of text, and also to associate virtual text to the mark. +--- If present, the position defined by `end_col` and `end_row` should be +--- after the start position in order for the extmark to cover a range. An +--- earlier end position is not an error, but then it behaves like an empty +--- range (no highlighting). +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param ns_id integer Namespace id from `nvim_create_namespace()` +--- @param line integer Line where to place the mark, 0-based. `api-indexing` +--- @param col integer Column where to place the mark, 0-based. `api-indexing` +--- @param opts vim.api.keyset.set_extmark Optional parameters. +--- • id : id of the extmark to edit. +--- • end_row : ending line of the mark, 0-based inclusive. +--- • end_col : ending col of the mark, 0-based exclusive. +--- • hl_group : name of the highlight group used to highlight +--- this mark. +--- • hl_eol : when true, for a multiline highlight covering the +--- EOL of a line, continue the highlight for the rest of the +--- screen line (just like for diff and cursorline highlight). +--- • virt_text : virtual text to link to this mark. A list of +--- [text, highlight] tuples, each representing a text chunk +--- with specified highlight. `highlight` element can either +--- be a single highlight group, or an array of multiple +--- highlight groups that will be stacked (highest priority +--- last). A highlight group can be supplied either as a +--- string or as an integer, the latter which can be obtained +--- using `nvim_get_hl_id_by_name()`. +--- • virt_text_pos : position of virtual text. Possible values: +--- • "eol": right after eol character (default). +--- • "overlay": display over the specified column, without +--- shifting the underlying text. +--- • "right_align": display right aligned in the window. +--- • "inline": display at the specified column, and shift the +--- buffer text to the right as needed. +--- +--- • virt_text_win_col : position the virtual text at a fixed +--- window column (starting from the first text column of the +--- screen line) instead of "virt_text_pos". +--- • virt_text_hide : hide the virtual text when the background +--- text is selected or hidden because of scrolling with +--- 'nowrap' or 'smoothscroll'. Currently only affects +--- "overlay" virt_text. +--- • hl_mode : control how highlights are combined with the +--- highlights of the text. Currently only affects virt_text +--- highlights, but might affect `hl_group` in later versions. +--- • "replace": only show the virt_text color. This is the +--- default. +--- • "combine": combine with background text color. +--- • "blend": blend with background text color. Not supported +--- for "inline" virt_text. +--- +--- • virt_lines : virtual lines to add next to this mark This +--- should be an array over lines, where each line in turn is +--- an array over [text, highlight] tuples. In general, buffer +--- and window options do not affect the display of the text. +--- In particular 'wrap' and 'linebreak' options do not take +--- effect, so the number of extra screen lines will always +--- match the size of the array. However the 'tabstop' buffer +--- option is still used for hard tabs. By default lines are +--- placed below the buffer line containing the mark. +--- • virt_lines_above: place virtual lines above instead. +--- • virt_lines_leftcol: Place extmarks in the leftmost column +--- of the window, bypassing sign and number columns. +--- • ephemeral : for use with `nvim_set_decoration_provider()` +--- callbacks. The mark will only be used for the current +--- redraw cycle, and not be permantently stored in the +--- buffer. +--- • right_gravity : boolean that indicates the direction the +--- extmark will be shifted in when new text is inserted (true +--- for right, false for left). Defaults to true. +--- • end_right_gravity : boolean that indicates the direction +--- the extmark end position (if it exists) will be shifted in +--- when new text is inserted (true for right, false for +--- left). Defaults to false. +--- • undo_restore : Restore the exact position of the mark if +--- text around the mark was deleted and then restored by +--- undo. Defaults to true. +--- • invalidate : boolean that indicates whether to hide the +--- extmark if the entirety of its range is deleted. If +--- "undo_restore" is false, the extmark is deleted instead. +--- • priority: a priority value for the highlight group or sign +--- attribute. For example treesitter highlighting uses a +--- value of 100. +--- • strict: boolean that indicates extmark should not be +--- placed if the line or column value is past the end of the +--- buffer or end of the line respectively. Defaults to true. +--- • sign_text: string of length 1-2 used to display in the +--- sign column. Note: ranges are unsupported and decorations +--- are only applied to start_row +--- • sign_hl_group: name of the highlight group used to +--- highlight the sign column text. Note: ranges are +--- unsupported and decorations are only applied to start_row +--- • number_hl_group: name of the highlight group used to +--- highlight the number column. Note: ranges are unsupported +--- and decorations are only applied to start_row +--- • line_hl_group: name of the highlight group used to +--- highlight the whole line. Note: ranges are unsupported and +--- decorations are only applied to start_row +--- • cursorline_hl_group: name of the highlight group used to +--- highlight the line when the cursor is on the same line as +--- the mark and 'cursorline' is enabled. Note: ranges are +--- unsupported and decorations are only applied to start_row +--- • conceal: string which should be either empty or a single +--- character. Enable concealing similar to `:syn-conceal`. +--- When a character is supplied it is used as `:syn-cchar`. +--- "hl_group" is used as highlight for the cchar if provided, +--- otherwise it defaults to `hl-Conceal`. +--- • spell: boolean indicating that spell checking should be +--- performed within this extmark +--- • ui_watched: boolean that indicates the mark should be +--- drawn by a UI. When set, the UI will receive win_extmark +--- events. Note: the mark is positioned by virt_text +--- attributes. Can be used together with virt_text. +--- @return integer +function vim.api.nvim_buf_set_extmark(buffer, ns_id, line, col, opts) end + +--- Sets a buffer-local `mapping` for the given mode. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param mode string +--- @param lhs string +--- @param rhs string +--- @param opts vim.api.keyset.keymap +function vim.api.nvim_buf_set_keymap(buffer, mode, lhs, rhs, opts) end + +--- Sets (replaces) a line-range in the buffer. +--- Indexing is zero-based, end-exclusive. Negative indices are interpreted as +--- length+1+index: -1 refers to the index past the end. So to change or +--- delete the last element use start=-2 and end=-1. +--- To insert lines at a given index, set `start` and `end` to the same index. +--- To delete a range of lines, set `replacement` to an empty array. +--- Out-of-bounds indices are clamped to the nearest valid value, unless +--- `strict_indexing` is set. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param start integer First line index +--- @param end_ integer Last line index, exclusive +--- @param strict_indexing boolean Whether out-of-bounds should be an error. +--- @param replacement string[] Array of lines to use as replacement +function vim.api.nvim_buf_set_lines(buffer, start, end_, strict_indexing, replacement) end + +--- Sets a named mark in the given buffer, all marks are allowed +--- file/uppercase, visual, last change, etc. See `mark-motions`. +--- Marks are (1,0)-indexed. `api-indexing` +--- +--- @param buffer integer Buffer to set the mark on +--- @param name string Mark name +--- @param line integer Line number +--- @param col integer Column/row number +--- @param opts table<string,any> Optional parameters. Reserved for future use. +--- @return boolean +function vim.api.nvim_buf_set_mark(buffer, name, line, col, opts) end + +--- Sets the full file name for a buffer +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param name string Buffer name +function vim.api.nvim_buf_set_name(buffer, name) end + +--- @deprecated +--- @param buffer integer +--- @param name string +--- @param value any +function vim.api.nvim_buf_set_option(buffer, name, value) end + +--- Sets (replaces) a range in the buffer +--- This is recommended over `nvim_buf_set_lines()` when only modifying parts +--- of a line, as extmarks will be preserved on non-modified parts of the +--- touched lines. +--- Indexing is zero-based. Row indices are end-inclusive, and column indices +--- are end-exclusive. +--- To insert text at a given `(row, column)` location, use `start_row = +--- end_row = row` and `start_col = end_col = col`. To delete the text in a +--- range, use `replacement = {}`. +--- Prefer `nvim_buf_set_lines()` if you are only adding or deleting entire +--- lines. +--- Prefer `nvim_put()` if you want to insert text at the cursor position. +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param start_row integer First line index +--- @param start_col integer Starting column (byte offset) on first line +--- @param end_row integer Last line index, inclusive +--- @param end_col integer Ending column (byte offset) on last line, exclusive +--- @param replacement string[] Array of lines to use as replacement +function vim.api.nvim_buf_set_text(buffer, start_row, start_col, end_row, end_col, replacement) end + +--- Sets a buffer-scoped (b:) variable +--- +--- @param buffer integer Buffer handle, or 0 for current buffer +--- @param name string Variable name +--- @param value any Variable value +function vim.api.nvim_buf_set_var(buffer, name, value) end + +--- @deprecated +--- @param buffer integer +--- @param src_id integer +--- @param line integer +--- @param chunks any[] +--- @param opts table<string,any> +--- @return integer +function vim.api.nvim_buf_set_virtual_text(buffer, src_id, line, chunks, opts) end + +--- Calls a Vimscript `Dictionary-function` with the given arguments. +--- On execution error: fails with Vimscript error, updates v:errmsg. +--- +--- @param dict any Dictionary, or String evaluating to a Vimscript `self` dict +--- @param fn string Name of the function defined on the Vimscript dict +--- @param args any[] Function arguments packed in an Array +--- @return any +function vim.api.nvim_call_dict_function(dict, fn, args) end + +--- Calls a Vimscript function with the given arguments. +--- On execution error: fails with Vimscript error, updates v:errmsg. +--- +--- @param fn string Function to call +--- @param args any[] Function arguments packed in an Array +--- @return any +function vim.api.nvim_call_function(fn, args) end + +--- Send data to channel `id`. For a job, it writes it to the stdin of the +--- process. For the stdio channel `channel-stdio`, it writes to Nvim's +--- stdout. For an internal terminal instance (`nvim_open_term()`) it writes +--- directly to terminal output. See `channel-bytes` for more information. +--- This function writes raw data, not RPC messages. If the channel was +--- created with `rpc=true` then the channel expects RPC messages, use +--- `vim.rpcnotify()` and `vim.rpcrequest()` instead. +--- +--- @param chan integer id of the channel +--- @param data string data to write. 8-bit clean: can contain NUL bytes. +function vim.api.nvim_chan_send(chan, data) end + +--- Clears all autocommands selected by {opts}. To delete autocmds see +--- `nvim_del_autocmd()`. +--- +--- @param opts vim.api.keyset.clear_autocmds Parameters +--- • event: (string|table) Examples: +--- • event: "pat1" +--- • event: { "pat1" } +--- • event: { "pat1", "pat2", "pat3" } +--- +--- • pattern: (string|table) +--- • pattern or patterns to match exactly. +--- • For example, if you have `*.py` as that pattern for the +--- autocmd, you must pass `*.py` exactly to clear it. +--- `test.py` will not match the pattern. +--- +--- • defaults to clearing all patterns. +--- • NOTE: Cannot be used with {buffer} +--- +--- • buffer: (bufnr) +--- • clear only `autocmd-buflocal` autocommands. +--- • NOTE: Cannot be used with {pattern} +--- +--- • group: (string|int) The augroup name or id. +--- • NOTE: If not passed, will only delete autocmds not in any group. +function vim.api.nvim_clear_autocmds(opts) end + +--- Executes an Ex command. +--- Unlike `nvim_command()` this command takes a structured Dictionary instead +--- of a String. This allows for easier construction and manipulation of an Ex +--- command. This also allows for things such as having spaces inside a +--- command argument, expanding filenames in a command that otherwise doesn't +--- expand filenames, etc. Command arguments may also be Number, Boolean or +--- String. +--- The first argument may also be used instead of count for commands that +--- support it in order to make their usage simpler with `vim.cmd()`. For +--- example, instead of `vim.cmd.bdelete{ count = 2 }`, you may do +--- `vim.cmd.bdelete(2)`. +--- On execution error: fails with Vimscript error, updates v:errmsg. +--- +--- @param cmd vim.api.keyset.cmd Command to execute. Must be a Dictionary that can contain the +--- same values as the return value of `nvim_parse_cmd()` except +--- "addr", "nargs" and "nextcmd" which are ignored if provided. +--- All values except for "cmd" are optional. +--- @param opts vim.api.keyset.cmd_opts Optional parameters. +--- • output: (boolean, default false) Whether to return command +--- output. +--- @return string +function vim.api.nvim_cmd(cmd, opts) end + +--- Executes an Ex command. +--- On execution error: fails with Vimscript error, updates v:errmsg. +--- Prefer using `nvim_cmd()` or `nvim_exec2()` over this. To evaluate +--- multiple lines of Vim script or an Ex command directly, use +--- `nvim_exec2()`. To construct an Ex command using a structured format and +--- then execute it, use `nvim_cmd()`. To modify an Ex command before +--- evaluating it, use `nvim_parse_cmd()` in conjunction with `nvim_cmd()`. +--- +--- @param command string Ex command string +function vim.api.nvim_command(command) end + +--- @deprecated +--- @param command string +--- @return string +function vim.api.nvim_command_output(command) end + +--- Create or get an autocommand group `autocmd-groups`. +--- To get an existing group id, do: +--- +--- ```lua +--- local id = vim.api.nvim_create_augroup("MyGroup", { +--- clear = false +--- }) +--- ``` +--- +--- @param name string String: The name of the group +--- @param opts vim.api.keyset.create_augroup Dictionary Parameters +--- • clear (bool) optional: defaults to true. Clear existing +--- commands if the group already exists `autocmd-groups`. +--- @return integer +function vim.api.nvim_create_augroup(name, opts) end + +--- Creates an `autocommand` event handler, defined by `callback` (Lua function or Vimscript function name string) or `command` (Ex command string). +--- Example using Lua callback: +--- +--- ```lua +--- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { +--- pattern = {"*.c", "*.h"}, +--- callback = function(ev) +--- print(string.format('event fired: %s', vim.inspect(ev))) +--- end +--- }) +--- ``` +--- +--- Example using an Ex command as the handler: +--- +--- ```lua +--- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { +--- pattern = {"*.c", "*.h"}, +--- command = "echo 'Entering a C or C++ file'", +--- }) +--- ``` +--- +--- Note: `pattern` is NOT automatically expanded (unlike with `:autocmd`), +--- thus names like "$HOME" and "~" must be expanded explicitly: +--- +--- ```lua +--- pattern = vim.fn.expand("~") .. "/some/path/*.py" +--- ``` +--- +--- @param event any (string|array) Event(s) that will trigger the handler +--- (`callback` or `command`). +--- @param opts vim.api.keyset.create_autocmd Options dict: +--- • group (string|integer) optional: autocommand group name or +--- id to match against. +--- • pattern (string|array) optional: pattern(s) to match +--- literally `autocmd-pattern`. +--- • buffer (integer) optional: buffer number for buffer-local +--- autocommands `autocmd-buflocal`. Cannot be used with +--- {pattern}. +--- • desc (string) optional: description (for documentation and +--- troubleshooting). +--- • callback (function|string) optional: Lua function (or +--- Vimscript function name, if string) called when the +--- event(s) is triggered. Lua callback can return true to +--- delete the autocommand, and receives a table argument with +--- these keys: +--- • id: (number) autocommand id +--- • event: (string) name of the triggered event +--- `autocmd-events` +--- • group: (number|nil) autocommand group id, if any +--- • match: (string) expanded value of `<amatch>` +--- • buf: (number) expanded value of `<abuf>` +--- • file: (string) expanded value of `<afile>` +--- • data: (any) arbitrary data passed from +--- `nvim_exec_autocmds()` +--- +--- • command (string) optional: Vim command to execute on event. +--- Cannot be used with {callback} +--- • once (boolean) optional: defaults to false. Run the +--- autocommand only once `autocmd-once`. +--- • nested (boolean) optional: defaults to false. Run nested +--- autocommands `autocmd-nested`. +--- @return integer +function vim.api.nvim_create_autocmd(event, opts) end + +--- Creates a new, empty, unnamed buffer. +--- +--- @param listed boolean Sets 'buflisted' +--- @param scratch boolean Creates a "throwaway" `scratch-buffer` for temporary work +--- (always 'nomodified'). Also sets 'nomodeline' on the +--- buffer. +--- @return integer +function vim.api.nvim_create_buf(listed, scratch) end + +--- Creates a new namespace or gets an existing one. *namespace* +--- Namespaces are used for buffer highlights and virtual text, see +--- `nvim_buf_add_highlight()` and `nvim_buf_set_extmark()`. +--- Namespaces can be named or anonymous. If `name` matches an existing +--- namespace, the associated id is returned. If `name` is an empty string a +--- new, anonymous namespace is created. +--- +--- @param name string Namespace name or empty string +--- @return integer +function vim.api.nvim_create_namespace(name) end + +--- Creates a global `user-commands` command. +--- For Lua usage see `lua-guide-commands-create`. +--- Example: +--- +--- ```vim +--- :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true}) +--- :SayHello +--- Hello world! +--- ``` +--- +--- @param name string Name of the new user command. Must begin with an uppercase +--- letter. +--- @param command any Replacement command to execute when this user command is +--- executed. When called from Lua, the command can also be a +--- Lua function. The function is called with a single table +--- argument that contains the following keys: +--- • name: (string) Command name +--- • args: (string) The args passed to the command, if any +--- `<args>` +--- • fargs: (table) The args split by unescaped whitespace +--- (when more than one argument is allowed), if any +--- `<f-args>` +--- • nargs: (string) Number of arguments `:command-nargs` +--- • bang: (boolean) "true" if the command was executed with a +--- ! modifier `<bang>` +--- • line1: (number) The starting line of the command range +--- `<line1>` +--- • line2: (number) The final line of the command range +--- `<line2>` +--- • range: (number) The number of items in the command range: +--- 0, 1, or 2 `<range>` +--- • count: (number) Any count supplied `<count>` +--- • reg: (string) The optional register, if specified `<reg>` +--- • mods: (string) Command modifiers, if any `<mods>` +--- • smods: (table) Command modifiers in a structured format. +--- Has the same structure as the "mods" key of +--- `nvim_parse_cmd()`. +--- @param opts vim.api.keyset.user_command Optional `command-attributes`. +--- • Set boolean attributes such as `:command-bang` or +--- `:command-bar` to true (but not `:command-buffer`, use +--- `nvim_buf_create_user_command()` instead). +--- • "complete" `:command-complete` also accepts a Lua +--- function which works like +--- `:command-completion-customlist`. +--- • Other parameters: +--- • desc: (string) Used for listing the command when a Lua +--- function is used for {command}. +--- • force: (boolean, default true) Override any previous +--- definition. +--- • preview: (function) Preview callback for 'inccommand' +--- `:command-preview` +function vim.api.nvim_create_user_command(name, command, opts) end + +--- Delete an autocommand group by id. +--- To get a group id one can use `nvim_get_autocmds()`. +--- NOTE: behavior differs from `:augroup-delete`. When deleting a group, +--- autocommands contained in this group will also be deleted and cleared. +--- This group will no longer exist. +--- +--- @param id integer Integer The id of the group. +function vim.api.nvim_del_augroup_by_id(id) end + +--- Delete an autocommand group by name. +--- NOTE: behavior differs from `:augroup-delete`. When deleting a group, +--- autocommands contained in this group will also be deleted and cleared. +--- This group will no longer exist. +--- +--- @param name string String The name of the group. +function vim.api.nvim_del_augroup_by_name(name) end + +--- Deletes an autocommand by id. +--- +--- @param id integer Integer Autocommand id returned by `nvim_create_autocmd()` +function vim.api.nvim_del_autocmd(id) end + +--- Deletes the current line. +--- +function vim.api.nvim_del_current_line() end + +--- Unmaps a global `mapping` for the given mode. +--- To unmap a buffer-local mapping, use `nvim_buf_del_keymap()`. +--- +--- @param mode string +--- @param lhs string +function vim.api.nvim_del_keymap(mode, lhs) end + +--- Deletes an uppercase/file named mark. See `mark-motions`. +--- +--- @param name string Mark name +--- @return boolean +function vim.api.nvim_del_mark(name) end + +--- Delete a user-defined command. +--- +--- @param name string Name of the command to delete. +function vim.api.nvim_del_user_command(name) end + +--- Removes a global (g:) variable. +--- +--- @param name string Variable name +function vim.api.nvim_del_var(name) end + +--- Echo a message. +--- +--- @param chunks any[] A list of [text, hl_group] arrays, each representing a text +--- chunk with specified highlight. `hl_group` element can be +--- omitted for no highlight. +--- @param history boolean if true, add to `message-history`. +--- @param opts vim.api.keyset.echo_opts Optional parameters. +--- • verbose: Message was printed as a result of 'verbose' +--- option if Nvim was invoked with -V3log_file, the message +--- will be redirected to the log_file and suppressed from +--- direct output. +function vim.api.nvim_echo(chunks, history, opts) end + +--- Writes a message to the Vim error buffer. Does not append "\n", the +--- message is buffered (won't display) until a linefeed is written. +--- +--- @param str string Message +function vim.api.nvim_err_write(str) end + +--- Writes a message to the Vim error buffer. Appends "\n", so the buffer is +--- flushed (and displayed). +--- +--- @param str string Message +function vim.api.nvim_err_writeln(str) end + +--- Evaluates a Vimscript `expression`. Dictionaries and Lists are recursively +--- expanded. +--- On execution error: fails with Vimscript error, updates v:errmsg. +--- +--- @param expr string Vimscript expression string +--- @return any +function vim.api.nvim_eval(expr) end + +--- Evaluates statusline string. +--- +--- @param str string Statusline string (see 'statusline'). +--- @param opts vim.api.keyset.eval_statusline Optional parameters. +--- • winid: (number) `window-ID` of the window to use as context +--- for statusline. +--- • maxwidth: (number) Maximum width of statusline. +--- • fillchar: (string) Character to fill blank spaces in the +--- statusline (see 'fillchars'). Treated as single-width even +--- if it isn't. +--- • highlights: (boolean) Return highlight information. +--- • use_winbar: (boolean) Evaluate winbar instead of statusline. +--- • use_tabline: (boolean) Evaluate tabline instead of +--- statusline. When true, {winid} is ignored. Mutually +--- exclusive with {use_winbar}. +--- • use_statuscol_lnum: (number) Evaluate statuscolumn for this +--- line number instead of statusline. +--- @return table<string,any> +function vim.api.nvim_eval_statusline(str, opts) end + +--- @deprecated +--- @param src string +--- @param output boolean +--- @return string +function vim.api.nvim_exec(src, output) end + +--- Executes Vimscript (multiline block of Ex commands), like anonymous +--- `:source`. +--- Unlike `nvim_command()` this function supports heredocs, script-scope +--- (s:), etc. +--- On execution error: fails with Vimscript error, updates v:errmsg. +--- +--- @param src string Vimscript code +--- @param opts vim.api.keyset.exec_opts Optional parameters. +--- • output: (boolean, default false) Whether to capture and +--- return all (non-error, non-shell `:!`) output. +--- @return table<string,any> +function vim.api.nvim_exec2(src, opts) end + +--- Execute all autocommands for {event} that match the corresponding {opts} +--- `autocmd-execute`. +--- +--- @param event any (String|Array) The event or events to execute +--- @param opts vim.api.keyset.exec_autocmds Dictionary of autocommand options: +--- • group (string|integer) optional: the autocommand group name +--- or id to match against. `autocmd-groups`. +--- • pattern (string|array) optional: defaults to "*" +--- `autocmd-pattern`. Cannot be used with {buffer}. +--- • buffer (integer) optional: buffer number +--- `autocmd-buflocal`. Cannot be used with {pattern}. +--- • modeline (bool) optional: defaults to true. Process the +--- modeline after the autocommands `<nomodeline>`. +--- • data (any): arbitrary data to send to the autocommand +--- callback. See `nvim_create_autocmd()` for details. +function vim.api.nvim_exec_autocmds(event, opts) end + +--- Sends input-keys to Nvim, subject to various quirks controlled by `mode` +--- flags. This is a blocking call, unlike `nvim_input()`. +--- On execution error: does not fail, but updates v:errmsg. +--- To input sequences like <C-o> use `nvim_replace_termcodes()` (typically +--- with escape_ks=false) to replace `keycodes`, then pass the result to +--- nvim_feedkeys(). +--- Example: +--- +--- ```vim +--- :let key = nvim_replace_termcodes("<C-o>", v:true, v:false, v:true) +--- :call nvim_feedkeys(key, 'n', v:false) +--- ``` +--- +--- @param keys string to be typed +--- @param mode string behavior flags, see `feedkeys()` +--- @param escape_ks boolean If true, escape K_SPECIAL bytes in `keys`. This should be +--- false if you already used `nvim_replace_termcodes()`, and +--- true otherwise. +function vim.api.nvim_feedkeys(keys, mode, escape_ks) end + +--- Gets the option information for all options. +--- The dictionary has the full option names as keys and option metadata +--- dictionaries as detailed at `nvim_get_option_info2()`. +--- +--- @return table<string,any> +function vim.api.nvim_get_all_options_info() end + +--- Get all autocommands that match the corresponding {opts}. +--- These examples will get autocommands matching ALL the given criteria: +--- +--- ```lua +--- -- Matches all criteria +--- autocommands = vim.api.nvim_get_autocmds({ +--- group = "MyGroup", +--- event = {"BufEnter", "BufWinEnter"}, +--- pattern = {"*.c", "*.h"} +--- }) +--- +--- -- All commands from one group +--- autocommands = vim.api.nvim_get_autocmds({ +--- group = "MyGroup", +--- }) +--- ``` +--- +--- NOTE: When multiple patterns or events are provided, it will find all the +--- autocommands that match any combination of them. +--- +--- @param opts vim.api.keyset.get_autocmds Dictionary with at least one of the following: +--- • group (string|integer): the autocommand group name or id to +--- match against. +--- • event (string|array): event or events to match against +--- `autocmd-events`. +--- • pattern (string|array): pattern or patterns to match against +--- `autocmd-pattern`. Cannot be used with {buffer} +--- • buffer: Buffer number or list of buffer numbers for buffer +--- local autocommands `autocmd-buflocal`. Cannot be used with +--- {pattern} +--- @return any[] +function vim.api.nvim_get_autocmds(opts) end + +--- Gets information about a channel. +--- +--- @param chan integer +--- @return table<string,any> +function vim.api.nvim_get_chan_info(chan) end + +--- Returns the 24-bit RGB value of a `nvim_get_color_map()` color name or +--- "#rrggbb" hexadecimal string. +--- Example: +--- +--- ```vim +--- :echo nvim_get_color_by_name("Pink") +--- :echo nvim_get_color_by_name("#cbcbcb") +--- ``` +--- +--- @param name string Color name or "#rrggbb" string +--- @return integer +function vim.api.nvim_get_color_by_name(name) end + +--- Returns a map of color names and RGB values. +--- Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values +--- (e.g. 65535). +--- +--- @return table<string,any> +function vim.api.nvim_get_color_map() end + +--- Gets a map of global (non-buffer-local) Ex commands. +--- Currently only `user-commands` are supported, not builtin Ex commands. +--- +--- @param opts vim.api.keyset.get_commands Optional parameters. Currently only supports {"builtin":false} +--- @return table<string,any> +function vim.api.nvim_get_commands(opts) end + +--- Gets a map of the current editor state. +--- +--- @param opts vim.api.keyset.context Optional parameters. +--- • types: List of `context-types` ("regs", "jumps", "bufs", +--- "gvars", …) to gather, or empty for "all". +--- @return table<string,any> +function vim.api.nvim_get_context(opts) end + +--- Gets the current buffer. +--- +--- @return integer +function vim.api.nvim_get_current_buf() end + +--- Gets the current line. +--- +--- @return string +function vim.api.nvim_get_current_line() end + +--- Gets the current tabpage. +--- +--- @return integer +function vim.api.nvim_get_current_tabpage() end + +--- Gets the current window. +--- +--- @return integer +function vim.api.nvim_get_current_win() end + +--- Gets all or specific highlight groups in a namespace. +--- +--- @param ns_id integer Get highlight groups for namespace ns_id +--- `nvim_get_namespaces()`. Use 0 to get global highlight groups +--- `:highlight`. +--- @param opts vim.api.keyset.get_highlight Options dict: +--- • name: (string) Get a highlight definition by name. +--- • id: (integer) Get a highlight definition by id. +--- • link: (boolean, default true) Show linked group name +--- instead of effective definition `:hi-link`. +--- • create: (boolean, default true) When highlight group +--- doesn't exist create it. +--- @return table<string,any> +function vim.api.nvim_get_hl(ns_id, opts) end + +--- @deprecated +--- @param hl_id integer +--- @param rgb boolean +--- @return table<string,any> +function vim.api.nvim_get_hl_by_id(hl_id, rgb) end + +--- @deprecated +--- @param name string +--- @param rgb boolean +--- @return table<string,any> +function vim.api.nvim_get_hl_by_name(name, rgb) end + +--- Gets a highlight group by name +--- similar to `hlID()`, but allocates a new ID if not present. +--- +--- @param name string +--- @return integer +function vim.api.nvim_get_hl_id_by_name(name) end + +--- Gets the active highlight namespace. +--- +--- @param opts vim.api.keyset.get_ns Optional parameters +--- • winid: (number) `window-ID` for retrieving a window's +--- highlight namespace. A value of -1 is returned when +--- `nvim_win_set_hl_ns()` has not been called for the window +--- (or was called with a namespace of -1). +--- @return integer +function vim.api.nvim_get_hl_ns(opts) end + +--- Gets a list of global (non-buffer-local) `mapping` definitions. +--- +--- @param mode string Mode short-name ("n", "i", "v", ...) +--- @return table<string,any>[] +function vim.api.nvim_get_keymap(mode) end + +--- Returns a `(row, col, buffer, buffername)` tuple representing the position +--- of the uppercase/file named mark. "End of line" column position is +--- returned as `v:maxcol` (big number). See `mark-motions`. +--- Marks are (1,0)-indexed. `api-indexing` +--- +--- @param name string Mark name +--- @param opts table<string,any> Optional parameters. Reserved for future use. +--- @return any[] +function vim.api.nvim_get_mark(name, opts) end + +--- Gets the current mode. `mode()` "blocking" is true if Nvim is waiting for +--- input. +--- +--- @return table<string,any> +function vim.api.nvim_get_mode() end + +--- Gets existing, non-anonymous `namespace`s. +--- +--- @return table<string,any> +function vim.api.nvim_get_namespaces() end + +--- @deprecated +--- @param name string +--- @return any +function vim.api.nvim_get_option(name) end + +--- @deprecated +--- @param name string +--- @return table<string,any> +function vim.api.nvim_get_option_info(name) end + +--- Gets the option information for one option from arbitrary buffer or window +--- Resulting dictionary has keys: +--- • name: Name of the option (like 'filetype') +--- • shortname: Shortened name of the option (like 'ft') +--- • type: type of option ("string", "number" or "boolean") +--- • default: The default value for the option +--- • was_set: Whether the option was set. +--- • last_set_sid: Last set script id (if any) +--- • last_set_linenr: line number where option was set +--- • last_set_chan: Channel where option was set (0 for local) +--- • scope: one of "global", "win", or "buf" +--- • global_local: whether win or buf option has a global value +--- • commalist: List of comma separated values +--- • flaglist: List of single char flags +--- +--- When {scope} is not provided, the last set information applies to the +--- local value in the current buffer or window if it is available, otherwise +--- the global value information is returned. This behavior can be disabled by +--- explicitly specifying {scope} in the {opts} table. +--- +--- @param name string Option name +--- @param opts vim.api.keyset.option Optional parameters +--- • scope: One of "global" or "local". Analogous to `:setglobal` +--- and `:setlocal`, respectively. +--- • win: `window-ID`. Used for getting window local options. +--- • buf: Buffer number. Used for getting buffer local options. +--- Implies {scope} is "local". +--- @return table<string,any> +function vim.api.nvim_get_option_info2(name, opts) end + +--- Gets the value of an option. The behavior of this function matches that of +--- `:set`: the local value of an option is returned if it exists; otherwise, +--- the global value is returned. Local values always correspond to the +--- current buffer or window, unless "buf" or "win" is set in {opts}. +--- +--- @param name string Option name +--- @param opts vim.api.keyset.option Optional parameters +--- • scope: One of "global" or "local". Analogous to `:setglobal` +--- and `:setlocal`, respectively. +--- • win: `window-ID`. Used for getting window local options. +--- • buf: Buffer number. Used for getting buffer local options. +--- Implies {scope} is "local". +--- • filetype: `filetype`. Used to get the default option for a +--- specific filetype. Cannot be used with any other option. +--- Note: this will trigger `ftplugin` and all `FileType` +--- autocommands for the corresponding filetype. +--- @return any +function vim.api.nvim_get_option_value(name, opts) end + +--- Gets info describing process `pid`. +--- +--- @param pid integer +--- @return any +function vim.api.nvim_get_proc(pid) end + +--- Gets the immediate children of process `pid`. +--- +--- @param pid integer +--- @return any[] +function vim.api.nvim_get_proc_children(pid) end + +--- Find files in runtime directories +--- "name" can contain wildcards. For example +--- nvim_get_runtime_file("colors/*.vim", true) will return all color scheme +--- files. Always use forward slashes (/) in the search pattern for +--- subdirectories regardless of platform. +--- It is not an error to not find any files. An empty array is returned then. +--- +--- @param name string pattern of files to search for +--- @param all boolean whether to return all matches or only the first +--- @return string[] +function vim.api.nvim_get_runtime_file(name, all) end + +--- Gets a global (g:) variable. +--- +--- @param name string Variable name +--- @return any +function vim.api.nvim_get_var(name) end + +--- Gets a v: variable. +--- +--- @param name string Variable name +--- @return any +function vim.api.nvim_get_vvar(name) end + +--- Queues raw user-input. Unlike `nvim_feedkeys()`, this uses a low-level +--- input buffer and the call is non-blocking (input is processed +--- asynchronously by the eventloop). +--- On execution error: does not fail, but updates v:errmsg. +--- +--- @param keys string to be typed +--- @return integer +function vim.api.nvim_input(keys) end + +--- Send mouse event from GUI. +--- Non-blocking: does not wait on any result, but queues the event to be +--- processed soon by the event loop. +--- +--- @param button string Mouse button: one of "left", "right", "middle", "wheel", +--- "move". +--- @param action string For ordinary buttons, one of "press", "drag", "release". +--- For the wheel, one of "up", "down", "left", "right". +--- Ignored for "move". +--- @param modifier string String of modifiers each represented by a single char. The +--- same specifiers are used as for a key press, except that +--- the "-" separator is optional, so "C-A-", "c-a" and "CA" +--- can all be used to specify Ctrl+Alt+click. +--- @param grid integer Grid number if the client uses `ui-multigrid`, else 0. +--- @param row integer Mouse row-position (zero-based, like redraw events) +--- @param col integer Mouse column-position (zero-based, like redraw events) +function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end + +--- Gets the current list of buffer handles +--- Includes unlisted (unloaded/deleted) buffers, like `:ls!`. Use +--- `nvim_buf_is_loaded()` to check if a buffer is loaded. +--- +--- @return integer[] +function vim.api.nvim_list_bufs() end + +--- Get information about all open channels. +--- +--- @return any[] +function vim.api.nvim_list_chans() end + +--- Gets the paths contained in `runtime-search-path`. +--- +--- @return string[] +function vim.api.nvim_list_runtime_paths() end + +--- Gets the current list of tabpage handles. +--- +--- @return integer[] +function vim.api.nvim_list_tabpages() end + +--- Gets a list of dictionaries representing attached UIs. +--- +--- @return any[] +function vim.api.nvim_list_uis() end + +--- Gets the current list of window handles. +--- +--- @return integer[] +function vim.api.nvim_list_wins() end + +--- Sets the current editor state from the given `context` map. +--- +--- @param dict table<string,any> `Context` map. +--- @return any +function vim.api.nvim_load_context(dict) end + +--- Notify the user with a message +--- Relays the call to vim.notify . By default forwards your message in the +--- echo area but can be overridden to trigger desktop notifications. +--- +--- @param msg string Message to display to the user +--- @param log_level integer The log level +--- @param opts table<string,any> Reserved for future use. +--- @return any +function vim.api.nvim_notify(msg, log_level, opts) end + +--- Open a terminal instance in a buffer +--- By default (and currently the only option) the terminal will not be +--- connected to an external process. Instead, input send on the channel will +--- be echoed directly by the terminal. This is useful to display ANSI +--- terminal sequences returned as part of a rpc message, or similar. +--- Note: to directly initiate the terminal using the right size, display the +--- buffer in a configured window before calling this. For instance, for a +--- floating display, first create an empty buffer using `nvim_create_buf()`, +--- then display it using `nvim_open_win()`, and then call this function. Then +--- `nvim_chan_send()` can be called immediately to process sequences in a +--- virtual terminal having the intended size. +--- +--- @param buffer integer the buffer to use (expected to be empty) +--- @param opts table<string,function> Optional parameters. +--- • on_input: Lua callback for input sent, i e keypresses in +--- terminal mode. Note: keypresses are sent raw as they would +--- be to the pty master end. For instance, a carriage return +--- is sent as a "\r", not as a "\n". `textlock` applies. It +--- is possible to call `nvim_chan_send()` directly in the +--- callback however. ["input", term, bufnr, data] +--- @return integer +function vim.api.nvim_open_term(buffer, opts) end + +--- Open a new window. +--- Currently this is used to open floating and external windows. Floats are +--- windows that are drawn above the split layout, at some anchor position in +--- some other window. Floats can be drawn internally or by external GUI with +--- the `ui-multigrid` extension. External windows are only supported with +--- multigrid GUIs, and are displayed as separate top-level windows. +--- For a general overview of floats, see `api-floatwin`. +--- Exactly one of `external` and `relative` must be specified. The `width` +--- and `height` of the new window must be specified. +--- With relative=editor (row=0,col=0) refers to the top-left corner of the +--- screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right +--- corner. Fractional values are allowed, but the builtin implementation +--- (used by non-multigrid UIs) will always round down to nearest integer. +--- Out-of-bounds values, and configurations that make the float not fit +--- inside the main editor, are allowed. The builtin implementation truncates +--- values so floats are fully within the main screen grid. External GUIs +--- could let floats hover outside of the main window like a tooltip, but this +--- should not be used to specify arbitrary WM screen positions. +--- Example (Lua): window-relative float +--- +--- ```lua +--- vim.api.nvim_open_win(0, false, +--- {relative='win', row=3, col=3, width=12, height=3}) +--- ``` +--- +--- Example (Lua): buffer-relative float (travels as buffer is scrolled) +--- +--- ```lua +--- vim.api.nvim_open_win(0, false, +--- {relative='win', width=12, height=3, bufpos={100,10}}) +--- }) +--- ``` +--- +--- @param buffer integer Buffer to display, or 0 for current buffer +--- @param enter boolean Enter the window (make it the current window) +--- @param config vim.api.keyset.float_config Map defining the window configuration. Keys: +--- • relative: Sets the window layout to "floating", placed at +--- (row,col) coordinates relative to: +--- • "editor" The global editor grid +--- • "win" Window given by the `win` field, or current +--- window. +--- • "cursor" Cursor position in current window. +--- • "mouse" Mouse position +--- +--- • win: `window-ID` for relative="win". +--- • anchor: Decides which corner of the float to place at +--- (row,col): +--- • "NW" northwest (default) +--- • "NE" northeast +--- • "SW" southwest +--- • "SE" southeast +--- +--- • width: Window width (in character cells). Minimum of 1. +--- • height: Window height (in character cells). Minimum of 1. +--- • bufpos: Places float relative to buffer text (only when +--- relative="win"). Takes a tuple of zero-indexed [line, +--- column]. `row` and `col` if given are applied relative to this position, else they +--- default to: +--- • `row=1` and `col=0` if `anchor` is "NW" or "NE" +--- • `row=0` and `col=0` if `anchor` is "SW" or "SE" (thus +--- like a tooltip near the buffer text). +--- +--- • row: Row position in units of "screen cell height", may be +--- fractional. +--- • col: Column position in units of "screen cell width", may +--- be fractional. +--- • focusable: Enable focus by user actions (wincmds, mouse +--- events). Defaults to true. Non-focusable windows can be +--- entered by `nvim_set_current_win()`. +--- • external: GUI should display the window as an external +--- top-level window. Currently accepts no other positioning +--- configuration together with this. +--- • zindex: Stacking order. floats with higher `zindex` go on top on floats with lower indices. Must be larger +--- than zero. The following screen elements have hard-coded +--- z-indices: +--- • 100: insert completion popupmenu +--- • 200: message scrollback +--- • 250: cmdline completion popupmenu (when +--- wildoptions+=pum) The default value for floats are 50. +--- In general, values below 100 are recommended, unless +--- there is a good reason to overshadow builtin elements. +--- +--- • style: (optional) Configure the appearance of the window. +--- Currently only supports one value: +--- • "minimal" Nvim will display the window with many UI +--- options disabled. This is useful when displaying a +--- temporary float where the text should not be edited. +--- Disables 'number', 'relativenumber', 'cursorline', +--- 'cursorcolumn', 'foldcolumn', 'spell' and 'list' +--- options. 'signcolumn' is changed to `auto` and +--- 'colorcolumn' is cleared. 'statuscolumn' is changed to +--- empty. The end-of-buffer region is hidden by setting +--- `eob` flag of 'fillchars' to a space char, and clearing +--- the `hl-EndOfBuffer` region in 'winhighlight'. +--- +--- • border: Style of (optional) window border. This can either +--- be a string or an array. The string values are +--- • "none": No border (default). +--- • "single": A single line box. +--- • "double": A double line box. +--- • "rounded": Like "single", but with rounded corners ("╭" +--- etc.). +--- • "solid": Adds padding by a single whitespace cell. +--- • "shadow": A drop shadow effect by blending with the +--- background. +--- • If it is an array, it should have a length of eight or +--- any divisor of eight. The array will specify the eight +--- chars building up the border in a clockwise fashion +--- starting with the top-left corner. As an example, the +--- double box style could be specified as [ "╔", "═" ,"╗", +--- "║", "╝", "═", "╚", "║" ]. If the number of chars are +--- less than eight, they will be repeated. Thus an ASCII +--- border could be specified as [ "/", "-", "\\", "|" ], or +--- all chars the same as [ "x" ]. An empty string can be +--- used to turn off a specific border, for instance, [ "", +--- "", "", ">", "", "", "", "<" ] will only make vertical +--- borders but not horizontal ones. By default, +--- `FloatBorder` highlight is used, which links to +--- `WinSeparator` when not defined. It could also be +--- specified by character: [ ["+", "MyCorner"], ["x", +--- "MyBorder"] ]. +--- +--- • title: Title (optional) in window border, string or list. +--- List should consist of `[text, highlight]` tuples. If +--- string, the default highlight group is `FloatTitle`. +--- • title_pos: Title position. Must be set with `title` +--- option. Value can be one of "left", "center", or "right". +--- Default is `"left"`. +--- • footer: Footer (optional) in window border, string or +--- list. List should consist of `[text, highlight]` tuples. +--- If string, the default highlight group is `FloatFooter`. +--- • footer_pos: Footer position. Must be set with `footer` +--- option. Value can be one of "left", "center", or "right". +--- Default is `"left"`. +--- • noautocmd: If true then no buffer-related autocommand +--- events such as `BufEnter`, `BufLeave` or `BufWinEnter` may +--- fire from calling this function. +--- • fixed: If true when anchor is NW or SW, the float window +--- would be kept fixed even if the window would be truncated. +--- • hide: If true the floating window will be hidden. +--- @return integer +function vim.api.nvim_open_win(buffer, enter, config) end + +--- Writes a message to the Vim output buffer. Does not append "\n", the +--- message is buffered (won't display) until a linefeed is written. +--- +--- @param str string Message +function vim.api.nvim_out_write(str) end + +--- Parse command line. +--- Doesn't check the validity of command arguments. +--- +--- @param str string Command line string to parse. Cannot contain "\n". +--- @param opts table<string,any> Optional parameters. Reserved for future use. +--- @return table<string,any> +function vim.api.nvim_parse_cmd(str, opts) end + +--- Parse a Vimscript expression. +--- +--- @param expr string Expression to parse. Always treated as a single line. +--- @param flags string Flags: +--- • "m" if multiple expressions in a row are allowed (only +--- the first one will be parsed), +--- • "E" if EOC tokens are not allowed (determines whether +--- they will stop parsing process or be recognized as an +--- operator/space, though also yielding an error). +--- • "l" when needing to start parsing with lvalues for +--- ":let" or ":for". Common flag sets: +--- • "m" to parse like for ":echo". +--- • "E" to parse like for "<C-r>=". +--- • empty string for ":call". +--- • "lm" to parse for ":let". +--- @param highlight boolean If true, return value will also include "highlight" key +--- containing array of 4-tuples (arrays) (Integer, Integer, +--- Integer, String), where first three numbers define the +--- highlighted region and represent line, starting column +--- and ending column (latter exclusive: one should highlight +--- region [start_col, end_col)). +--- @return table<string,any> +function vim.api.nvim_parse_expression(expr, flags, highlight) end + +--- Pastes at cursor, in any mode. +--- Invokes the `vim.paste` handler, which handles each mode appropriately. +--- Sets redo/undo. Faster than `nvim_input()`. Lines break at LF ("\n"). +--- Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err` +--- but do not affect the return value (which is strictly decided by +--- `vim.paste()`). On error, subsequent calls are ignored ("drained") until +--- the next paste is initiated (phase 1 or -1). +--- +--- @param data string Multiline input. May be binary (containing NUL bytes). +--- @param crlf boolean Also break lines at CR and CRLF. +--- @param phase integer -1: paste in a single call (i.e. without streaming). To +--- "stream" a paste, call `nvim_paste` sequentially with these `phase` values: +--- • 1: starts the paste (exactly once) +--- • 2: continues the paste (zero or more times) +--- • 3: ends the paste (exactly once) +--- @return boolean +function vim.api.nvim_paste(data, crlf, phase) end + +--- Puts text at cursor, in any mode. +--- Compare `:put` and `p` which are always linewise. +--- +--- @param lines string[] `readfile()`-style list of lines. `channel-lines` +--- @param type string Edit behavior: any `getregtype()` result, or: +--- • "b" `blockwise-visual` mode (may include width, e.g. "b3") +--- • "c" `charwise` mode +--- • "l" `linewise` mode +--- • "" guess by contents, see `setreg()` +--- @param after boolean If true insert after cursor (like `p`), or before (like +--- `P`). +--- @param follow boolean If true place cursor at end of inserted text. +function vim.api.nvim_put(lines, type, after, follow) end + +--- Replaces terminal codes and `keycodes` (<CR>, <Esc>, ...) in a string with +--- the internal representation. +--- +--- @param str string String to be converted. +--- @param from_part boolean Legacy Vim parameter. Usually true. +--- @param do_lt boolean Also translate <lt>. Ignored if `special` is false. +--- @param special boolean Replace `keycodes`, e.g. <CR> becomes a "\r" char. +--- @return string +function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end + +--- Selects an item in the completion popup menu. +--- If neither `ins-completion` nor `cmdline-completion` popup menu is active +--- this API call is silently ignored. Useful for an external UI using +--- `ui-popupmenu` to control the popup menu with the mouse. Can also be used +--- in a mapping; use <Cmd> `:map-cmd` or a Lua mapping to ensure the mapping +--- doesn't end completion mode. +--- +--- @param item integer Index (zero-based) of the item to select. Value of -1 +--- selects nothing and restores the original text. +--- @param insert boolean For `ins-completion`, whether the selection should be +--- inserted in the buffer. Ignored for `cmdline-completion`. +--- @param finish boolean Finish the completion and dismiss the popup menu. Implies +--- {insert}. +--- @param opts table<string,any> Optional parameters. Reserved for future use. +function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end + +--- Sets the current buffer. +--- +--- @param buffer integer Buffer handle +function vim.api.nvim_set_current_buf(buffer) end + +--- Changes the global working directory. +--- +--- @param dir string Directory path +function vim.api.nvim_set_current_dir(dir) end + +--- Sets the current line. +--- +--- @param line string Line contents +function vim.api.nvim_set_current_line(line) end + +--- Sets the current tabpage. +--- +--- @param tabpage integer Tabpage handle +function vim.api.nvim_set_current_tabpage(tabpage) end + +--- Sets the current window. +--- +--- @param window integer Window handle +function vim.api.nvim_set_current_win(window) end + +--- Set or change decoration provider for a `namespace` +--- This is a very general purpose interface for having Lua callbacks being +--- triggered during the redraw code. +--- The expected usage is to set `extmarks` for the currently redrawn buffer. +--- `nvim_buf_set_extmark()` can be called to add marks on a per-window or +--- per-lines basis. Use the `ephemeral` key to only use the mark for the +--- current screen redraw (the callback will be called again for the next +--- redraw). +--- Note: this function should not be called often. Rather, the callbacks +--- themselves can be used to throttle unneeded callbacks. the `on_start` +--- callback can return `false` to disable the provider until the next redraw. +--- Similarly, return `false` in `on_win` will skip the `on_lines` calls for +--- that window (but any extmarks set in `on_win` will still be used). A +--- plugin managing multiple sources of decoration should ideally only set one +--- provider, and merge the sources internally. You can use multiple `ns_id` +--- for the extmarks set/modified inside the callback anyway. +--- Note: doing anything other than setting extmarks is considered +--- experimental. Doing things like changing options are not explicitly +--- forbidden, but is likely to have unexpected consequences (such as 100% CPU +--- consumption). doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is +--- quite dubious for the moment. +--- Note: It is not allowed to remove or update extmarks in 'on_line' +--- callbacks. +--- +--- @param ns_id integer Namespace id from `nvim_create_namespace()` +--- @param opts vim.api.keyset.set_decoration_provider Table of callbacks: +--- • on_start: called first on each screen redraw ["start", +--- tick] +--- • on_buf: called for each buffer being redrawn (before window +--- callbacks) ["buf", bufnr, tick] +--- • on_win: called when starting to redraw a specific window. +--- botline_guess is an approximation that does not exceed the +--- last line number. ["win", winid, bufnr, topline, +--- botline_guess] +--- • on_line: called for each buffer line being redrawn. (The +--- interaction with fold lines is subject to change) ["win", +--- winid, bufnr, row] +--- • on_end: called at the end of a redraw cycle ["end", tick] +function vim.api.nvim_set_decoration_provider(ns_id, opts) end + +--- Sets a highlight group. +--- +--- @param ns_id integer Namespace id for this highlight `nvim_create_namespace()`. +--- Use 0 to set a highlight group globally `:highlight`. +--- Highlights from non-global namespaces are not active by +--- default, use `nvim_set_hl_ns()` or `nvim_win_set_hl_ns()` to +--- activate them. +--- @param name string Highlight group name, e.g. "ErrorMsg" +--- @param val vim.api.keyset.highlight Highlight definition map, accepts the following keys: +--- • fg (or foreground): color name or "#RRGGBB", see note. +--- • bg (or background): color name or "#RRGGBB", see note. +--- • sp (or special): color name or "#RRGGBB" +--- • blend: integer between 0 and 100 +--- • bold: boolean +--- • standout: boolean +--- • underline: boolean +--- • undercurl: boolean +--- • underdouble: boolean +--- • underdotted: boolean +--- • underdashed: boolean +--- • strikethrough: boolean +--- • italic: boolean +--- • reverse: boolean +--- • nocombine: boolean +--- • link: name of another highlight group to link to, see +--- `:hi-link`. +--- • default: Don't override existing definition `:hi-default` +--- • ctermfg: Sets foreground of cterm color `ctermfg` +--- • ctermbg: Sets background of cterm color `ctermbg` +--- • cterm: cterm attribute map, like `highlight-args`. If not +--- set, cterm attributes will match those from the attribute +--- map documented above. +--- • force: if true force update the highlight group when it +--- exists. +function vim.api.nvim_set_hl(ns_id, name, val) end + +--- Set active namespace for highlights defined with `nvim_set_hl()`. This can +--- be set for a single window, see `nvim_win_set_hl_ns()`. +--- +--- @param ns_id integer the namespace to use +function vim.api.nvim_set_hl_ns(ns_id) end + +--- Set active namespace for highlights defined with `nvim_set_hl()` while +--- redrawing. +--- This function meant to be called while redrawing, primarily from +--- `nvim_set_decoration_provider()` on_win and on_line callbacks, which are +--- allowed to change the namespace during a redraw cycle. +--- +--- @param ns_id integer the namespace to activate +function vim.api.nvim_set_hl_ns_fast(ns_id) end + +--- Sets a global `mapping` for the given mode. +--- To set a buffer-local mapping, use `nvim_buf_set_keymap()`. +--- Unlike `:map`, leading/trailing whitespace is accepted as part of the +--- {lhs} or {rhs}. Empty {rhs} is `<Nop>`. `keycodes` are replaced as usual. +--- Example: +--- +--- ```vim +--- call nvim_set_keymap('n', ' <NL>', '', {'nowait': v:true}) +--- ``` +--- +--- is equivalent to: +--- +--- ```vim +--- nmap <nowait> <Space><NL> <Nop> +--- ``` +--- +--- @param mode string Mode short-name (map command prefix: "n", "i", "v", "x", …) or +--- "!" for `:map!`, or empty string for `:map`. "ia", "ca" or +--- "!a" for abbreviation in Insert mode, Cmdline mode, or both, +--- respectively +--- @param lhs string Left-hand-side `{lhs}` of the mapping. +--- @param rhs string Right-hand-side `{rhs}` of the mapping. +--- @param opts vim.api.keyset.keymap Optional parameters map: Accepts all `:map-arguments` as keys +--- except `<buffer>`, values are booleans (default false). Also: +--- • "noremap" disables `recursive_mapping`, like `:noremap` +--- • "desc" human-readable description. +--- • "callback" Lua function called in place of {rhs}. +--- • "replace_keycodes" (boolean) When "expr" is true, replace +--- keycodes in the resulting string (see +--- `nvim_replace_termcodes()`). Returning nil from the Lua +--- "callback" is equivalent to returning an empty string. +function vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end + +--- @deprecated +--- @param name string +--- @param value any +function vim.api.nvim_set_option(name, value) end + +--- Sets the value of an option. The behavior of this function matches that of +--- `:set`: for global-local options, both the global and local value are set +--- unless otherwise specified with {scope}. +--- Note the options {win} and {buf} cannot be used together. +--- +--- @param name string Option name +--- @param value any New option value +--- @param opts vim.api.keyset.option Optional parameters +--- • scope: One of "global" or "local". Analogous to +--- `:setglobal` and `:setlocal`, respectively. +--- • win: `window-ID`. Used for setting window local option. +--- • buf: Buffer number. Used for setting buffer local option. +function vim.api.nvim_set_option_value(name, value, opts) end + +--- Sets a global (g:) variable. +--- +--- @param name string Variable name +--- @param value any Variable value +function vim.api.nvim_set_var(name, value) end + +--- Sets a v: variable, if it is not readonly. +--- +--- @param name string Variable name +--- @param value any Variable value +function vim.api.nvim_set_vvar(name, value) end + +--- Calculates the number of display cells occupied by `text`. Control +--- characters including <Tab> count as one cell. +--- +--- @param text string Some text +--- @return integer +function vim.api.nvim_strwidth(text) end + +--- Removes a tab-scoped (t:) variable +--- +--- @param tabpage integer Tabpage handle, or 0 for current tabpage +--- @param name string Variable name +function vim.api.nvim_tabpage_del_var(tabpage, name) end + +--- Gets the tabpage number +--- +--- @param tabpage integer Tabpage handle, or 0 for current tabpage +--- @return integer +function vim.api.nvim_tabpage_get_number(tabpage) end + +--- Gets a tab-scoped (t:) variable +--- +--- @param tabpage integer Tabpage handle, or 0 for current tabpage +--- @param name string Variable name +--- @return any +function vim.api.nvim_tabpage_get_var(tabpage, name) end + +--- Gets the current window in a tabpage +--- +--- @param tabpage integer Tabpage handle, or 0 for current tabpage +--- @return integer +function vim.api.nvim_tabpage_get_win(tabpage) end + +--- Checks if a tabpage is valid +--- +--- @param tabpage integer Tabpage handle, or 0 for current tabpage +--- @return boolean +function vim.api.nvim_tabpage_is_valid(tabpage) end + +--- Gets the windows in a tabpage +--- +--- @param tabpage integer Tabpage handle, or 0 for current tabpage +--- @return integer[] +function vim.api.nvim_tabpage_list_wins(tabpage) end + +--- Sets a tab-scoped (t:) variable +--- +--- @param tabpage integer Tabpage handle, or 0 for current tabpage +--- @param name string Variable name +--- @param value any Variable value +function vim.api.nvim_tabpage_set_var(tabpage, name, value) end + +--- Calls a function with window as temporary current window. +--- +--- @param window integer Window handle, or 0 for current window +--- @param fun function Function to call inside the window (currently Lua callable +--- only) +--- @return any +function vim.api.nvim_win_call(window, fun) end + +--- Closes the window (like `:close` with a `window-ID`). +--- +--- @param window integer Window handle, or 0 for current window +--- @param force boolean Behave like `:close!` The last window of a buffer with +--- unwritten changes can be closed. The buffer will become +--- hidden, even if 'hidden' is not set. +function vim.api.nvim_win_close(window, force) end + +--- Removes a window-scoped (w:) variable +--- +--- @param window integer Window handle, or 0 for current window +--- @param name string Variable name +function vim.api.nvim_win_del_var(window, name) end + +--- Gets the current buffer in a window +--- +--- @param window integer Window handle, or 0 for current window +--- @return integer +function vim.api.nvim_win_get_buf(window) end + +--- Gets window configuration. +--- The returned value may be given to `nvim_open_win()`. +--- `relative` is empty for normal windows. +--- +--- @param window integer Window handle, or 0 for current window +--- @return table<string,any> +function vim.api.nvim_win_get_config(window) end + +--- Gets the (1,0)-indexed, buffer-relative cursor position for a given window +--- (different windows showing the same buffer have independent cursor +--- positions). `api-indexing` +--- +--- @param window integer Window handle, or 0 for current window +--- @return integer[] +function vim.api.nvim_win_get_cursor(window) end + +--- Gets the window height +--- +--- @param window integer Window handle, or 0 for current window +--- @return integer +function vim.api.nvim_win_get_height(window) end + +--- Gets the window number +--- +--- @param window integer Window handle, or 0 for current window +--- @return integer +function vim.api.nvim_win_get_number(window) end + +--- @deprecated +--- @param window integer +--- @param name string +--- @return any +function vim.api.nvim_win_get_option(window, name) end + +--- Gets the window position in display cells. First position is zero. +--- +--- @param window integer Window handle, or 0 for current window +--- @return integer[] +function vim.api.nvim_win_get_position(window) end + +--- Gets the window tabpage +--- +--- @param window integer Window handle, or 0 for current window +--- @return integer +function vim.api.nvim_win_get_tabpage(window) end + +--- Gets a window-scoped (w:) variable +--- +--- @param window integer Window handle, or 0 for current window +--- @param name string Variable name +--- @return any +function vim.api.nvim_win_get_var(window, name) end + +--- Gets the window width +--- +--- @param window integer Window handle, or 0 for current window +--- @return integer +function vim.api.nvim_win_get_width(window) end + +--- Closes the window and hide the buffer it contains (like `:hide` with a +--- `window-ID`). +--- Like `:hide` the buffer becomes hidden unless another window is editing +--- it, or 'bufhidden' is `unload`, `delete` or `wipe` as opposed to `:close` +--- or `nvim_win_close()`, which will close the buffer. +--- +--- @param window integer Window handle, or 0 for current window +function vim.api.nvim_win_hide(window) end + +--- Checks if a window is valid +--- +--- @param window integer Window handle, or 0 for current window +--- @return boolean +function vim.api.nvim_win_is_valid(window) end + +--- Sets the current buffer in a window, without side effects +--- +--- @param window integer Window handle, or 0 for current window +--- @param buffer integer Buffer handle +function vim.api.nvim_win_set_buf(window, buffer) end + +--- Configures window layout. Currently only for floating and external windows +--- (including changing a split window to those layouts). +--- When reconfiguring a floating window, absent option keys will not be +--- changed. `row`/`col` and `relative` must be reconfigured together. +--- +--- @param window integer Window handle, or 0 for current window +--- @param config vim.api.keyset.float_config Map defining the window configuration, see `nvim_open_win()` +function vim.api.nvim_win_set_config(window, config) end + +--- Sets the (1,0)-indexed cursor position in the window. `api-indexing` This +--- scrolls the window even if it is not the current one. +--- +--- @param window integer Window handle, or 0 for current window +--- @param pos integer[] (row, col) tuple representing the new position +function vim.api.nvim_win_set_cursor(window, pos) end + +--- Sets the window height. +--- +--- @param window integer Window handle, or 0 for current window +--- @param height integer Height as a count of rows +function vim.api.nvim_win_set_height(window, height) end + +--- Set highlight namespace for a window. This will use highlights defined +--- with `nvim_set_hl()` for this namespace, but fall back to global +--- highlights (ns=0) when missing. +--- This takes precedence over the 'winhighlight' option. +--- +--- @param window integer +--- @param ns_id integer the namespace to use +function vim.api.nvim_win_set_hl_ns(window, ns_id) end + +--- @deprecated +--- @param window integer +--- @param name string +--- @param value any +function vim.api.nvim_win_set_option(window, name, value) end + +--- Sets a window-scoped (w:) variable +--- +--- @param window integer Window handle, or 0 for current window +--- @param name string Variable name +--- @param value any Variable value +function vim.api.nvim_win_set_var(window, name, value) end + +--- Sets the window width. This will only succeed if the screen is split +--- vertically. +--- +--- @param window integer Window handle, or 0 for current window +--- @param width integer Width as a count of columns +function vim.api.nvim_win_set_width(window, width) end + +--- Computes the number of screen lines occupied by a range of text in a given +--- window. Works for off-screen text and takes folds into account. +--- Diff filler or virtual lines above a line are counted as a part of that +--- line, unless the line is on "start_row" and "start_vcol" is specified. +--- Diff filler or virtual lines below the last buffer line are counted in the +--- result when "end_row" is omitted. +--- Line indexing is similar to `nvim_buf_get_text()`. +--- +--- @param window integer Window handle, or 0 for current window. +--- @param opts vim.api.keyset.win_text_height Optional parameters: +--- • start_row: Starting line index, 0-based inclusive. When +--- omitted start at the very top. +--- • end_row: Ending line index, 0-based inclusive. When +--- omitted end at the very bottom. +--- • start_vcol: Starting virtual column index on "start_row", +--- 0-based inclusive, rounded down to full screen lines. When +--- omitted include the whole line. +--- • end_vcol: Ending virtual column index on "end_row", +--- 0-based exclusive, rounded up to full screen lines. When +--- omitted include the whole line. +--- @return table<string,any> +function vim.api.nvim_win_text_height(window, opts) end diff --git a/runtime/lua/vim/_meta/api_keysets.lua b/runtime/lua/vim/_meta/api_keysets.lua new file mode 100644 index 0000000000..f69e5a92c7 --- /dev/null +++ b/runtime/lua/vim/_meta/api_keysets.lua @@ -0,0 +1,267 @@ +--- @meta _ +-- THIS FILE IS GENERATED +-- DO NOT EDIT +error('Cannot require a meta file') + +--- @class vim.api.keyset.clear_autocmds +--- @field buffer? integer +--- @field event? any +--- @field group? any +--- @field pattern? any + +--- @class vim.api.keyset.cmd +--- @field cmd? string +--- @field range? any[] +--- @field count? integer +--- @field reg? string +--- @field bang? boolean +--- @field args? any[] +--- @field magic? table<string,any> +--- @field mods? table<string,any> +--- @field nargs? any +--- @field addr? any +--- @field nextcmd? any + +--- @class vim.api.keyset.cmd_magic +--- @field file? boolean +--- @field bar? boolean + +--- @class vim.api.keyset.cmd_mods +--- @field silent? boolean +--- @field emsg_silent? boolean +--- @field unsilent? boolean +--- @field filter? table<string,any> +--- @field sandbox? boolean +--- @field noautocmd? boolean +--- @field browse? boolean +--- @field confirm? boolean +--- @field hide? boolean +--- @field horizontal? boolean +--- @field keepalt? boolean +--- @field keepjumps? boolean +--- @field keepmarks? boolean +--- @field keeppatterns? boolean +--- @field lockmarks? boolean +--- @field noswapfile? boolean +--- @field tab? integer +--- @field verbose? integer +--- @field vertical? boolean +--- @field split? string + +--- @class vim.api.keyset.cmd_mods_filter +--- @field pattern? string +--- @field force? boolean + +--- @class vim.api.keyset.cmd_opts +--- @field output? boolean + +--- @class vim.api.keyset.context +--- @field types? any[] + +--- @class vim.api.keyset.create_augroup +--- @field clear? any + +--- @class vim.api.keyset.create_autocmd +--- @field buffer? integer +--- @field callback? any +--- @field command? string +--- @field desc? string +--- @field group? any +--- @field nested? boolean +--- @field once? boolean +--- @field pattern? any + +--- @class vim.api.keyset.echo_opts +--- @field verbose? boolean + +--- @class vim.api.keyset.eval_statusline +--- @field winid? integer +--- @field maxwidth? integer +--- @field fillchar? string +--- @field highlights? boolean +--- @field use_winbar? boolean +--- @field use_tabline? boolean +--- @field use_statuscol_lnum? integer + +--- @class vim.api.keyset.exec_autocmds +--- @field buffer? integer +--- @field group? any +--- @field modeline? boolean +--- @field pattern? any +--- @field data? any + +--- @class vim.api.keyset.exec_opts +--- @field output? boolean + +--- @class vim.api.keyset.float_config +--- @field row? number +--- @field col? number +--- @field width? integer +--- @field height? integer +--- @field anchor? string +--- @field relative? string +--- @field win? integer +--- @field bufpos? any[] +--- @field external? boolean +--- @field focusable? boolean +--- @field zindex? integer +--- @field border? any +--- @field title? any +--- @field title_pos? string +--- @field footer? any +--- @field footer_pos? string +--- @field style? string +--- @field noautocmd? boolean +--- @field fixed? boolean +--- @field hide? boolean + +--- @class vim.api.keyset.get_autocmds +--- @field event? any +--- @field group? any +--- @field pattern? any +--- @field buffer? any + +--- @class vim.api.keyset.get_commands +--- @field builtin? boolean + +--- @class vim.api.keyset.get_extmarks +--- @field limit? integer +--- @field details? boolean +--- @field hl_name? boolean +--- @field overlap? boolean +--- @field type? string + +--- @class vim.api.keyset.get_highlight +--- @field id? integer +--- @field name? string +--- @field link? boolean +--- @field create? boolean + +--- @class vim.api.keyset.get_ns +--- @field winid? integer + +--- @class vim.api.keyset.highlight +--- @field bold? boolean +--- @field standout? boolean +--- @field strikethrough? boolean +--- @field underline? boolean +--- @field undercurl? boolean +--- @field underdouble? boolean +--- @field underdotted? boolean +--- @field underdashed? boolean +--- @field italic? boolean +--- @field reverse? boolean +--- @field altfont? boolean +--- @field nocombine? boolean +--- @field default? boolean +--- @field cterm? any +--- @field foreground? any +--- @field fg? any +--- @field background? any +--- @field bg? any +--- @field ctermfg? any +--- @field ctermbg? any +--- @field special? any +--- @field sp? any +--- @field link? any +--- @field global_link? any +--- @field fallback? boolean +--- @field blend? integer +--- @field fg_indexed? boolean +--- @field bg_indexed? boolean +--- @field force? boolean + +--- @class vim.api.keyset.highlight_cterm +--- @field bold? boolean +--- @field standout? boolean +--- @field strikethrough? boolean +--- @field underline? boolean +--- @field undercurl? boolean +--- @field underdouble? boolean +--- @field underdotted? boolean +--- @field underdashed? boolean +--- @field italic? boolean +--- @field reverse? boolean +--- @field altfont? boolean +--- @field nocombine? boolean + +--- @class vim.api.keyset.keymap +--- @field noremap? boolean +--- @field nowait? boolean +--- @field silent? boolean +--- @field script? boolean +--- @field expr? boolean +--- @field unique? boolean +--- @field callback? function +--- @field desc? string +--- @field replace_keycodes? boolean + +--- @class vim.api.keyset.option +--- @field scope? string +--- @field win? integer +--- @field buf? integer +--- @field filetype? string + +--- @class vim.api.keyset.runtime +--- @field is_lua? boolean +--- @field do_source? boolean + +--- @class vim.api.keyset.set_decoration_provider +--- @field on_start? function +--- @field on_buf? function +--- @field on_win? function +--- @field on_line? function +--- @field on_end? function +--- @field _on_hl_def? function +--- @field _on_spell_nav? function + +--- @class vim.api.keyset.set_extmark +--- @field id? integer +--- @field end_line? integer +--- @field end_row? integer +--- @field end_col? integer +--- @field hl_group? any +--- @field virt_text? any[] +--- @field virt_text_pos? string +--- @field virt_text_win_col? integer +--- @field virt_text_hide? boolean +--- @field hl_eol? boolean +--- @field hl_mode? string +--- @field invalidate? boolean +--- @field ephemeral? boolean +--- @field priority? integer +--- @field right_gravity? boolean +--- @field end_right_gravity? boolean +--- @field virt_lines? any[] +--- @field virt_lines_above? boolean +--- @field virt_lines_leftcol? boolean +--- @field strict? boolean +--- @field sign_text? string +--- @field sign_hl_group? any +--- @field number_hl_group? any +--- @field line_hl_group? any +--- @field cursorline_hl_group? any +--- @field conceal? string +--- @field spell? boolean +--- @field ui_watched? boolean +--- @field undo_restore? boolean + +--- @class vim.api.keyset.user_command +--- @field addr? any +--- @field bang? boolean +--- @field bar? boolean +--- @field complete? any +--- @field count? any +--- @field desc? any +--- @field force? boolean +--- @field keepscript? boolean +--- @field nargs? any +--- @field preview? any +--- @field range? any +--- @field register? boolean + +--- @class vim.api.keyset.win_text_height +--- @field start_row? integer +--- @field end_row? integer +--- @field start_vcol? integer +--- @field end_vcol? integer diff --git a/runtime/lua/vim/_meta/base64.lua b/runtime/lua/vim/_meta/base64.lua new file mode 100644 index 0000000000..f25b4af234 --- /dev/null +++ b/runtime/lua/vim/_meta/base64.lua @@ -0,0 +1,13 @@ +--- @meta + +--- Encode {str} using Base64. +--- +--- @param str string String to encode +--- @return string Encoded string +function vim.base64.encode(str) end + +--- Decode a Base64 encoded string. +--- +--- @param str string Base64 encoded string +--- @return string Decoded string +function vim.base64.decode(str) end diff --git a/runtime/lua/vim/_meta/builtin.lua b/runtime/lua/vim/_meta/builtin.lua new file mode 100644 index 0000000000..eeba356672 --- /dev/null +++ b/runtime/lua/vim/_meta/builtin.lua @@ -0,0 +1,289 @@ +---@meta + +-- luacheck: no unused args + +---@defgroup vim.builtin +--- +---@brief <pre>help +---vim.api.{func}({...}) *vim.api* +--- Invokes Nvim |API| function {func} with arguments {...}. +--- Example: call the "nvim_get_current_line()" API function: >lua +--- print(tostring(vim.api.nvim_get_current_line())) +--- +---vim.NIL *vim.NIL* +--- Special value representing NIL in |RPC| and |v:null| in Vimscript +--- conversion, and similar cases. Lua `nil` cannot be used as part of a Lua +--- table representing a Dictionary or Array, because it is treated as +--- missing: `{"foo", nil}` is the same as `{"foo"}`. +--- +---vim.type_idx *vim.type_idx* +--- Type index for use in |lua-special-tbl|. Specifying one of the values from +--- |vim.types| allows typing the empty table (it is unclear whether empty Lua +--- table represents empty list or empty array) and forcing integral numbers +--- to be |Float|. See |lua-special-tbl| for more details. +--- +---vim.val_idx *vim.val_idx* +--- Value index for tables representing |Float|s. A table representing +--- floating-point value 1.0 looks like this: >lua +--- { +--- [vim.type_idx] = vim.types.float, +--- [vim.val_idx] = 1.0, +--- } +---< See also |vim.type_idx| and |lua-special-tbl|. +--- +---vim.types *vim.types* +--- Table with possible values for |vim.type_idx|. Contains two sets of +--- key-value pairs: first maps possible values for |vim.type_idx| to +--- human-readable strings, second maps human-readable type names to values +--- for |vim.type_idx|. Currently contains pairs for `float`, `array` and +--- `dictionary` types. +--- +--- Note: One must expect that values corresponding to `vim.types.float`, +--- `vim.types.array` and `vim.types.dictionary` fall under only two following +--- assumptions: +--- 1. Value may serve both as a key and as a value in a table. Given the +--- properties of Lua tables this basically means “value is not `nil`”. +--- 2. For each value in `vim.types` table `vim.types[vim.types[value]]` is the +--- same as `value`. +--- No other restrictions are put on types, and it is not guaranteed that +--- values corresponding to `vim.types.float`, `vim.types.array` and +--- `vim.types.dictionary` will not change or that `vim.types` table will only +--- contain values for these three types. +--- +--- *log_levels* *vim.log.levels* +---Log levels are one of the values defined in `vim.log.levels`: +--- +--- vim.log.levels.DEBUG +--- vim.log.levels.ERROR +--- vim.log.levels.INFO +--- vim.log.levels.TRACE +--- vim.log.levels.WARN +--- vim.log.levels.OFF +--- +---</pre> + +--- Returns true if the code is executing as part of a "fast" event handler, +--- where most of the API is disabled. These are low-level events (e.g. +--- |lua-loop-callbacks|) which can be invoked whenever Nvim polls for input. +--- When this is `false` most API functions are callable (but may be subject +--- to other restrictions such as |textlock|). +function vim.in_fast_event() end + +--- Creates a special empty table (marked with a metatable), which Nvim +--- converts to an empty dictionary when translating Lua values to Vimscript +--- or API types. Nvim by default converts an empty table `{}` without this +--- metatable to an list/array. +--- +--- Note: If numeric keys are present in the table, Nvim ignores the metatable +--- marker and converts the dict to a list/array anyway. +function vim.empty_dict() end + +--- Sends {event} to {channel} via |RPC| and returns immediately. If {channel} +--- is 0, the event is broadcast to all channels. +--- +--- This function also works in a fast callback |lua-loop-callbacks|. +--- @param channel integer +--- @param method string +--- @param args? any[] +--- @param ...? any +function vim.rpcnotify(channel, method, args, ...) end + +--- Sends a request to {channel} to invoke {method} via |RPC| and blocks until +--- a response is received. +--- +--- Note: NIL values as part of the return value is represented as |vim.NIL| +--- special value +--- @param channel integer +--- @param method string +--- @param args? any[] +--- @param ...? any +function vim.rpcrequest(channel, method, args, ...) end + +--- Compares strings case-insensitively. +--- @param a string +--- @param b string +--- @return 0|1|-1 +--- if strings are +--- equal, {a} is greater than {b} or {a} is lesser than {b}, respectively. +function vim.stricmp(a, b) end + +--- Convert UTF-32 or UTF-16 {index} to byte index. If {use_utf16} is not +--- supplied, it defaults to false (use UTF-32). Returns the byte index. +--- +--- Invalid UTF-8 and NUL is treated like by |vim.str_byteindex()|. +--- An {index} in the middle of a UTF-16 sequence is rounded upwards to +--- the end of that sequence. +--- @param str string +--- @param index number +--- @param use_utf16? any +function vim.str_byteindex(str, index, use_utf16) end + +--- Gets a list of the starting byte positions of each UTF-8 codepoint in the given string. +--- +--- Embedded NUL bytes are treated as terminating the string. +--- @param str string +--- @return table +function vim.str_utf_pos(str) end + +--- Gets the distance (in bytes) from the starting byte of the codepoint (character) that {index} +--- points to. +--- +--- The result can be added to {index} to get the starting byte of a character. +--- +--- Examples: +--- +--- ```lua +--- -- The character 'æ' is stored as the bytes '\xc3\xa6' (using UTF-8) +--- +--- -- Returns 0 because the index is pointing at the first byte of a character +--- vim.str_utf_start('æ', 1) +--- +--- -- Returns -1 because the index is pointing at the second byte of a character +--- vim.str_utf_start('æ', 2) +--- ``` +--- +--- @param str string +--- @param index number +--- @return number +function vim.str_utf_start(str, index) end + +--- Gets the distance (in bytes) from the last byte of the codepoint (character) that {index} points +--- to. +--- +--- Examples: +--- +--- ```lua +--- -- The character 'æ' is stored as the bytes '\xc3\xa6' (using UTF-8) +--- +--- -- Returns 0 because the index is pointing at the last byte of a character +--- vim.str_utf_end('æ', 2) +--- +--- -- Returns 1 because the index is pointing at the penultimate byte of a character +--- vim.str_utf_end('æ', 1) +--- ``` +--- +--- @param str string +--- @param index number +--- @return number +function vim.str_utf_end(str, index) end + +--- Convert byte index to UTF-32 and UTF-16 indices. If {index} is not +--- supplied, the length of the string is used. All indices are zero-based. +--- +--- Embedded NUL bytes are treated as terminating the string. Invalid UTF-8 +--- bytes, and embedded surrogates are counted as one code point each. An +--- {index} in the middle of a UTF-8 sequence is rounded upwards to the end of +--- that sequence. +--- @param str string +--- @param index? number +--- @return integer UTF-32 index +--- @return integer UTF-16 index +function vim.str_utfindex(str, index) end + +--- The result is a String, which is the text {str} converted from +--- encoding {from} to encoding {to}. When the conversion fails `nil` is +--- returned. When some characters could not be converted they +--- are replaced with "?". +--- The encoding names are whatever the iconv() library function +--- can accept, see ":Man 3 iconv". +--- +--- @param str string Text to convert +--- @param from number Encoding of {str} +--- @param to number Target encoding +--- @param opts? table<string,any> +--- @return string|nil Converted string if conversion succeeds, `nil` otherwise. +function vim.iconv(str, from, to, opts) end + +--- Schedules {fn} to be invoked soon by the main event-loop. Useful +--- to avoid |textlock| or other temporary restrictions. +--- @param fn function +function vim.schedule(fn) end + +--- Wait for {time} in milliseconds until {callback} returns `true`. +--- +--- Executes {callback} immediately and at approximately {interval} +--- milliseconds (default 200). Nvim still processes other events during +--- this time. +--- +--- Cannot be called while in an |api-fast| event. +--- +--- Examples: +--- +--- ```lua +--- +--- --- +--- -- Wait for 100 ms, allowing other events to process +--- vim.wait(100, function() end) +--- +--- --- +--- -- Wait for 100 ms or until global variable set. +--- vim.wait(100, function() return vim.g.waiting_for_var end) +--- +--- --- +--- -- Wait for 1 second or until global variable set, checking every ~500 ms +--- vim.wait(1000, function() return vim.g.waiting_for_var end, 500) +--- +--- --- +--- -- Schedule a function to set a value in 100ms +--- vim.defer_fn(function() vim.g.timer_result = true end, 100) +--- +--- -- Would wait ten seconds if results blocked. Actually only waits 100 ms +--- if vim.wait(10000, function() return vim.g.timer_result end) then +--- print('Only waiting a little bit of time!') +--- end +--- ``` +--- +--- @param time integer Number of milliseconds to wait +--- @param callback? fun(): boolean Optional callback. Waits until {callback} returns true +--- @param interval? integer (Approximate) number of milliseconds to wait between polls +--- @param fast_only? boolean If true, only |api-fast| events will be processed. +--- @return boolean, nil|-1|-2 +--- - If {callback} returns `true` during the {time}: `true, nil` +--- - If {callback} never returns `true` during the {time}: `false, -1` +--- - If {callback} is interrupted during the {time}: `false, -2` +--- - If {callback} errors, the error is raised. +function vim.wait(time, callback, interval, fast_only) end + +--- Attach to ui events, similar to |nvim_ui_attach()| but receive events +--- as Lua callback. Can be used to implement screen elements like +--- popupmenu or message handling in Lua. +--- +--- {options} should be a dictionary-like table, where `ext_...` options should +--- be set to true to receive events for the respective external element. +--- +--- {callback} receives event name plus additional parameters. See |ui-popupmenu| +--- and the sections below for event format for respective events. +--- +--- WARNING: This api is considered experimental. Usability will vary for +--- different screen elements. In particular `ext_messages` behavior is subject +--- to further changes and usability improvements. This is expected to be +--- used to handle messages when setting 'cmdheight' to zero (which is +--- likewise experimental). +--- +--- Example (stub for a |ui-popupmenu| implementation): +--- +--- ```lua +--- ns = vim.api.nvim_create_namespace('my_fancy_pum') +--- +--- vim.ui_attach(ns, {ext_popupmenu=true}, function(event, ...) +--- if event == "popupmenu_show" then +--- local items, selected, row, col, grid = ... +--- print("display pum ", #items) +--- elseif event == "popupmenu_select" then +--- local selected = ... +--- print("selected", selected) +--- elseif event == "popupmenu_hide" then +--- print("FIN") +--- end +--- end) +--- ``` +--- +--- @param ns integer +--- @param options table<string, any> +--- @param callback fun() +function vim.ui_attach(ns, options, callback) end + +--- Detach a callback previously attached with |vim.ui_attach()| for the +--- given namespace {ns}. +--- @param ns integer +function vim.ui_detach(ns) end diff --git a/runtime/lua/vim/_meta/builtin_types.lua b/runtime/lua/vim/_meta/builtin_types.lua new file mode 100644 index 0000000000..ef0452c649 --- /dev/null +++ b/runtime/lua/vim/_meta/builtin_types.lua @@ -0,0 +1,129 @@ +--- @class vim.fn.sign +--- @field group string +--- @field id integer +--- @field lnum integer +--- @field name string +--- @field priority integer + +--- @class vim.fn.getbufinfo.dict +--- @field buflisted? 0|1 +--- @field bufloaded? 0|1 +--- @field bufmodified? 0|1 + +--- @class vim.fn.getbufinfo.ret.item +--- @field bufnr integer +--- @field changed 0|1 +--- @field changedtick integer +--- @field hidden 0|1 +--- @field lastused integer +--- @field linecount integer +--- @field listed 0|1 +--- @field lnum integer +--- @field loaded 0|1 +--- @field name string +--- @field signs vim.fn.sign[] +--- @field variables table<string,any> +--- @field windows integer[] + +--- @alias vim.fn.getjumplist.ret {[1]: vim.fn.getjumplist.ret.item[], [2]: integer} + +--- @class vim.fn.getjumplist.ret.item +--- @field bufnr integer +--- @field col integer +--- @field coladd integer +--- @field filename? string +--- @field lnum integer + +--- @class vim.fn.getmousepos.ret +--- @field screenrow integer +--- @field screencol integer +--- @field winid integer +--- @field winrow integer +--- @field wincol integer +--- @field line integer +--- @field column integer + +--- @class vim.fn.getwininfo.ret.item +--- @field botline integer +--- @field bufnr integer +--- @field height integer +--- @field loclist integer +--- @field quickfix integer +--- @field tabnr integer +--- @field terminal integer +--- @field textoff integer +--- @field topline integer +--- @field variables table<string,any> +--- @field width integer +--- @field winbar integer +--- @field wincol integer +--- @field winid integer +--- @field winnr integer +--- @field winrow integer + +--- @class vim.fn.sign_define.dict +--- @field text string +--- @field icon? string +--- @field linehl? string +--- @field numhl? string +--- @field texthl? string +--- @field culhl? string + +--- @class vim.fn.sign_getdefined.ret.item +--- @field name string +--- @field text string +--- @field icon? string +--- @field texthl? string +--- @field culhl? string +--- @field numhl? string +--- @field linehl? string + +--- @class vim.fn.sign_getplaced.dict +--- @field group? string +--- @field id? integer +--- @field lnum? string + +--- @class vim.fn.sign_getplaced.ret.item +--- @field buf integer +--- @field signs vim.fn.sign[] + +--- @class vim.fn.sign_place.dict +--- @field lnum? integer +--- @field priority? integer + +--- @class vim.fn.sign_placelist.list.item +--- @field buffer integer|string +--- @field group? string +--- @field id? integer +--- @field lnum integer +--- @field name string +--- @field priority? integer + +--- @class vim.fn.sign_unplace.dict +--- @field buffer? integer|string +--- @field id? integer + +--- @class vim.fn.sign_unplacelist.list.item +--- @field buffer? integer|string +--- @field group? string +--- @field id? integer + +--- @class vim.fn.winrestview.dict +--- @field col? integer +--- @field coladd? integer +--- @field curswant? integer +--- @field leftcol? integer +--- @field lnum? integer +--- @field skipcol? integer +--- @field topfill? integer +--- @field topline? integer + +--- @class vim.fn.winsaveview.ret +--- @field col integer +--- @field coladd integer +--- @field curswant integer +--- @field leftcol integer +--- @field lnum integer +--- @field skipcol integer +--- @field topfill integer +--- @field topline integer diff --git a/runtime/lua/vim/_meta/diff.lua b/runtime/lua/vim/_meta/diff.lua new file mode 100644 index 0000000000..f265139448 --- /dev/null +++ b/runtime/lua/vim/_meta/diff.lua @@ -0,0 +1,70 @@ +---@meta + +-- luacheck: no unused args + +--- Run diff on strings {a} and {b}. Any indices returned by this function, +--- either directly or via callback arguments, are 1-based. +--- +--- Examples: +--- +--- ```lua +--- vim.diff('a\n', 'b\nc\n') +--- -- => +--- -- @@ -1 +1,2 @@ +--- -- -a +--- -- +b +--- -- +c +--- +--- vim.diff('a\n', 'b\nc\n', {result_type = 'indices'}) +--- -- => +--- -- { +--- -- {1, 1, 1, 2} +--- -- } +--- ``` +--- +---@param a string First string to compare +---@param b string Second string to compare +---@param opts table<string,any> Optional parameters: +--- - `on_hunk` (callback): +--- Invoked for each hunk in the diff. Return a negative number +--- to cancel the callback for any remaining hunks. +--- Args: +--- - `start_a` (integer): Start line of hunk in {a}. +--- - `count_a` (integer): Hunk size in {a}. +--- - `start_b` (integer): Start line of hunk in {b}. +--- - `count_b` (integer): Hunk size in {b}. +--- - `result_type` (string): Form of the returned diff: +--- - "unified": (default) String in unified format. +--- - "indices": Array of hunk locations. +--- Note: This option is ignored if `on_hunk` is used. +--- - `linematch` (boolean|integer): Run linematch on the resulting hunks +--- from xdiff. When integer, only hunks upto this size in +--- lines are run through linematch. Requires `result_type = indices`, +--- ignored otherwise. +--- - `algorithm` (string): +--- Diff algorithm to use. Values: +--- - "myers" the default algorithm +--- - "minimal" spend extra time to generate the +--- smallest possible diff +--- - "patience" patience diff algorithm +--- - "histogram" histogram diff algorithm +--- - `ctxlen` (integer): Context length +--- - `interhunkctxlen` (integer): +--- Inter hunk context length +--- - `ignore_whitespace` (boolean): +--- Ignore whitespace +--- - `ignore_whitespace_change` (boolean): +--- Ignore whitespace change +--- - `ignore_whitespace_change_at_eol` (boolean) +--- Ignore whitespace change at end-of-line. +--- - `ignore_cr_at_eol` (boolean) +--- Ignore carriage return at end-of-line +--- - `ignore_blank_lines` (boolean) +--- Ignore blank lines +--- - `indent_heuristic` (boolean): +--- Use the indent heuristic for the internal +--- diff library. +--- +---@return string|table|nil +--- See {opts.result_type}. `nil` if {opts.on_hunk} is given. +function vim.diff(a, b, opts) end diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua new file mode 100644 index 0000000000..e010086615 --- /dev/null +++ b/runtime/lua/vim/_meta/json.lua @@ -0,0 +1,39 @@ +---@meta + +---@nodoc +vim.json = {} + +-- luacheck: no unused args + +---@defgroup vim.json +--- +--- This module provides encoding and decoding of Lua objects to and +--- from JSON-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|. + +--- Decodes (or "unpacks") the JSON-encoded {str} to a Lua object. +--- +--- - Decodes JSON "null" as |vim.NIL| (controllable by {opts}, see below). +--- - Decodes empty object as |vim.empty_dict()|. +--- - Decodes empty array as `{}` (empty Lua table). +--- +--- Example: +--- +--- ```lua +--- vim.print(vim.json.decode('{"bar":[],"foo":{},"zub":null}')) +--- -- { bar = {}, foo = vim.empty_dict(), zub = vim.NIL } +--- ``` +--- +---@param str string Stringified JSON data. +---@param opts? table<string,any> Options table with keys: +--- - luanil: (table) Table with keys: +--- * object: (boolean) When true, converts `null` in JSON objects +--- to Lua `nil` instead of |vim.NIL|. +--- * array: (boolean) When true, converts `null` in JSON arrays +--- to Lua `nil` instead of |vim.NIL|. +---@return any +function vim.json.decode(str, opts) end + +--- Encodes (or "packs") Lua object {obj} as JSON in a Lua string. +---@param obj any +---@return string +function vim.json.encode(obj) end diff --git a/runtime/lua/vim/_meta/lpeg.lua b/runtime/lua/vim/_meta/lpeg.lua new file mode 100644 index 0000000000..42c9a6449e --- /dev/null +++ b/runtime/lua/vim/_meta/lpeg.lua @@ -0,0 +1,323 @@ +--- @meta + +-- These types were taken from https://github.com/LuaCATS/lpeg, with types being renamed to include +-- the vim namespace and with some descriptions made less verbose. + +--- *LPeg* is a new pattern-matching library for Lua, based on [Parsing Expression Grammars](https://bford.info/packrat/) (PEGs). +vim.lpeg = {} + +--- @class vim.lpeg.Pattern +--- @operator unm: vim.lpeg.Pattern +--- @operator add(vim.lpeg.Pattern): vim.lpeg.Pattern +--- @operator sub(vim.lpeg.Pattern): vim.lpeg.Pattern +--- @operator mul(vim.lpeg.Pattern): vim.lpeg.Pattern +--- @operator mul(vim.lpeg.Capture): vim.lpeg.Pattern +--- @operator div(string): vim.lpeg.Capture +--- @operator div(number): vim.lpeg.Capture +--- @operator div(table): vim.lpeg.Capture +--- @operator div(function): vim.lpeg.Capture +--- @operator pow(number): vim.lpeg.Pattern +--- @operator mod(function): nil +local Pattern = {} + +--- @alias vim.lpeg.Capture vim.lpeg.Pattern + +--- Matches the given `pattern` against the `subject` string. If the match succeeds, returns the index in the +--- subject of the first character after the match, or the captured values (if the pattern captured any value). +--- An optional numeric argument `init` makes the match start at that position in the subject string. As usual +--- in Lua libraries, a negative value counts from the end. Unlike typical pattern-matching functions, `match` +--- works only in anchored mode; that is, it tries to match the pattern with a prefix of the given subject +--- string (at position `init`), not with an arbitrary substring of the subject. So, if we want to find a +--- pattern anywhere in a string, we must either write a loop in Lua or write a pattern that +--- matches anywhere. +--- +--- Example: +--- ```lua +--- local pattern = lpeg.R("az") ^ 1 * -1 +--- assert(pattern:match("hello") == 6) +--- assert(lpeg.match(pattern, "hello") == 6) +--- assert(pattern:match("1 hello") == nil) +--- ``` +--- +--- @param pattern vim.lpeg.Pattern +--- @param subject string +--- @param init? integer +--- @return integer|vim.lpeg.Capture|nil +function vim.lpeg.match(pattern, subject, init) end + +--- Matches the given `pattern` against the `subject` string. If the match succeeds, returns the +--- index in the subject of the first character after the match, or the captured values (if the +--- pattern captured any value). An optional numeric argument `init` makes the match start at +--- that position in the subject string. As usual in Lua libraries, a negative value counts from the end. +--- Unlike typical pattern-matching functions, `match` works only in anchored mode; that is, it tries +--- to match the pattern with a prefix of the given subject string (at position `init`), not with +--- an arbitrary substring of the subject. So, if we want to find a pattern anywhere in a string, +--- we must either write a loop in Lua or write a pattern that matches anywhere. +--- +--- Example: +--- ```lua +--- local pattern = lpeg.R("az") ^ 1 * -1 +--- assert(pattern:match("hello") == 6) +--- assert(lpeg.match(pattern, "hello") == 6) +--- assert(pattern:match("1 hello") == nil) +--- ``` +--- +--- @param subject string +--- @param init? integer +--- @return integer|vim.lpeg.Capture|nil +function Pattern:match(subject, init) end + +--- Returns the string `"pattern"` if the given value is a pattern, otherwise `nil`. +--- +--- @return 'pattern'|nil +function vim.lpeg.type(value) end + +--- Returns a string with the running version of LPeg. +--- @return string +function vim.lpeg.version() end + +--- Sets a limit for the size of the backtrack stack used by LPeg to track calls and choices. +--- The default limit is `400`. Most well-written patterns need little backtrack levels and +--- therefore you seldom need to change this limit; before changing it you should try to rewrite +--- your pattern to avoid the need for extra space. Nevertheless, a few useful patterns may overflow. +--- Also, with recursive grammars, subjects with deep recursion may also need larger limits. +--- +--- @param max integer +function vim.lpeg.setmaxstack(max) end + +--- Converts the given value into a proper pattern. This following rules are applied: +--- * If the argument is a pattern, it is returned unmodified. +--- * If the argument is a string, it is translated to a pattern that matches the string literally. +--- * If the argument is a non-negative number `n`, the result is a pattern that matches exactly `n` characters. +--- * If the argument is a negative number `-n`, the result is a pattern that succeeds only if +--- the input string has less than `n` characters left: `lpeg.P(-n)` is equivalent to `-lpeg.P(n)` +--- (see the unary minus operation). +--- * If the argument is a boolean, the result is a pattern that always succeeds or always fails +--- (according to the boolean value), without consuming any input. +--- * If the argument is a table, it is interpreted as a grammar (see Grammars). +--- * If the argument is a function, returns a pattern equivalent to a match-time captureover the empty string. +--- +--- @param value vim.lpeg.Pattern|string|integer|boolean|table|function +--- @return vim.lpeg.Pattern +function vim.lpeg.P(value) end + +--- Returns a pattern that matches only if the input string at the current position is preceded by `patt`. +--- Pattern `patt` must match only strings with some fixed length, and it cannot contain captures. +--- Like the and predicate, this pattern never consumes any input, independently of success or failure. +--- +--- @param pattern vim.lpeg.Pattern +--- @return vim.lpeg.Pattern +function vim.lpeg.B(pattern) end + +--- Returns a pattern that matches any single character belonging to one of the given ranges. +--- Each `range` is a string `xy` of length 2, representing all characters with code between the codes of +--- `x` and `y` (both inclusive). As an example, the pattern `lpeg.R("09")` matches any digit, and +--- `lpeg.R("az", "AZ")` matches any ASCII letter. +--- +--- Example: +--- ```lua +--- local pattern = lpeg.R("az") ^ 1 * -1 +--- assert(pattern:match("hello") == 6) +--- ``` +--- +--- @param ... string +--- @return vim.lpeg.Pattern +function vim.lpeg.R(...) end + +--- Returns a pattern that matches any single character that appears in the given string (the `S` stands for Set). +--- As an example, the pattern `lpeg.S("+-*/")` matches any arithmetic operator. Note that, if `s` is a character +--- (that is, a string of length 1), then `lpeg.P(s)` is equivalent to `lpeg.S(s)` which is equivalent to +--- `lpeg.R(s..s)`. Note also that both `lpeg.S("")` and `lpeg.R()` are patterns that always fail. +--- +--- @param string string +--- @return vim.lpeg.Pattern +function vim.lpeg.S(string) end + +--- Creates a non-terminal (a variable) for a grammar. This operation creates a non-terminal (a variable) +--- for a grammar. The created non-terminal refers to the rule indexed by `v` in the enclosing grammar. +--- +--- Example: +--- ```lua +--- local b = lpeg.P({"(" * ((1 - lpeg.S "()") + lpeg.V(1)) ^ 0 * ")"}) +--- assert(b:match('((string))') == 11) +--- assert(b:match('(') == nil) +--- ``` +--- +--- @param v string|integer +--- @return vim.lpeg.Pattern +function vim.lpeg.V(v) end + +--- @class vim.lpeg.Locale +--- @field alnum userdata +--- @field alpha userdata +--- @field cntrl userdata +--- @field digit userdata +--- @field graph userdata +--- @field lower userdata +--- @field print userdata +--- @field punct userdata +--- @field space userdata +--- @field upper userdata +--- @field xdigit userdata + +--- Returns a table with patterns for matching some character classes according to the current locale. +--- The table has fields named `alnum`, `alpha`, `cntrl`, `digit`, `graph`, `lower`, `print`, `punct`, +--- `space`, `upper`, and `xdigit`, each one containing a correspondent pattern. Each pattern matches +--- any single character that belongs to its class. +--- If called with an argument `table`, then it creates those fields inside the given table and returns +--- that table. +--- +--- Example: +--- ```lua +--- lpeg.locale(lpeg) +--- local space = lpeg.space^0 +--- local name = lpeg.C(lpeg.alpha^1) * space +--- local sep = lpeg.S(",;") * space +--- local pair = lpeg.Cg(name * "=" * space * name) * sep^-1 +--- local list = lpeg.Cf(lpeg.Ct("") * pair^0, rawset) +--- local t = list:match("a=b, c = hi; next = pi") +--- assert(t.a == 'b') +--- assert(t.c == 'hi') +--- assert(t.next == 'pi') +--- local locale = lpeg.locale() +--- assert(type(locale.digit) == 'userdata') +--- ``` +--- +--- @param tab? table +--- @return vim.lpeg.Locale +function vim.lpeg.locale(tab) end + +--- Creates a simple capture, which captures the substring of the subject that matches `patt`. +--- The captured value is a string. If `patt` has other captures, their values are returned after this one. +--- +--- Example: +--- ```lua +--- local function split (s, sep) +--- sep = lpeg.P(sep) +--- local elem = lpeg.C((1 - sep)^0) +--- local p = elem * (sep * elem)^0 +--- return lpeg.match(p, s) +--- end +--- local a, b, c = split('a,b,c', ',') +--- assert(a == 'a') +--- assert(b == 'b') +--- assert(c == 'c') +--- ``` +--- +--- @param patt vim.lpeg.Pattern +--- @return vim.lpeg.Capture +function vim.lpeg.C(patt) end + +--- Creates an argument capture. This pattern matches the empty string and produces the value given as the +--- nth extra argument given in the call to `lpeg.match`. +--- @param n integer +--- @return vim.lpeg.Capture +function vim.lpeg.Carg(n) end + +--- Creates a back capture. This pattern matches the empty string and produces the values produced by the most recent +--- group capture named `name` (where `name` can be any Lua value). Most recent means the last complete outermost +--- group capture with the given name. A Complete capture means that the entire pattern corresponding to the capture +--- has matched. An Outermost capture means that the capture is not inside another complete capture. +--- In the same way that LPeg does not specify when it evaluates captures, it does not specify whether it reuses +--- values previously produced by the group or re-evaluates them. +--- +--- @param name any +--- @return vim.lpeg.Capture +function vim.lpeg.Cb(name) end + +--- Creates a constant capture. This pattern matches the empty string and produces all given values as its captured values. +--- +--- @param ... any +--- @return vim.lpeg.Capture +function vim.lpeg.Cc(...) end + +--- Creates a fold capture. If `patt` produces a list of captures C1 C2 ... Cn, this capture will produce the value +--- `func(...func(func(C1, C2), C3)...,Cn)`, that is, it will fold (or accumulate, or reduce) the captures from +--- `patt` using function `func`. This capture assumes that `patt` should produce at least one capture with at +--- least one value (of any type), which becomes the initial value of an accumulator. (If you need a specific +--- initial value, you may prefix a constant captureto `patt`.) For each subsequent capture, LPeg calls `func` +--- with this accumulator as the first argument and all values produced by the capture as extra arguments; +--- the first result from this call becomes the new value for the accumulator. The final value of the accumulator +--- becomes the captured value. +--- +--- Example: +--- ```lua +--- local number = lpeg.R("09") ^ 1 / tonumber +--- local list = number * ("," * number) ^ 0 +--- local function add(acc, newvalue) return acc + newvalue end +--- local sum = lpeg.Cf(list, add) +--- assert(sum:match("10,30,43") == 83) +--- ``` +--- +--- @param patt vim.lpeg.Pattern +--- @param func fun(acc, newvalue) +--- @return vim.lpeg.Capture +function vim.lpeg.Cf(patt, func) end + +--- Creates a group capture. It groups all values returned by `patt` into a single capture. +--- The group may be anonymous (if no name is given) or named with the given name (which +--- can be any non-nil Lua value). +--- +--- @param patt vim.lpeg.Pattern +--- @param name? string +--- @return vim.lpeg.Capture +function vim.lpeg.Cg(patt, name) end + +--- Creates a position capture. It matches the empty string and captures the position in the +--- subject where the match occurs. The captured value is a number. +--- +--- Example: +--- ```lua +--- local I = lpeg.Cp() +--- local function anywhere(p) return lpeg.P({I * p * I + 1 * lpeg.V(1)}) end +--- local match_start, match_end = anywhere("world"):match("hello world!") +--- assert(match_start == 7) +--- assert(match_end == 12) +--- ``` +--- +--- @return vim.lpeg.Capture +function vim.lpeg.Cp() end + +--- Creates a substitution capture. This function creates a substitution capture, which +--- captures the substring of the subject that matches `patt`, with substitutions. +--- For any capture inside `patt` with a value, the substring that matched the capture +--- is replaced by the capture value (which should be a string). The final captured +--- value is the string resulting from all replacements. +--- +--- Example: +--- ```lua +--- local function gsub (s, patt, repl) +--- patt = lpeg.P(patt) +--- patt = lpeg.Cs((patt / repl + 1)^0) +--- return lpeg.match(patt, s) +--- end +--- assert(gsub('Hello, xxx!', 'xxx', 'World') == 'Hello, World!') +--- ``` +--- +--- @param patt vim.lpeg.Pattern +--- @return vim.lpeg.Capture +function vim.lpeg.Cs(patt) end + +--- Creates a table capture. This capture returns a table with all values from all anonymous captures +--- made by `patt` inside this table in successive integer keys, starting at 1. +--- Moreover, for each named capture group created by `patt`, the first value of the group is put into +--- the table with the group name as its key. The captured value is only the table. +--- +--- @param patt vim.lpeg.Pattern|'' +--- @return vim.lpeg.Capture +function vim.lpeg.Ct(patt) end + +--- Creates a match-time capture. Unlike all other captures, this one is evaluated immediately when a match occurs +--- (even if it is part of a larger pattern that fails later). It forces the immediate evaluation of all its nested captures +--- and then calls `function`. The given function gets as arguments the entire subject, the current position +--- (after the match of `patt`), plus any capture values produced by `patt`. The first value returned by `function` +--- defines how the match happens. If the call returns a number, the match succeeds and the returned number +--- becomes the new current position. (Assuming a subject sand current position i, the returned number must be +--- in the range [i, len(s) + 1].) If the call returns true, the match succeeds without consuming any input +--- (so, to return true is equivalent to return i). If the call returns false, nil, or no value, the match fails. +--- Any extra values returned by the function become the values produced by the capture. +--- +--- @param patt vim.lpeg.Pattern +--- @param fn function +--- @return vim.lpeg.Capture +function vim.lpeg.Cmt(patt, fn) end diff --git a/runtime/lua/vim/_meta/misc.lua b/runtime/lua/vim/_meta/misc.lua new file mode 100644 index 0000000000..0d70e16314 --- /dev/null +++ b/runtime/lua/vim/_meta/misc.lua @@ -0,0 +1,15 @@ +---@meta + +-- luacheck: no unused args + +--- Invokes |vim-function| or |user-function| {func} with arguments {...}. +--- See also |vim.fn|. +--- Equivalent to: +--- +--- ```lua +--- vim.fn[func]({...}) +--- ``` +--- +--- @param func fun() +--- @param ... any +function vim.call(func, ...) end diff --git a/runtime/lua/vim/_meta/mpack.lua b/runtime/lua/vim/_meta/mpack.lua new file mode 100644 index 0000000000..54e097ad97 --- /dev/null +++ b/runtime/lua/vim/_meta/mpack.lua @@ -0,0 +1,15 @@ +--- @meta + +-- luacheck: no unused args + +--- @defgroup vim.mpack +--- +--- This module provides encoding and decoding of Lua objects to and +--- from msgpack-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|. + +--- Decodes (or "unpacks") the msgpack-encoded {str} to a Lua object. +--- @param str string +function vim.mpack.decode(str) end + +--- Encodes (or "packs") Lua object {obj} as msgpack in a Lua string. +function vim.mpack.encode(obj) end diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua new file mode 100644 index 0000000000..d2bdab4d28 --- /dev/null +++ b/runtime/lua/vim/_meta/options.lua @@ -0,0 +1,7958 @@ +--- @meta _ +-- THIS FILE IS GENERATED +-- DO NOT EDIT +error('Cannot require a meta file') + +---@class vim.bo +---@field [integer] vim.bo +vim.bo = vim.bo + +---@class vim.wo +---@field [integer] vim.wo +vim.wo = vim.wo + +--- Allow CTRL-_ in Insert and Command-line mode. This is default off, to +--- avoid that users that accidentally type CTRL-_ instead of SHIFT-_ get +--- into reverse Insert mode, and don't know how to get out. See +--- 'revins'. +--- +--- @type boolean +vim.o.allowrevins = false +vim.o.ari = vim.o.allowrevins +vim.go.allowrevins = vim.o.allowrevins +vim.go.ari = vim.go.allowrevins + +--- Tells Vim what to do with characters with East Asian Width Class +--- Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek +--- letters, Cyrillic letters). +--- +--- There are currently two possible values: +--- "single": Use the same width as characters in US-ASCII. This is +--- expected by most users. +--- "double": Use twice the width of ASCII characters. +--- *E834* *E835* +--- The value "double" cannot be used if 'listchars' or 'fillchars' +--- contains a character that would be double width. These errors may +--- also be given when calling setcellwidths(). +--- +--- The values are overruled for characters specified with +--- `setcellwidths()`. +--- +--- There are a number of CJK fonts for which the width of glyphs for +--- those characters are solely based on how many octets they take in +--- legacy/traditional CJK encodings. In those encodings, Euro, +--- Registered sign, Greek/Cyrillic letters are represented by two octets, +--- therefore those fonts have "wide" glyphs for them. This is also +--- true of some line drawing characters used to make tables in text +--- file. Therefore, when a CJK font is used for GUI Vim or +--- Vim is running inside a terminal (emulators) that uses a CJK font +--- (or Vim is run inside an xterm invoked with "-cjkwidth" option.), +--- this option should be set to "double" to match the width perceived +--- by Vim with the width of glyphs in the font. Perhaps it also has +--- to be set to "double" under CJK MS-Windows when the system locale is +--- set to one of CJK locales. See Unicode Standard Annex #11 +--- (https://www.unicode.org/reports/tr11). +--- +--- @type string +vim.o.ambiwidth = "single" +vim.o.ambw = vim.o.ambiwidth +vim.go.ambiwidth = vim.o.ambiwidth +vim.go.ambw = vim.go.ambiwidth + +--- This option can be set to start editing Arabic text. +--- Setting this option will: +--- - Set the 'rightleft' option, unless 'termbidi' is set. +--- - Set the 'arabicshape' option, unless 'termbidi' is set. +--- - Set the 'keymap' option to "arabic"; in Insert mode CTRL-^ toggles +--- between typing English and Arabic key mapping. +--- - Set the 'delcombine' option +--- +--- Resetting this option will: +--- - Reset the 'rightleft' option. +--- - Disable the use of 'keymap' (without changing its value). +--- Note that 'arabicshape' and 'delcombine' are not reset (it is a global +--- option). +--- Also see `arabic.txt`. +--- +--- @type boolean +vim.o.arabic = false +vim.o.arab = vim.o.arabic +vim.wo.arabic = vim.o.arabic +vim.wo.arab = vim.wo.arabic + +--- When on and 'termbidi' is off, the required visual character +--- corrections that need to take place for displaying the Arabic language +--- take effect. Shaping, in essence, gets enabled; the term is a broad +--- one which encompasses: +--- a) the changing/morphing of characters based on their location +--- within a word (initial, medial, final and stand-alone). +--- b) the enabling of the ability to compose characters +--- c) the enabling of the required combining of some characters +--- When disabled the display shows each character's true stand-alone +--- form. +--- Arabic is a complex language which requires other settings, for +--- further details see `arabic.txt`. +--- +--- @type boolean +vim.o.arabicshape = true +vim.o.arshape = vim.o.arabicshape +vim.go.arabicshape = vim.o.arabicshape +vim.go.arshape = vim.go.arabicshape + +--- When on, Vim will change the current working directory whenever you +--- open a file, switch buffers, delete a buffer or open/close a window. +--- It will change to the directory containing the file which was opened +--- or selected. When a buffer has no name it also has no directory, thus +--- the current directory won't change when navigating to it. +--- Note: When this option is on some plugins may not work. +--- +--- @type boolean +vim.o.autochdir = false +vim.o.acd = vim.o.autochdir +vim.go.autochdir = vim.o.autochdir +vim.go.acd = vim.go.autochdir + +--- Copy indent from current line when starting a new line (typing <CR> +--- in Insert mode or when using the "o" or "O" command). If you do not +--- type anything on the new line except <BS> or CTRL-D and then type +--- <Esc>, CTRL-O or <CR>, the indent is deleted again. Moving the cursor +--- to another line has the same effect, unless the 'I' flag is included +--- in 'cpoptions'. +--- When autoindent is on, formatting (with the "gq" command or when you +--- reach 'textwidth' in Insert mode) uses the indentation of the first +--- line. +--- When 'smartindent' or 'cindent' is on the indent is changed in +--- a different way. +--- +--- @type boolean +vim.o.autoindent = true +vim.o.ai = vim.o.autoindent +vim.bo.autoindent = vim.o.autoindent +vim.bo.ai = vim.bo.autoindent + +--- When a file has been detected to have been changed outside of Vim and +--- it has not been changed inside of Vim, automatically read it again. +--- When the file has been deleted this is not done, so you have the text +--- from before it was deleted. When it appears again then it is read. +--- `timestamp` +--- If this option has a local value, use this command to switch back to +--- using the global value: +--- ``` +--- :set autoread< +--- ``` +--- +--- +--- @type boolean +vim.o.autoread = true +vim.o.ar = vim.o.autoread +vim.bo.autoread = vim.o.autoread +vim.bo.ar = vim.bo.autoread +vim.go.autoread = vim.o.autoread +vim.go.ar = vim.go.autoread + +--- Write the contents of the file, if it has been modified, on each +--- `:next`, `:rewind`, `:last`, `:first`, `:previous`, `:stop`, +--- `:suspend`, `:tag`, `:!`, `:make`, CTRL-] and CTRL-^ command; and when +--- a `:buffer`, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one +--- to another file. +--- A buffer is not written if it becomes hidden, e.g. when 'bufhidden' is +--- set to "hide" and `:next` is used. +--- Note that for some commands the 'autowrite' option is not used, see +--- 'autowriteall' for that. +--- Some buffers will not be written, specifically when 'buftype' is +--- "nowrite", "nofile", "terminal" or "prompt". +--- USE WITH CARE: If you make temporary changes to a buffer that you +--- don't want to be saved this option may cause it to be saved anyway. +--- Renaming the buffer with ":file {name}" may help avoid this. +--- +--- @type boolean +vim.o.autowrite = false +vim.o.aw = vim.o.autowrite +vim.go.autowrite = vim.o.autowrite +vim.go.aw = vim.go.autowrite + +--- Like 'autowrite', but also used for commands ":edit", ":enew", ":quit", +--- ":qall", ":exit", ":xit", ":recover" and closing the Vim window. +--- Setting this option also implies that Vim behaves like 'autowrite' has +--- been set. +--- +--- @type boolean +vim.o.autowriteall = false +vim.o.awa = vim.o.autowriteall +vim.go.autowriteall = vim.o.autowriteall +vim.go.awa = vim.go.autowriteall + +--- When set to "dark" or "light", adjusts the default color groups for +--- that background type. The `TUI` or other UI sets this on startup +--- (triggering `OptionSet`) if it can detect the background color. +--- +--- This option does NOT change the background color, it tells Nvim what +--- the "inherited" (terminal/GUI) background looks like. +--- See `:hi-normal` if you want to set the background color explicitly. +--- *g:colors_name* +--- When a color scheme is loaded (the "g:colors_name" variable is set) +--- setting 'background' will cause the color scheme to be reloaded. If +--- the color scheme adjusts to the value of 'background' this will work. +--- However, if the color scheme sets 'background' itself the effect may +--- be undone. First delete the "g:colors_name" variable when needed. +--- +--- Normally this option would be set in the vimrc file. Possibly +--- depending on the terminal name. Example: +--- ``` +--- :if $TERM ==# "xterm" +--- : set background=dark +--- :endif +--- ``` +--- When this option is set, the default settings for the highlight groups +--- will change. To use other settings, place ":highlight" commands AFTER +--- the setting of the 'background' option. +--- This option is also used in the "$VIMRUNTIME/syntax/syntax.vim" file +--- to select the colors for syntax highlighting. After changing this +--- option, you must load syntax.vim again to see the result. This can be +--- done with ":syntax on". +--- +--- @type string +vim.o.background = "dark" +vim.o.bg = vim.o.background +vim.go.background = vim.o.background +vim.go.bg = vim.go.background + +--- Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert +--- mode. This is a list of items, separated by commas. Each item allows +--- a way to backspace over something: +--- value effect ~ +--- indent allow backspacing over autoindent +--- eol allow backspacing over line breaks (join lines) +--- start allow backspacing over the start of insert; CTRL-W and CTRL-U +--- stop once at the start of insert. +--- nostop like start, except CTRL-W and CTRL-U do not stop at the start of +--- insert. +--- +--- When the value is empty, Vi compatible backspacing is used, none of +--- the ways mentioned for the items above are possible. +--- +--- @type string +vim.o.backspace = "indent,eol,start" +vim.o.bs = vim.o.backspace +vim.go.backspace = vim.o.backspace +vim.go.bs = vim.go.backspace + +--- Make a backup before overwriting a file. Leave it around after the +--- file has been successfully written. If you do not want to keep the +--- backup file, but you do want a backup while the file is being +--- written, reset this option and set the 'writebackup' option (this is +--- the default). If you do not want a backup file at all reset both +--- options (use this if your file system is almost full). See the +--- `backup-table` for more explanations. +--- When the 'backupskip' pattern matches, a backup is not made anyway. +--- When 'patchmode' is set, the backup may be renamed to become the +--- oldest version of a file. +--- +--- @type boolean +vim.o.backup = false +vim.o.bk = vim.o.backup +vim.go.backup = vim.o.backup +vim.go.bk = vim.go.backup + +--- When writing a file and a backup is made, this option tells how it's +--- done. This is a comma-separated list of words. +--- +--- The main values are: +--- "yes" make a copy of the file and overwrite the original one +--- "no" rename the file and write a new one +--- "auto" one of the previous, what works best +--- +--- Extra values that can be combined with the ones above are: +--- "breaksymlink" always break symlinks when writing +--- "breakhardlink" always break hardlinks when writing +--- +--- Making a copy and overwriting the original file: +--- - Takes extra time to copy the file. +--- + When the file has special attributes, is a (hard/symbolic) link or +--- has a resource fork, all this is preserved. +--- - When the file is a link the backup will have the name of the link, +--- not of the real file. +--- +--- Renaming the file and writing a new one: +--- + It's fast. +--- - Sometimes not all attributes of the file can be copied to the new +--- file. +--- - When the file is a link the new file will not be a link. +--- +--- The "auto" value is the middle way: When Vim sees that renaming the +--- file is possible without side effects (the attributes can be passed on +--- and the file is not a link) that is used. When problems are expected, +--- a copy will be made. +--- +--- The "breaksymlink" and "breakhardlink" values can be used in +--- combination with any of "yes", "no" and "auto". When included, they +--- force Vim to always break either symbolic or hard links by doing +--- exactly what the "no" option does, renaming the original file to +--- become the backup and writing a new file in its place. This can be +--- useful for example in source trees where all the files are symbolic or +--- hard links and any changes should stay in the local source tree, not +--- be propagated back to the original source. +--- *crontab* +--- One situation where "no" and "auto" will cause problems: A program +--- that opens a file, invokes Vim to edit that file, and then tests if +--- the open file was changed (through the file descriptor) will check the +--- backup file instead of the newly created file. "crontab -e" is an +--- example. +--- +--- When a copy is made, the original file is truncated and then filled +--- with the new text. This means that protection bits, owner and +--- symbolic links of the original file are unmodified. The backup file, +--- however, is a new file, owned by the user who edited the file. The +--- group of the backup is set to the group of the original file. If this +--- fails, the protection bits for the group are made the same as for +--- others. +--- +--- When the file is renamed, this is the other way around: The backup has +--- the same attributes of the original file, and the newly written file +--- is owned by the current user. When the file was a (hard/symbolic) +--- link, the new file will not! That's why the "auto" value doesn't +--- rename when the file is a link. The owner and group of the newly +--- written file will be set to the same ones as the original file, but +--- the system may refuse to do this. In that case the "auto" value will +--- again not rename the file. +--- +--- @type string +vim.o.backupcopy = "auto" +vim.o.bkc = vim.o.backupcopy +vim.bo.backupcopy = vim.o.backupcopy +vim.bo.bkc = vim.bo.backupcopy +vim.go.backupcopy = vim.o.backupcopy +vim.go.bkc = vim.go.backupcopy + +--- List of directories for the backup file, separated with commas. +--- - The backup file will be created in the first directory in the list +--- where this is possible. If none of the directories exist Nvim will +--- attempt to create the last directory in the list. +--- - Empty means that no backup file will be created ('patchmode' is +--- impossible!). Writing may fail because of this. +--- - A directory "." means to put the backup file in the same directory +--- as the edited file. +--- - A directory starting with "./" (or ".\" for MS-Windows) means to put +--- the backup file relative to where the edited file is. The leading +--- "." is replaced with the path name of the edited file. +--- ("." inside a directory name has no special meaning). +--- - Spaces after the comma are ignored, other spaces are considered part +--- of the directory name. To have a space at the start of a directory +--- name, precede it with a backslash. +--- - To include a comma in a directory name precede it with a backslash. +--- - A directory name may end in an '/'. +--- - For Unix and Win32, if a directory ends in two path separators "//", +--- the swap file name will be built from the complete path to the file +--- with all path separators changed to percent '%' signs. This will +--- ensure file name uniqueness in the backup directory. +--- On Win32, it is also possible to end with "\\". However, When a +--- separating comma is following, you must use "//", since "\\" will +--- include the comma in the file name. Therefore it is recommended to +--- use '//', instead of '\\'. +--- - Environment variables are expanded `:set_env`. +--- - Careful with '\' characters, type one before a space, type two to +--- get one in the option (see `option-backslash`), for example: +--- ``` +--- :set bdir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces +--- ``` +--- +--- See also 'backup' and 'writebackup' options. +--- If you want to hide your backup files on Unix, consider this value: +--- ``` +--- :set backupdir=./.backup,~/.backup,.,/tmp +--- ``` +--- You must create a ".backup" directory in each directory and in your +--- home directory for this to work properly. +--- The use of `:set+=` and `:set-=` is preferred when adding or removing +--- directories from the list. This avoids problems when a future version +--- uses another default. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.backupdir = ".,$XDG_STATE_HOME/nvim/backup//" +vim.o.bdir = vim.o.backupdir +vim.go.backupdir = vim.o.backupdir +vim.go.bdir = vim.go.backupdir + +--- String which is appended to a file name to make the name of the +--- backup file. The default is quite unusual, because this avoids +--- accidentally overwriting existing files with a backup file. You might +--- prefer using ".bak", but make sure that you don't have files with +--- ".bak" that you want to keep. +--- Only normal file name characters can be used; `/\*?[|<>` are illegal. +--- +--- If you like to keep a lot of backups, you could use a BufWritePre +--- autocommand to change 'backupext' just before writing the file to +--- include a timestamp. +--- ``` +--- :au BufWritePre * let &bex = '-' .. strftime("%Y%b%d%X") .. '~' +--- ``` +--- Use 'backupdir' to put the backup in a different directory. +--- +--- @type string +vim.o.backupext = "~" +vim.o.bex = vim.o.backupext +vim.go.backupext = vim.o.backupext +vim.go.bex = vim.go.backupext + +--- A list of file patterns. When one of the patterns matches with the +--- name of the file which is written, no backup file is created. Both +--- the specified file name and the full path name of the file are used. +--- The pattern is used like with `:autocmd`, see `autocmd-pattern`. +--- Watch out for special characters, see `option-backslash`. +--- When $TMPDIR, $TMP or $TEMP is not defined, it is not used for the +--- default value. "/tmp/*" is only used for Unix. +--- +--- WARNING: Not having a backup file means that when Vim fails to write +--- your buffer correctly and then, for whatever reason, Vim exits, you +--- lose both the original file and what you were writing. Only disable +--- backups if you don't care about losing the file. +--- +--- Note that environment variables are not expanded. If you want to use +--- $HOME you must expand it explicitly, e.g.: +--- +--- ```vim +--- :let &backupskip = escape(expand('$HOME'), '\') .. '/tmp/*' +--- ``` +--- Note that the default also makes sure that "crontab -e" works (when a +--- backup would be made by renaming the original file crontab won't see +--- the newly created file). Also see 'backupcopy' and `crontab`. +--- +--- @type string +vim.o.backupskip = "/tmp/*" +vim.o.bsk = vim.o.backupskip +vim.go.backupskip = vim.o.backupskip +vim.go.bsk = vim.go.backupskip + +--- Specifies for which events the bell will not be rung. It is a comma- +--- separated list of items. For each item that is present, the bell +--- will be silenced. This is most useful to specify specific events in +--- insert mode to be silenced. +--- +--- item meaning when present ~ +--- all All events. +--- backspace When hitting <BS> or <Del> and deleting results in an +--- error. +--- cursor Fail to move around using the cursor keys or +--- <PageUp>/<PageDown> in `Insert-mode`. +--- complete Error occurred when using `i_CTRL-X_CTRL-K` or +--- `i_CTRL-X_CTRL-T`. +--- copy Cannot copy char from insert mode using `i_CTRL-Y` or +--- `i_CTRL-E`. +--- ctrlg Unknown Char after <C-G> in Insert mode. +--- error Other Error occurred (e.g. try to join last line) +--- (mostly used in `Normal-mode` or `Cmdline-mode`). +--- esc hitting <Esc> in `Normal-mode`. +--- hangul Ignored. +--- lang Calling the beep module for Lua/Mzscheme/TCL. +--- mess No output available for `g<`. +--- showmatch Error occurred for 'showmatch' function. +--- operator Empty region error `cpo-E`. +--- register Unknown register after <C-R> in `Insert-mode`. +--- shell Bell from shell output `:!`. +--- spell Error happened on spell suggest. +--- wildmode More matches in `cmdline-completion` available +--- (depends on the 'wildmode' setting). +--- +--- This is most useful to fine tune when in Insert mode the bell should +--- be rung. For Normal mode and Ex commands, the bell is often rung to +--- indicate that an error occurred. It can be silenced by adding the +--- "error" keyword. +--- +--- @type string +vim.o.belloff = "all" +vim.o.bo = vim.o.belloff +vim.go.belloff = vim.o.belloff +vim.go.bo = vim.go.belloff + +--- This option should be set before editing a binary file. You can also +--- use the `-b` Vim argument. When this option is switched on a few +--- options will be changed (also when it already was on): +--- 'textwidth' will be set to 0 +--- 'wrapmargin' will be set to 0 +--- 'modeline' will be off +--- 'expandtab' will be off +--- Also, 'fileformat' and 'fileformats' options will not be used, the +--- file is read and written like 'fileformat' was "unix" (a single <NL> +--- separates lines). +--- The 'fileencoding' and 'fileencodings' options will not be used, the +--- file is read without conversion. +--- NOTE: When you start editing a(nother) file while the 'bin' option is +--- on, settings from autocommands may change the settings again (e.g., +--- 'textwidth'), causing trouble when editing. You might want to set +--- 'bin' again when the file has been loaded. +--- The previous values of these options are remembered and restored when +--- 'bin' is switched from on to off. Each buffer has its own set of +--- saved option values. +--- To edit a file with 'binary' set you can use the `++bin` argument. +--- This avoids you have to do ":set bin", which would have effect for all +--- files you edit. +--- When writing a file the <EOL> for the last line is only written if +--- there was one in the original file (normally Vim appends an <EOL> to +--- the last line if there is none; this would make the file longer). See +--- the 'endofline' option. +--- +--- @type boolean +vim.o.binary = false +vim.o.bin = vim.o.binary +vim.bo.binary = vim.o.binary +vim.bo.bin = vim.bo.binary + +--- When writing a file and the following conditions are met, a BOM (Byte +--- Order Mark) is prepended to the file: +--- - this option is on +--- - the 'binary' option is off +--- - 'fileencoding' is "utf-8", "ucs-2", "ucs-4" or one of the little/big +--- endian variants. +--- Some applications use the BOM to recognize the encoding of the file. +--- Often used for UCS-2 files on MS-Windows. For other applications it +--- causes trouble, for example: "cat file1 file2" makes the BOM of file2 +--- appear halfway through the resulting file. Gcc doesn't accept a BOM. +--- When Vim reads a file and 'fileencodings' starts with "ucs-bom", a +--- check for the presence of the BOM is done and 'bomb' set accordingly. +--- Unless 'binary' is set, it is removed from the first line, so that you +--- don't see it when editing. When you don't change the options, the BOM +--- will be restored when writing the file. +--- +--- @type boolean +vim.o.bomb = false +vim.bo.bomb = vim.o.bomb + +--- This option lets you choose which characters might cause a line +--- break if 'linebreak' is on. Only works for ASCII characters. +--- +--- @type string +vim.o.breakat = " \t!@*-+;:,./?" +vim.o.brk = vim.o.breakat +vim.go.breakat = vim.o.breakat +vim.go.brk = vim.go.breakat + +--- Every wrapped line will continue visually indented (same amount of +--- space as the beginning of that line), thus preserving horizontal blocks +--- of text. +--- +--- @type boolean +vim.o.breakindent = false +vim.o.bri = vim.o.breakindent +vim.wo.breakindent = vim.o.breakindent +vim.wo.bri = vim.wo.breakindent + +--- Settings for 'breakindent'. It can consist of the following optional +--- items and must be separated by a comma: +--- min:{n} Minimum text width that will be kept after +--- applying 'breakindent', even if the resulting +--- text should normally be narrower. This prevents +--- text indented almost to the right window border +--- occupying lot of vertical space when broken. +--- (default: 20) +--- shift:{n} After applying 'breakindent', the wrapped line's +--- beginning will be shifted by the given number of +--- characters. It permits dynamic French paragraph +--- indentation (negative) or emphasizing the line +--- continuation (positive). +--- (default: 0) +--- sbr Display the 'showbreak' value before applying the +--- additional indent. +--- (default: off) +--- list:{n} Adds an additional indent for lines that match a +--- numbered or bulleted list (using the +--- 'formatlistpat' setting). +--- list:-1 Uses the length of a match with 'formatlistpat' +--- for indentation. +--- (default: 0) +--- column:{n} Indent at column {n}. Will overrule the other +--- sub-options. Note: an additional indent may be +--- added for the 'showbreak' setting. +--- (default: off) +--- +--- @type string +vim.o.breakindentopt = "" +vim.o.briopt = vim.o.breakindentopt +vim.wo.breakindentopt = vim.o.breakindentopt +vim.wo.briopt = vim.wo.breakindentopt + +--- Which directory to use for the file browser: +--- last Use same directory as with last file browser, where a +--- file was opened or saved. +--- buffer Use the directory of the related buffer. +--- current Use the current directory. +--- {path} Use the specified directory +--- +--- @type string +vim.o.browsedir = "" +vim.o.bsdir = vim.o.browsedir +vim.go.browsedir = vim.o.browsedir +vim.go.bsdir = vim.go.browsedir + +--- This option specifies what happens when a buffer is no longer +--- displayed in a window: +--- <empty> follow the global 'hidden' option +--- hide hide the buffer (don't unload it), even if 'hidden' is +--- not set +--- unload unload the buffer, even if 'hidden' is set; the +--- `:hide` command will also unload the buffer +--- delete delete the buffer from the buffer list, even if +--- 'hidden' is set; the `:hide` command will also delete +--- the buffer, making it behave like `:bdelete` +--- wipe wipe the buffer from the buffer list, even if +--- 'hidden' is set; the `:hide` command will also wipe +--- out the buffer, making it behave like `:bwipeout` +--- +--- CAREFUL: when "unload", "delete" or "wipe" is used changes in a buffer +--- are lost without a warning. Also, these values may break autocommands +--- that switch between buffers temporarily. +--- This option is used together with 'buftype' and 'swapfile' to specify +--- special kinds of buffers. See `special-buffers`. +--- +--- @type string +vim.o.bufhidden = "" +vim.o.bh = vim.o.bufhidden +vim.bo.bufhidden = vim.o.bufhidden +vim.bo.bh = vim.bo.bufhidden + +--- When this option is set, the buffer shows up in the buffer list. If +--- it is reset it is not used for ":bnext", "ls", the Buffers menu, etc. +--- This option is reset by Vim for buffers that are only used to remember +--- a file name or marks. Vim sets it when starting to edit a buffer. +--- But not when moving to a buffer with ":buffer". +--- +--- @type boolean +vim.o.buflisted = true +vim.o.bl = vim.o.buflisted +vim.bo.buflisted = vim.o.buflisted +vim.bo.bl = vim.bo.buflisted + +--- The value of this option specifies the type of a buffer: +--- <empty> normal buffer +--- acwrite buffer will always be written with `BufWriteCmd`s +--- help help buffer (do not set this manually) +--- nofile buffer is not related to a file, will not be written +--- nowrite buffer will not be written +--- quickfix list of errors `:cwindow` or locations `:lwindow` +--- terminal `terminal-emulator` buffer +--- prompt buffer where only the last line can be edited, meant +--- to be used by a plugin, see `prompt-buffer` +--- +--- This option is used together with 'bufhidden' and 'swapfile' to +--- specify special kinds of buffers. See `special-buffers`. +--- Also see `win_gettype()`, which returns the type of the window. +--- +--- Be careful with changing this option, it can have many side effects! +--- One such effect is that Vim will not check the timestamp of the file, +--- if the file is changed by another program this will not be noticed. +--- +--- A "quickfix" buffer is only used for the error list and the location +--- list. This value is set by the `:cwindow` and `:lwindow` commands and +--- you are not supposed to change it. +--- +--- "nofile" and "nowrite" buffers are similar: +--- both: The buffer is not to be written to disk, ":w" doesn't +--- work (":w filename" does work though). +--- both: The buffer is never considered to be `'modified'`. +--- There is no warning when the changes will be lost, for +--- example when you quit Vim. +--- both: A swap file is only created when using too much memory +--- (when 'swapfile' has been reset there is never a swap +--- file). +--- nofile only: The buffer name is fixed, it is not handled like a +--- file name. It is not modified in response to a `:cd` +--- command. +--- both: When using ":e bufname" and already editing "bufname" +--- the buffer is made empty and autocommands are +--- triggered as usual for `:edit`. +--- *E676* +--- "acwrite" implies that the buffer name is not related to a file, like +--- "nofile", but it will be written. Thus, in contrast to "nofile" and +--- "nowrite", ":w" does work and a modified buffer can't be abandoned +--- without saving. For writing there must be matching `BufWriteCmd|, +--- |FileWriteCmd` or `FileAppendCmd` autocommands. +--- +--- @type string +vim.o.buftype = "" +vim.o.bt = vim.o.buftype +vim.bo.buftype = vim.o.buftype +vim.bo.bt = vim.bo.buftype + +--- Specifies details about changing the case of letters. It may contain +--- these words, separated by a comma: +--- internal Use internal case mapping functions, the current +--- locale does not change the case mapping. When +--- "internal" is omitted, the towupper() and towlower() +--- system library functions are used when available. +--- keepascii For the ASCII characters (0x00 to 0x7f) use the US +--- case mapping, the current locale is not effective. +--- This probably only matters for Turkish. +--- +--- @type string +vim.o.casemap = "internal,keepascii" +vim.o.cmp = vim.o.casemap +vim.go.casemap = vim.o.casemap +vim.go.cmp = vim.go.casemap + +--- When on, `:cd`, `:tcd` and `:lcd` without an argument changes the +--- current working directory to the `$HOME` directory like in Unix. +--- When off, those commands just print the current directory name. +--- On Unix this option has no effect. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type boolean +vim.o.cdhome = false +vim.o.cdh = vim.o.cdhome +vim.go.cdhome = vim.o.cdhome +vim.go.cdh = vim.go.cdhome + +--- This is a list of directories which will be searched when using the +--- `:cd`, `:tcd` and `:lcd` commands, provided that the directory being +--- searched for has a relative path, not an absolute part starting with +--- "/", "./" or "../", the 'cdpath' option is not used then. +--- The 'cdpath' option's value has the same form and semantics as +--- `'path'`. Also see `file-searching`. +--- The default value is taken from $CDPATH, with a "," prepended to look +--- in the current directory first. +--- If the default value taken from $CDPATH is not what you want, include +--- a modified version of the following command in your vimrc file to +--- override it: +--- ``` +--- :let &cdpath = ',' .. substitute(substitute($CDPATH, '[, ]', '\\\0', 'g'), ':', ',', 'g') +--- ``` +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- (parts of 'cdpath' can be passed to the shell to expand file names). +--- +--- @type string +vim.o.cdpath = ",," +vim.o.cd = vim.o.cdpath +vim.go.cdpath = vim.o.cdpath +vim.go.cd = vim.go.cdpath + +--- The key used in Command-line Mode to open the command-line window. +--- Only non-printable keys are allowed. +--- The key can be specified as a single character, but it is difficult to +--- type. The preferred way is to use the <> notation. Examples: +--- ``` +--- :exe "set cedit=\\<C-Y>" +--- :exe "set cedit=\\<Esc>" +--- ``` +--- `Nvi` also has this option, but it only uses the first character. +--- See `cmdwin`. +--- +--- @type string +vim.o.cedit = "\6" +vim.go.cedit = vim.o.cedit + +--- `channel` connected to the buffer, or 0 if no channel is connected. +--- In a `:terminal` buffer this is the terminal channel. +--- Read-only. +--- +--- @type integer +vim.o.channel = 0 +vim.bo.channel = vim.o.channel + +--- An expression that is used for character encoding conversion. It is +--- evaluated when a file that is to be read or has been written has a +--- different encoding from what is desired. +--- 'charconvert' is not used when the internal iconv() function is +--- supported and is able to do the conversion. Using iconv() is +--- preferred, because it is much faster. +--- 'charconvert' is not used when reading stdin `--`, because there is no +--- file to convert from. You will have to save the text in a file first. +--- The expression must return zero, false or an empty string for success, +--- non-zero or true for failure. +--- See `encoding-names` for possible encoding names. +--- Additionally, names given in 'fileencodings' and 'fileencoding' are +--- used. +--- Conversion between "latin1", "unicode", "ucs-2", "ucs-4" and "utf-8" +--- is done internally by Vim, 'charconvert' is not used for this. +--- Also used for Unicode conversion. +--- Example: +--- ``` +--- set charconvert=CharConvert() +--- fun CharConvert() +--- system("recode " +--- \ .. v:charconvert_from .. ".." .. v:charconvert_to +--- \ .. " <" .. v:fname_in .. " >" .. v:fname_out) +--- return v:shell_error +--- endfun +--- ``` +--- The related Vim variables are: +--- v:charconvert_from name of the current encoding +--- v:charconvert_to name of the desired encoding +--- v:fname_in name of the input file +--- v:fname_out name of the output file +--- Note that v:fname_in and v:fname_out will never be the same. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.charconvert = "" +vim.o.ccv = vim.o.charconvert +vim.go.charconvert = vim.o.charconvert +vim.go.ccv = vim.go.charconvert + +--- Enables automatic C program indenting. See 'cinkeys' to set the keys +--- that trigger reindenting in insert mode and 'cinoptions' to set your +--- preferred indent style. +--- If 'indentexpr' is not empty, it overrules 'cindent'. +--- If 'lisp' is not on and both 'indentexpr' and 'equalprg' are empty, +--- the "=" operator indents using this algorithm rather than calling an +--- external program. +--- See `C-indenting`. +--- When you don't like the way 'cindent' works, try the 'smartindent' +--- option or 'indentexpr'. +--- +--- @type boolean +vim.o.cindent = false +vim.o.cin = vim.o.cindent +vim.bo.cindent = vim.o.cindent +vim.bo.cin = vim.bo.cindent + +--- A list of keys that, when typed in Insert mode, cause reindenting of +--- the current line. Only used if 'cindent' is on and 'indentexpr' is +--- empty. +--- For the format of this option see `cinkeys-format`. +--- See `C-indenting`. +--- +--- @type string +vim.o.cinkeys = "0{,0},0),0],:,0#,!^F,o,O,e" +vim.o.cink = vim.o.cinkeys +vim.bo.cinkeys = vim.o.cinkeys +vim.bo.cink = vim.bo.cinkeys + +--- The 'cinoptions' affect the way 'cindent' reindents lines in a C +--- program. See `cinoptions-values` for the values of this option, and +--- `C-indenting` for info on C indenting in general. +--- +--- @type string +vim.o.cinoptions = "" +vim.o.cino = vim.o.cinoptions +vim.bo.cinoptions = vim.o.cinoptions +vim.bo.cino = vim.bo.cinoptions + +--- Keywords that are interpreted as a C++ scope declaration by `cino-g`. +--- Useful e.g. for working with the Qt framework that defines additional +--- scope declarations "signals", "public slots" and "private slots": +--- ``` +--- set cinscopedecls+=signals,public\ slots,private\ slots +--- ``` +--- +--- +--- @type string +vim.o.cinscopedecls = "public,protected,private" +vim.o.cinsd = vim.o.cinscopedecls +vim.bo.cinscopedecls = vim.o.cinscopedecls +vim.bo.cinsd = vim.bo.cinscopedecls + +--- These keywords start an extra indent in the next line when +--- 'smartindent' or 'cindent' is set. For 'cindent' this is only done at +--- an appropriate place (inside {}). +--- Note that 'ignorecase' isn't used for 'cinwords'. If case doesn't +--- matter, include the keyword both the uppercase and lowercase: +--- "if,If,IF". +--- +--- @type string +vim.o.cinwords = "if,else,while,do,for,switch" +vim.o.cinw = vim.o.cinwords +vim.bo.cinwords = vim.o.cinwords +vim.bo.cinw = vim.bo.cinwords + +--- This option is a list of comma-separated names. +--- These names are recognized: +--- +--- *clipboard-unnamed* +--- unnamed When included, Vim will use the clipboard register "*" +--- for all yank, delete, change and put operations which +--- would normally go to the unnamed register. When a +--- register is explicitly specified, it will always be +--- used regardless of whether "unnamed" is in 'clipboard' +--- or not. The clipboard register can always be +--- explicitly accessed using the "* notation. Also see +--- `clipboard`. +--- +--- *clipboard-unnamedplus* +--- unnamedplus A variant of the "unnamed" flag which uses the +--- clipboard register "+" (`quoteplus`) instead of +--- register "*" for all yank, delete, change and put +--- operations which would normally go to the unnamed +--- register. When "unnamed" is also included to the +--- option, yank and delete operations (but not put) +--- will additionally copy the text into register +--- "*". See `clipboard`. +--- +--- @type string +vim.o.clipboard = "" +vim.o.cb = vim.o.clipboard +vim.go.clipboard = vim.o.clipboard +vim.go.cb = vim.go.clipboard + +--- Number of screen lines to use for the command-line. Helps avoiding +--- `hit-enter` prompts. +--- The value of this option is stored with the tab page, so that each tab +--- page can have a different value. +--- +--- When 'cmdheight' is zero, there is no command-line unless it is being +--- used. The command-line will cover the last line of the screen when +--- shown. +--- +--- WARNING: `cmdheight=0` is considered experimental. Expect some +--- unwanted behaviour. Some 'shortmess' flags and similar +--- mechanism might fail to take effect, causing unwanted hit-enter +--- prompts. Some informative messages, both from Nvim itself and +--- plugins, will not be displayed. +--- +--- @type integer +vim.o.cmdheight = 1 +vim.o.ch = vim.o.cmdheight +vim.go.cmdheight = vim.o.cmdheight +vim.go.ch = vim.go.cmdheight + +--- Number of screen lines to use for the command-line window. `cmdwin` +--- +--- @type integer +vim.o.cmdwinheight = 7 +vim.o.cwh = vim.o.cmdwinheight +vim.go.cmdwinheight = vim.o.cmdwinheight +vim.go.cwh = vim.go.cmdwinheight + +--- 'colorcolumn' is a comma-separated list of screen columns that are +--- highlighted with ColorColumn `hl-ColorColumn`. Useful to align +--- text. Will make screen redrawing slower. +--- The screen column can be an absolute number, or a number preceded with +--- '+' or '-', which is added to or subtracted from 'textwidth'. +--- ``` +--- :set cc=+1 " highlight column after 'textwidth' +--- :set cc=+1,+2,+3 " highlight three columns after 'textwidth' +--- :hi ColorColumn ctermbg=lightgrey guibg=lightgrey +--- ``` +--- +--- When 'textwidth' is zero then the items with '-' and '+' are not used. +--- A maximum of 256 columns are highlighted. +--- +--- @type string +vim.o.colorcolumn = "" +vim.o.cc = vim.o.colorcolumn +vim.wo.colorcolumn = vim.o.colorcolumn +vim.wo.cc = vim.wo.colorcolumn + +--- Number of columns of the screen. Normally this is set by the terminal +--- initialization and does not have to be set by hand. +--- When Vim is running in the GUI or in a resizable window, setting this +--- option will cause the window size to be changed. When you only want +--- to use the size for the GUI, put the command in your `ginit.vim` file. +--- When you set this option and Vim is unable to change the physical +--- number of columns of the display, the display may be messed up. For +--- the GUI it is always possible and Vim limits the number of columns to +--- what fits on the screen. You can use this command to get the widest +--- window possible: +--- ``` +--- :set columns=9999 +--- ``` +--- Minimum value is 12, maximum value is 10000. +--- +--- @type integer +vim.o.columns = 80 +vim.o.co = vim.o.columns +vim.go.columns = vim.o.columns +vim.go.co = vim.go.columns + +--- A comma-separated list of strings that can start a comment line. See +--- `format-comments`. See `option-backslash` about using backslashes to +--- insert a space. +--- +--- @type string +vim.o.comments = "s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-,fb:•" +vim.o.com = vim.o.comments +vim.bo.comments = vim.o.comments +vim.bo.com = vim.bo.comments + +--- A template for a comment. The "%s" in the value is replaced with the +--- comment text. For example, C uses "/*%s*/". Currently only used to +--- add markers for folding, see `fold-marker`. +--- +--- @type string +vim.o.commentstring = "" +vim.o.cms = vim.o.commentstring +vim.bo.commentstring = vim.o.commentstring +vim.bo.cms = vim.bo.commentstring + +--- This option specifies how keyword completion `ins-completion` works +--- when CTRL-P or CTRL-N are used. It is also used for whole-line +--- completion `i_CTRL-X_CTRL-L`. It indicates the type of completion +--- and the places to scan. It is a comma-separated list of flags: +--- . scan the current buffer ('wrapscan' is ignored) +--- w scan buffers from other windows +--- b scan other loaded buffers that are in the buffer list +--- u scan the unloaded buffers that are in the buffer list +--- U scan the buffers that are not in the buffer list +--- k scan the files given with the 'dictionary' option +--- kspell use the currently active spell checking `spell` +--- k{dict} scan the file {dict}. Several "k" flags can be given, +--- patterns are valid too. For example: +--- ``` +--- :set cpt=k/usr/dict/*,k~/spanish +--- ``` +--- s scan the files given with the 'thesaurus' option +--- s{tsr} scan the file {tsr}. Several "s" flags can be given, patterns +--- are valid too. +--- i scan current and included files +--- d scan current and included files for defined name or macro +--- `i_CTRL-X_CTRL-D` +--- ] tag completion +--- t same as "]" +--- f scan the buffer names (as opposed to buffer contents) +--- +--- Unloaded buffers are not loaded, thus their autocmds `:autocmd` are +--- not executed, this may lead to unexpected completions from some files +--- (gzipped files for example). Unloaded buffers are not scanned for +--- whole-line completion. +--- +--- As you can see, CTRL-N and CTRL-P can be used to do any 'iskeyword'- +--- based expansion (e.g., dictionary `i_CTRL-X_CTRL-K`, included patterns +--- `i_CTRL-X_CTRL-I`, tags `i_CTRL-X_CTRL-]` and normal expansions). +--- +--- @type string +vim.o.complete = ".,w,b,u,t" +vim.o.cpt = vim.o.complete +vim.bo.complete = vim.o.complete +vim.bo.cpt = vim.bo.complete + +--- This option specifies a function to be used for Insert mode completion +--- with CTRL-X CTRL-U. `i_CTRL-X_CTRL-U` +--- See `complete-functions` for an explanation of how the function is +--- invoked and what it should return. The value can be the name of a +--- function, a `lambda` or a `Funcref`. See `option-value-function` for +--- more information. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.completefunc = "" +vim.o.cfu = vim.o.completefunc +vim.bo.completefunc = vim.o.completefunc +vim.bo.cfu = vim.bo.completefunc + +--- A comma-separated list of options for Insert mode completion +--- `ins-completion`. The supported values are: +--- +--- menu Use a popup menu to show the possible completions. The +--- menu is only shown when there is more than one match and +--- sufficient colors are available. `ins-completion-menu` +--- +--- menuone Use the popup menu also when there is only one match. +--- Useful when there is additional information about the +--- match, e.g., what file it comes from. +--- +--- longest Only insert the longest common text of the matches. If +--- the menu is displayed you can use CTRL-L to add more +--- characters. Whether case is ignored depends on the kind +--- of completion. For buffer text the 'ignorecase' option is +--- used. +--- +--- preview Show extra information about the currently selected +--- completion in the preview window. Only works in +--- combination with "menu" or "menuone". +--- +--- noinsert Do not insert any text for a match until the user selects +--- a match from the menu. Only works in combination with +--- "menu" or "menuone". No effect if "longest" is present. +--- +--- noselect Do not select a match in the menu, force the user to +--- select one from the menu. Only works in combination with +--- "menu" or "menuone". +--- +--- @type string +vim.o.completeopt = "menu,preview" +vim.o.cot = vim.o.completeopt +vim.go.completeopt = vim.o.completeopt +vim.go.cot = vim.go.completeopt + +--- only for MS-Windows +--- When this option is set it overrules 'shellslash' for completion: +--- - When this option is set to "slash", a forward slash is used for path +--- completion in insert mode. This is useful when editing HTML tag, or +--- Makefile with 'noshellslash' on MS-Windows. +--- - When this option is set to "backslash", backslash is used. This is +--- useful when editing a batch file with 'shellslash' set on MS-Windows. +--- - When this option is empty, same character is used as for +--- 'shellslash'. +--- For Insert mode completion the buffer-local value is used. For +--- command line completion the global value is used. +--- +--- @type string +vim.o.completeslash = "" +vim.o.csl = vim.o.completeslash +vim.bo.completeslash = vim.o.completeslash +vim.bo.csl = vim.bo.completeslash + +--- Sets the modes in which text in the cursor line can also be concealed. +--- When the current mode is listed then concealing happens just like in +--- other lines. +--- n Normal mode +--- v Visual mode +--- i Insert mode +--- c Command line editing, for 'incsearch' +--- +--- 'v' applies to all lines in the Visual area, not only the cursor. +--- A useful value is "nc". This is used in help files. So long as you +--- are moving around text is concealed, but when starting to insert text +--- or selecting a Visual area the concealed text is displayed, so that +--- you can see what you are doing. +--- Keep in mind that the cursor position is not always where it's +--- displayed. E.g., when moving vertically it may change column. +--- +--- @type string +vim.o.concealcursor = "" +vim.o.cocu = vim.o.concealcursor +vim.wo.concealcursor = vim.o.concealcursor +vim.wo.cocu = vim.wo.concealcursor + +--- Determine how text with the "conceal" syntax attribute `:syn-conceal` +--- is shown: +--- +--- Value Effect ~ +--- 0 Text is shown normally +--- 1 Each block of concealed text is replaced with one +--- character. If the syntax item does not have a custom +--- replacement character defined (see `:syn-cchar`) the +--- character defined in 'listchars' is used. +--- It is highlighted with the "Conceal" highlight group. +--- 2 Concealed text is completely hidden unless it has a +--- custom replacement character defined (see +--- `:syn-cchar`). +--- 3 Concealed text is completely hidden. +--- +--- Note: in the cursor line concealed text is not hidden, so that you can +--- edit and copy the text. This can be changed with the 'concealcursor' +--- option. +--- +--- @type integer +vim.o.conceallevel = 0 +vim.o.cole = vim.o.conceallevel +vim.wo.conceallevel = vim.o.conceallevel +vim.wo.cole = vim.wo.conceallevel + +--- When 'confirm' is on, certain operations that would normally +--- fail because of unsaved changes to a buffer, e.g. ":q" and ":e", +--- instead raise a dialog asking if you wish to save the current +--- file(s). You can still use a ! to unconditionally `abandon` a buffer. +--- If 'confirm' is off you can still activate confirmation for one +--- command only (this is most useful in mappings) with the `:confirm` +--- command. +--- Also see the `confirm()` function and the 'v' flag in 'guioptions'. +--- +--- @type boolean +vim.o.confirm = false +vim.o.cf = vim.o.confirm +vim.go.confirm = vim.o.confirm +vim.go.cf = vim.go.confirm + +--- Copy the structure of the existing lines indent when autoindenting a +--- new line. Normally the new indent is reconstructed by a series of +--- tabs followed by spaces as required (unless `'expandtab'` is enabled, +--- in which case only spaces are used). Enabling this option makes the +--- new line copy whatever characters were used for indenting on the +--- existing line. 'expandtab' has no effect on these characters, a Tab +--- remains a Tab. If the new indent is greater than on the existing +--- line, the remaining space is filled in the normal manner. +--- See 'preserveindent'. +--- +--- @type boolean +vim.o.copyindent = false +vim.o.ci = vim.o.copyindent +vim.bo.copyindent = vim.o.copyindent +vim.bo.ci = vim.bo.copyindent + +--- A sequence of single character flags. When a character is present +--- this indicates Vi-compatible behavior. This is used for things where +--- not being Vi-compatible is mostly or sometimes preferred. +--- 'cpoptions' stands for "compatible-options". +--- Commas can be added for readability. +--- To avoid problems with flags that are added in the future, use the +--- "+=" and "-=" feature of ":set" `add-option-flags`. +--- +--- contains behavior ~ +--- *cpo-a* +--- a When included, a ":read" command with a file name +--- argument will set the alternate file name for the +--- current window. +--- *cpo-A* +--- A When included, a ":write" command with a file name +--- argument will set the alternate file name for the +--- current window. +--- *cpo-b* +--- b "\|" in a ":map" command is recognized as the end of +--- the map command. The '\' is included in the mapping, +--- the text after the '|' is interpreted as the next +--- command. Use a CTRL-V instead of a backslash to +--- include the '|' in the mapping. Applies to all +--- mapping, abbreviation, menu and autocmd commands. +--- See also `map_bar`. +--- *cpo-B* +--- B A backslash has no special meaning in mappings, +--- abbreviations, user commands and the "to" part of the +--- menu commands. Remove this flag to be able to use a +--- backslash like a CTRL-V. For example, the command +--- ":map X \\<Esc>" results in X being mapped to: +--- 'B' included: "\^[" (^[ is a real <Esc>) +--- 'B' excluded: "<Esc>" (5 characters) +--- *cpo-c* +--- c Searching continues at the end of any match at the +--- cursor position, but not further than the start of the +--- next line. When not present searching continues +--- one character from the cursor position. With 'c' +--- "abababababab" only gets three matches when repeating +--- "/abab", without 'c' there are five matches. +--- *cpo-C* +--- C Do not concatenate sourced lines that start with a +--- backslash. See `line-continuation`. +--- *cpo-d* +--- d Using "./" in the 'tags' option doesn't mean to use +--- the tags file relative to the current file, but the +--- tags file in the current directory. +--- *cpo-D* +--- D Can't use CTRL-K to enter a digraph after Normal mode +--- commands with a character argument, like `r`, `f` and +--- `t`. +--- *cpo-e* +--- e When executing a register with ":@r", always add a +--- <CR> to the last line, also when the register is not +--- linewise. If this flag is not present, the register +--- is not linewise and the last line does not end in a +--- <CR>, then the last line is put on the command-line +--- and can be edited before hitting <CR>. +--- *cpo-E* +--- E It is an error when using "y", "d", "c", "g~", "gu" or +--- "gU" on an Empty region. The operators only work when +--- at least one character is to be operated on. Example: +--- This makes "y0" fail in the first column. +--- *cpo-f* +--- f When included, a ":read" command with a file name +--- argument will set the file name for the current buffer, +--- if the current buffer doesn't have a file name yet. +--- *cpo-F* +--- F When included, a ":write" command with a file name +--- argument will set the file name for the current +--- buffer, if the current buffer doesn't have a file name +--- yet. Also see `cpo-P`. +--- *cpo-i* +--- i When included, interrupting the reading of a file will +--- leave it modified. +--- *cpo-I* +--- I When moving the cursor up or down just after inserting +--- indent for 'autoindent', do not delete the indent. +--- *cpo-J* +--- J A `sentence` has to be followed by two spaces after +--- the '.', '!' or '?'. A <Tab> is not recognized as +--- white space. +--- *cpo-K* +--- K Don't wait for a key code to complete when it is +--- halfway through a mapping. This breaks mapping +--- <F1><F1> when only part of the second <F1> has been +--- read. It enables cancelling the mapping by typing +--- <F1><Esc>. +--- *cpo-l* +--- l Backslash in a [] range in a search pattern is taken +--- literally, only "\]", "\^", "\-" and "\\" are special. +--- See `/[]` +--- 'l' included: "/[ \t]" finds <Space>, '\' and 't' +--- 'l' excluded: "/[ \t]" finds <Space> and <Tab> +--- *cpo-L* +--- L When the 'list' option is set, 'wrapmargin', +--- 'textwidth', 'softtabstop' and Virtual Replace mode +--- (see `gR`) count a <Tab> as two characters, instead of +--- the normal behavior of a <Tab>. +--- *cpo-m* +--- m When included, a showmatch will always wait half a +--- second. When not included, a showmatch will wait half +--- a second or until a character is typed. `'showmatch'` +--- *cpo-M* +--- M When excluded, "%" matching will take backslashes into +--- account. Thus in "( \( )" and "\( ( \)" the outer +--- parenthesis match. When included "%" ignores +--- backslashes, which is Vi compatible. +--- *cpo-n* +--- n When included, the column used for 'number' and +--- 'relativenumber' will also be used for text of wrapped +--- lines. +--- *cpo-o* +--- o Line offset to search command is not remembered for +--- next search. +--- *cpo-O* +--- O Don't complain if a file is being overwritten, even +--- when it didn't exist when editing it. This is a +--- protection against a file unexpectedly created by +--- someone else. Vi didn't complain about this. +--- *cpo-p* +--- p Vi compatible Lisp indenting. When not present, a +--- slightly better algorithm is used. +--- *cpo-P* +--- P When included, a ":write" command that appends to a +--- file will set the file name for the current buffer, if +--- the current buffer doesn't have a file name yet and +--- the 'F' flag is also included `cpo-F`. +--- *cpo-q* +--- q When joining multiple lines leave the cursor at the +--- position where it would be when joining two lines. +--- *cpo-r* +--- r Redo ("." command) uses "/" to repeat a search +--- command, instead of the actually used search string. +--- *cpo-R* +--- R Remove marks from filtered lines. Without this flag +--- marks are kept like `:keepmarks` was used. +--- *cpo-s* +--- s Set buffer options when entering the buffer for the +--- first time. This is like it is in Vim version 3.0. +--- And it is the default. If not present the options are +--- set when the buffer is created. +--- *cpo-S* +--- S Set buffer options always when entering a buffer +--- (except 'readonly', 'fileformat', 'filetype' and +--- 'syntax'). This is the (most) Vi compatible setting. +--- The options are set to the values in the current +--- buffer. When you change an option and go to another +--- buffer, the value is copied. Effectively makes the +--- buffer options global to all buffers. +--- +--- 's' 'S' copy buffer options +--- no no when buffer created +--- yes no when buffer first entered (default) +--- X yes each time when buffer entered (vi comp.) +--- *cpo-t* +--- t Search pattern for the tag command is remembered for +--- "n" command. Otherwise Vim only puts the pattern in +--- the history for search pattern, but doesn't change the +--- last used search pattern. +--- *cpo-u* +--- u Undo is Vi compatible. See `undo-two-ways`. +--- *cpo-v* +--- v Backspaced characters remain visible on the screen in +--- Insert mode. Without this flag the characters are +--- erased from the screen right away. With this flag the +--- screen newly typed text overwrites backspaced +--- characters. +--- *cpo-W* +--- W Don't overwrite a readonly file. When omitted, ":w!" +--- overwrites a readonly file, if possible. +--- *cpo-x* +--- x <Esc> on the command-line executes the command-line. +--- The default in Vim is to abandon the command-line, +--- because <Esc> normally aborts a command. `c_<Esc>` +--- *cpo-X* +--- X When using a count with "R" the replaced text is +--- deleted only once. Also when repeating "R" with "." +--- and a count. +--- *cpo-y* +--- y A yank command can be redone with ".". Think twice if +--- you really want to use this, it may break some +--- plugins, since most people expect "." to only repeat a +--- change. +--- *cpo-Z* +--- Z When using "w!" while the 'readonly' option is set, +--- don't reset 'readonly'. +--- *cpo-!* +--- ! When redoing a filter command, use the last used +--- external command, whatever it was. Otherwise the last +--- used -filter- command is used. +--- *cpo-$* +--- $ When making a change to one line, don't redisplay the +--- line, but put a '$' at the end of the changed text. +--- The changed text will be overwritten when you type the +--- new text. The line is redisplayed if you type any +--- command that moves the cursor from the insertion +--- point. +--- *cpo-%* +--- % Vi-compatible matching is done for the "%" command. +--- Does not recognize "#if", "#endif", etc. +--- Does not recognize "/*" and "*/". +--- Parens inside single and double quotes are also +--- counted, causing a string that contains a paren to +--- disturb the matching. For example, in a line like +--- "if (strcmp("foo(", s))" the first paren does not +--- match the last one. When this flag is not included, +--- parens inside single and double quotes are treated +--- specially. When matching a paren outside of quotes, +--- everything inside quotes is ignored. When matching a +--- paren inside quotes, it will find the matching one (if +--- there is one). This works very well for C programs. +--- This flag is also used for other features, such as +--- C-indenting. +--- *cpo-+* +--- + When included, a ":write file" command will reset the +--- 'modified' flag of the buffer, even though the buffer +--- itself may still be different from its file. +--- *cpo->* +--- > When appending to a register, put a line break before +--- the appended text. +--- *cpo-;* +--- ; When using `,` or `;` to repeat the last `t` search +--- and the cursor is right in front of the searched +--- character, the cursor won't move. When not included, +--- the cursor would skip over it and jump to the +--- following occurrence. +--- *cpo-_* +--- _ When using `cw` on a word, do not include the +--- whitespace following the word in the motion. +--- +--- @type string +vim.o.cpoptions = "aABceFs_" +vim.o.cpo = vim.o.cpoptions +vim.go.cpoptions = vim.o.cpoptions +vim.go.cpo = vim.go.cpoptions + +--- When this option is set, as the cursor in the current +--- window moves other cursorbound windows (windows that also have +--- this option set) move their cursors to the corresponding line and +--- column. This option is useful for viewing the +--- differences between two versions of a file (see 'diff'); in diff mode, +--- inserted and deleted lines (though not characters within a line) are +--- taken into account. +--- +--- @type boolean +vim.o.cursorbind = false +vim.o.crb = vim.o.cursorbind +vim.wo.cursorbind = vim.o.cursorbind +vim.wo.crb = vim.wo.cursorbind + +--- Highlight the screen column of the cursor with CursorColumn +--- `hl-CursorColumn`. Useful to align text. Will make screen redrawing +--- slower. +--- If you only want the highlighting in the current window you can use +--- these autocommands: +--- ``` +--- au WinLeave * set nocursorline nocursorcolumn +--- au WinEnter * set cursorline cursorcolumn +--- ``` +--- +--- +--- @type boolean +vim.o.cursorcolumn = false +vim.o.cuc = vim.o.cursorcolumn +vim.wo.cursorcolumn = vim.o.cursorcolumn +vim.wo.cuc = vim.wo.cursorcolumn + +--- Highlight the text line of the cursor with CursorLine `hl-CursorLine`. +--- Useful to easily spot the cursor. Will make screen redrawing slower. +--- When Visual mode is active the highlighting isn't used to make it +--- easier to see the selected text. +--- +--- @type boolean +vim.o.cursorline = false +vim.o.cul = vim.o.cursorline +vim.wo.cursorline = vim.o.cursorline +vim.wo.cul = vim.wo.cursorline + +--- Comma-separated list of settings for how 'cursorline' is displayed. +--- Valid values: +--- "line" Highlight the text line of the cursor with +--- CursorLine `hl-CursorLine`. +--- "screenline" Highlight only the screen line of the cursor with +--- CursorLine `hl-CursorLine`. +--- "number" Highlight the line number of the cursor with +--- CursorLineNr `hl-CursorLineNr`. +--- +--- Special value: +--- "both" Alias for the values "line,number". +--- +--- "line" and "screenline" cannot be used together. +--- +--- @type string +vim.o.cursorlineopt = "both" +vim.o.culopt = vim.o.cursorlineopt +vim.wo.cursorlineopt = vim.o.cursorlineopt +vim.wo.culopt = vim.wo.cursorlineopt + +--- These values can be used: +--- msg Error messages that would otherwise be omitted will be given +--- anyway. +--- throw Error messages that would otherwise be omitted will be given +--- anyway and also throw an exception and set `v:errmsg`. +--- beep A message will be given when otherwise only a beep would be +--- produced. +--- The values can be combined, separated by a comma. +--- "msg" and "throw" are useful for debugging 'foldexpr', 'formatexpr' or +--- 'indentexpr'. +--- +--- @type string +vim.o.debug = "" +vim.go.debug = vim.o.debug + +--- Pattern to be used to find a macro definition. It is a search +--- pattern, just like for the "/" command. This option is used for the +--- commands like "[i" and "[d" `include-search`. The 'isident' option is +--- used to recognize the defined name after the match: +--- ``` +--- {match with 'define'}{non-ID chars}{defined name}{non-ID char} +--- ``` +--- See `option-backslash` about inserting backslashes to include a space +--- or backslash. +--- For C++ this value would be useful, to include const type declarations: +--- ``` +--- ^\(#\s*define\|[a-z]*\s*const\s*[a-z]*\) +--- ``` +--- You can also use "\ze" just before the name and continue the pattern +--- to check what is following. E.g. for Javascript, if a function is +--- defined with `func_name = function(args)`: +--- ``` +--- ^\s*\ze\i\+\s*=\s*function( +--- ``` +--- If the function is defined with `func_name : function() {...`: +--- ``` +--- ^\s*\ze\i\+\s*[:]\s*(*function\s*( +--- ``` +--- When using the ":set" command, you need to double the backslashes! +--- To avoid that use `:let` with a single quote string: +--- ``` +--- let &l:define = '^\s*\ze\k\+\s*=\s*function(' +--- ``` +--- +--- +--- @type string +vim.o.define = "" +vim.o.def = vim.o.define +vim.bo.define = vim.o.define +vim.bo.def = vim.bo.define +vim.go.define = vim.o.define +vim.go.def = vim.go.define + +--- If editing Unicode and this option is set, backspace and Normal mode +--- "x" delete each combining character on its own. When it is off (the +--- default) the character along with its combining characters are +--- deleted. +--- Note: When 'delcombine' is set "xx" may work differently from "2x"! +--- +--- This is useful for Arabic, Hebrew and many other languages where one +--- may have combining characters overtop of base characters, and want +--- to remove only the combining ones. +--- +--- @type boolean +vim.o.delcombine = false +vim.o.deco = vim.o.delcombine +vim.go.delcombine = vim.o.delcombine +vim.go.deco = vim.go.delcombine + +--- List of file names, separated by commas, that are used to lookup words +--- for keyword completion commands `i_CTRL-X_CTRL-K`. Each file should +--- contain a list of words. This can be one word per line, or several +--- words per line, separated by non-keyword characters (white space is +--- preferred). Maximum line length is 510 bytes. +--- +--- When this option is empty or an entry "spell" is present, and spell +--- checking is enabled, words in the word lists for the currently active +--- 'spelllang' are used. See `spell`. +--- +--- To include a comma in a file name precede it with a backslash. Spaces +--- after a comma are ignored, otherwise spaces are included in the file +--- name. See `option-backslash` about using backslashes. +--- This has nothing to do with the `Dictionary` variable type. +--- Where to find a list of words? +--- - BSD/macOS include the "/usr/share/dict/words" file. +--- - Try "apt install spell" to get the "/usr/share/dict/words" file on +--- apt-managed systems (Debian/Ubuntu). +--- The use of `:set+=` and `:set-=` is preferred when adding or removing +--- directories from the list. This avoids problems when a future version +--- uses another default. +--- Backticks cannot be used in this option for security reasons. +--- +--- @type string +vim.o.dictionary = "" +vim.o.dict = vim.o.dictionary +vim.bo.dictionary = vim.o.dictionary +vim.bo.dict = vim.bo.dictionary +vim.go.dictionary = vim.o.dictionary +vim.go.dict = vim.go.dictionary + +--- Join the current window in the group of windows that shows differences +--- between files. See `diff-mode`. +--- +--- @type boolean +vim.o.diff = false +vim.wo.diff = vim.o.diff + +--- Expression which is evaluated to obtain a diff file (either ed-style +--- or unified-style) from two versions of a file. See `diff-diffexpr`. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.diffexpr = "" +vim.o.dex = vim.o.diffexpr +vim.go.diffexpr = vim.o.diffexpr +vim.go.dex = vim.go.diffexpr + +--- Option settings for diff mode. It can consist of the following items. +--- All are optional. Items must be separated by a comma. +--- +--- filler Show filler lines, to keep the text +--- synchronized with a window that has inserted +--- lines at the same position. Mostly useful +--- when windows are side-by-side and 'scrollbind' +--- is set. +--- +--- context:{n} Use a context of {n} lines between a change +--- and a fold that contains unchanged lines. +--- When omitted a context of six lines is used. +--- When using zero the context is actually one, +--- since folds require a line in between, also +--- for a deleted line. Set it to a very large +--- value (999999) to disable folding completely. +--- See `fold-diff`. +--- +--- iblank Ignore changes where lines are all blank. Adds +--- the "-B" flag to the "diff" command if +--- 'diffexpr' is empty. Check the documentation +--- of the "diff" command for what this does +--- exactly. +--- NOTE: the diff windows will get out of sync, +--- because no differences between blank lines are +--- taken into account. +--- +--- icase Ignore changes in case of text. "a" and "A" +--- are considered the same. Adds the "-i" flag +--- to the "diff" command if 'diffexpr' is empty. +--- +--- iwhite Ignore changes in amount of white space. Adds +--- the "-b" flag to the "diff" command if +--- 'diffexpr' is empty. Check the documentation +--- of the "diff" command for what this does +--- exactly. It should ignore adding trailing +--- white space, but not leading white space. +--- +--- iwhiteall Ignore all white space changes. Adds +--- the "-w" flag to the "diff" command if +--- 'diffexpr' is empty. Check the documentation +--- of the "diff" command for what this does +--- exactly. +--- +--- iwhiteeol Ignore white space changes at end of line. +--- Adds the "-Z" flag to the "diff" command if +--- 'diffexpr' is empty. Check the documentation +--- of the "diff" command for what this does +--- exactly. +--- +--- horizontal Start diff mode with horizontal splits (unless +--- explicitly specified otherwise). +--- +--- vertical Start diff mode with vertical splits (unless +--- explicitly specified otherwise). +--- +--- closeoff When a window is closed where 'diff' is set +--- and there is only one window remaining in the +--- same tab page with 'diff' set, execute +--- `:diffoff` in that window. This undoes a +--- `:diffsplit` command. +--- +--- hiddenoff Do not use diff mode for a buffer when it +--- becomes hidden. +--- +--- foldcolumn:{n} Set the 'foldcolumn' option to {n} when +--- starting diff mode. Without this 2 is used. +--- +--- followwrap Follow the 'wrap' option and leave as it is. +--- +--- internal Use the internal diff library. This is +--- ignored when 'diffexpr' is set. *E960* +--- When running out of memory when writing a +--- buffer this item will be ignored for diffs +--- involving that buffer. Set the 'verbose' +--- option to see when this happens. +--- +--- indent-heuristic +--- Use the indent heuristic for the internal +--- diff library. +--- +--- linematch:{n} Enable a second stage diff on each generated +--- hunk in order to align lines. When the total +--- number of lines in a hunk exceeds {n}, the +--- second stage diff will not be performed as +--- very large hunks can cause noticeable lag. A +--- recommended setting is "linematch:60", as this +--- will enable alignment for a 2 buffer diff with +--- hunks of up to 30 lines each, or a 3 buffer +--- diff with hunks of up to 20 lines each. +--- +--- algorithm:{text} Use the specified diff algorithm with the +--- internal diff engine. Currently supported +--- algorithms are: +--- myers the default algorithm +--- minimal spend extra time to generate the +--- smallest possible diff +--- patience patience diff algorithm +--- histogram histogram diff algorithm +--- +--- Examples: +--- ``` +--- :set diffopt=internal,filler,context:4 +--- :set diffopt= +--- :set diffopt=internal,filler,foldcolumn:3 +--- :set diffopt-=internal " do NOT use the internal diff parser +--- ``` +--- +--- +--- @type string +vim.o.diffopt = "internal,filler,closeoff" +vim.o.dip = vim.o.diffopt +vim.go.diffopt = vim.o.diffopt +vim.go.dip = vim.go.diffopt + +--- Enable the entering of digraphs in Insert mode with {char1} <BS> +--- {char2}. See `digraphs`. +--- +--- @type boolean +vim.o.digraph = false +vim.o.dg = vim.o.digraph +vim.go.digraph = vim.o.digraph +vim.go.dg = vim.go.digraph + +--- List of directory names for the swap file, separated with commas. +--- +--- Possible items: +--- - The swap file will be created in the first directory where this is +--- possible. If it is not possible in any directory, but last +--- directory listed in the option does not exist, it is created. +--- - Empty means that no swap file will be used (recovery is +--- impossible!) and no `E303` error will be given. +--- - A directory "." means to put the swap file in the same directory as +--- the edited file. On Unix, a dot is prepended to the file name, so +--- it doesn't show in a directory listing. On MS-Windows the "hidden" +--- attribute is set and a dot prepended if possible. +--- - A directory starting with "./" (or ".\" for MS-Windows) means to put +--- the swap file relative to where the edited file is. The leading "." +--- is replaced with the path name of the edited file. +--- - For Unix and Win32, if a directory ends in two path separators "//", +--- the swap file name will be built from the complete path to the file +--- with all path separators replaced by percent '%' signs (including +--- the colon following the drive letter on Win32). This will ensure +--- file name uniqueness in the preserve directory. +--- On Win32, it is also possible to end with "\\". However, When a +--- separating comma is following, you must use "//", since "\\" will +--- include the comma in the file name. Therefore it is recommended to +--- use '//', instead of '\\'. +--- - Spaces after the comma are ignored, other spaces are considered part +--- of the directory name. To have a space at the start of a directory +--- name, precede it with a backslash. +--- - To include a comma in a directory name precede it with a backslash. +--- - A directory name may end in an ':' or '/'. +--- - Environment variables are expanded `:set_env`. +--- - Careful with '\' characters, type one before a space, type two to +--- get one in the option (see `option-backslash`), for example: +--- ``` +--- :set dir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces +--- ``` +--- +--- Editing the same file twice will result in a warning. Using "/tmp" on +--- is discouraged: if the system crashes you lose the swap file. And +--- others on the computer may be able to see the files. +--- Use `:set+=` and `:set-=` when adding or removing directories from the +--- list, this avoids problems if the Nvim default is changed. +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.directory = "$XDG_STATE_HOME/nvim/swap//" +vim.o.dir = vim.o.directory +vim.go.directory = vim.o.directory +vim.go.dir = vim.go.directory + +--- Change the way text is displayed. This is a comma-separated list of +--- flags: +--- lastline When included, as much as possible of the last line +--- in a window will be displayed. "@@@" is put in the +--- last columns of the last screen line to indicate the +--- rest of the line is not displayed. +--- truncate Like "lastline", but "@@@" is displayed in the first +--- column of the last screen line. Overrules "lastline". +--- uhex Show unprintable characters hexadecimal as <xx> +--- instead of using ^C and ~C. +--- msgsep Obsolete flag. Allowed but takes no effect. `msgsep` +--- +--- When neither "lastline" nor "truncate" is included, a last line that +--- doesn't fit is replaced with "@" lines. +--- +--- The "@" character can be changed by setting the "lastline" item in +--- 'fillchars'. The character is highlighted with `hl-NonText`. +--- +--- @type string +vim.o.display = "lastline" +vim.o.dy = vim.o.display +vim.go.display = vim.o.display +vim.go.dy = vim.go.display + +--- Tells when the 'equalalways' option applies: +--- ver vertically, width of windows is not affected +--- hor horizontally, height of windows is not affected +--- both width and height of windows is affected +--- +--- @type string +vim.o.eadirection = "both" +vim.o.ead = vim.o.eadirection +vim.go.eadirection = vim.o.eadirection +vim.go.ead = vim.go.eadirection + +--- When on all Unicode emoji characters are considered to be full width. +--- This excludes "text emoji" characters, which are normally displayed as +--- single width. Unfortunately there is no good specification for this +--- and it has been determined on trial-and-error basis. Use the +--- `setcellwidths()` function to change the behavior. +--- +--- @type boolean +vim.o.emoji = true +vim.o.emo = vim.o.emoji +vim.go.emoji = vim.o.emoji +vim.go.emo = vim.go.emoji + +--- String-encoding used internally and for `RPC` communication. +--- Always UTF-8. +--- +--- See 'fileencoding' to control file-content encoding. +--- +--- @type string +vim.o.encoding = "utf-8" +vim.o.enc = vim.o.encoding +vim.go.encoding = vim.o.encoding +vim.go.enc = vim.go.encoding + +--- Indicates that a CTRL-Z character was found at the end of the file +--- when reading it. Normally only happens when 'fileformat' is "dos". +--- When writing a file and this option is off and the 'binary' option +--- is on, or 'fixeol' option is off, no CTRL-Z will be written at the +--- end of the file. +--- See `eol-and-eof` for example settings. +--- +--- @type boolean +vim.o.endoffile = false +vim.o.eof = vim.o.endoffile +vim.bo.endoffile = vim.o.endoffile +vim.bo.eof = vim.bo.endoffile + +--- When writing a file and this option is off and the 'binary' option +--- is on, or 'fixeol' option is off, no <EOL> will be written for the +--- last line in the file. This option is automatically set or reset when +--- starting to edit a new file, depending on whether file has an <EOL> +--- for the last line in the file. Normally you don't have to set or +--- reset this option. +--- When 'binary' is off and 'fixeol' is on the value is not used when +--- writing the file. When 'binary' is on or 'fixeol' is off it is used +--- to remember the presence of a <EOL> for the last line in the file, so +--- that when you write the file the situation from the original file can +--- be kept. But you can change it if you want to. +--- See `eol-and-eof` for example settings. +--- +--- @type boolean +vim.o.endofline = true +vim.o.eol = vim.o.endofline +vim.bo.endofline = vim.o.endofline +vim.bo.eol = vim.bo.endofline + +--- When on, all the windows are automatically made the same size after +--- splitting or closing a window. This also happens the moment the +--- option is switched on. When off, splitting a window will reduce the +--- size of the current window and leave the other windows the same. When +--- closing a window the extra lines are given to the window next to it +--- (depending on 'splitbelow' and 'splitright'). +--- When mixing vertically and horizontally split windows, a minimal size +--- is computed and some windows may be larger if there is room. The +--- 'eadirection' option tells in which direction the size is affected. +--- Changing the height and width of a window can be avoided by setting +--- 'winfixheight' and 'winfixwidth', respectively. +--- If a window size is specified when creating a new window sizes are +--- currently not equalized (it's complicated, but may be implemented in +--- the future). +--- +--- @type boolean +vim.o.equalalways = true +vim.o.ea = vim.o.equalalways +vim.go.equalalways = vim.o.equalalways +vim.go.ea = vim.go.equalalways + +--- External program to use for "=" command. When this option is empty +--- the internal formatting functions are used; either 'lisp', 'cindent' +--- or 'indentexpr'. +--- Environment variables are expanded `:set_env`. See `option-backslash` +--- about including spaces and backslashes. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.equalprg = "" +vim.o.ep = vim.o.equalprg +vim.bo.equalprg = vim.o.equalprg +vim.bo.ep = vim.bo.equalprg +vim.go.equalprg = vim.o.equalprg +vim.go.ep = vim.go.equalprg + +--- Ring the bell (beep or screen flash) for error messages. This only +--- makes a difference for error messages, the bell will be used always +--- for a lot of errors without a message (e.g., hitting <Esc> in Normal +--- mode). See 'visualbell' to make the bell behave like a screen flash +--- or do nothing. See 'belloff' to finetune when to ring the bell. +--- +--- @type boolean +vim.o.errorbells = false +vim.o.eb = vim.o.errorbells +vim.go.errorbells = vim.o.errorbells +vim.go.eb = vim.go.errorbells + +--- Name of the errorfile for the QuickFix mode (see `:cf`). +--- When the "-q" command-line argument is used, 'errorfile' is set to the +--- following argument. See `-q`. +--- NOT used for the ":make" command. See 'makeef' for that. +--- Environment variables are expanded `:set_env`. +--- See `option-backslash` about including spaces and backslashes. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.errorfile = "errors.err" +vim.o.ef = vim.o.errorfile +vim.go.errorfile = vim.o.errorfile +vim.go.ef = vim.go.errorfile + +--- Scanf-like description of the format for the lines in the error file +--- (see `errorformat`). +--- +--- @type string +vim.o.errorformat = "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-Gg%\\?make[%*\\d]: *** [%f:%l:%m,%-Gg%\\?make: *** [%f:%l:%m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m" +vim.o.efm = vim.o.errorformat +vim.bo.errorformat = vim.o.errorformat +vim.bo.efm = vim.bo.errorformat +vim.go.errorformat = vim.o.errorformat +vim.go.efm = vim.go.errorformat + +--- A list of autocommand event names, which are to be ignored. +--- When set to "all" or when "all" is one of the items, all autocommand +--- events are ignored, autocommands will not be executed. +--- Otherwise this is a comma-separated list of event names. Example: +--- ``` +--- :set ei=WinEnter,WinLeave +--- ``` +--- +--- +--- @type string +vim.o.eventignore = "" +vim.o.ei = vim.o.eventignore +vim.go.eventignore = vim.o.eventignore +vim.go.ei = vim.go.eventignore + +--- In Insert mode: Use the appropriate number of spaces to insert a +--- <Tab>. Spaces are used in indents with the '>' and '<' commands and +--- when 'autoindent' is on. To insert a real tab when 'expandtab' is +--- on, use CTRL-V<Tab>. See also `:retab` and `ins-expandtab`. +--- +--- @type boolean +vim.o.expandtab = false +vim.o.et = vim.o.expandtab +vim.bo.expandtab = vim.o.expandtab +vim.bo.et = vim.bo.expandtab + +--- Automatically execute .nvim.lua, .nvimrc, and .exrc files in the +--- current directory, if the file is in the `trust` list. Use `:trust` to +--- manage trusted files. See also `vim.secure.read()`. +--- +--- Compare 'exrc' to `editorconfig`: +--- - 'exrc' can execute any code; editorconfig only specifies settings. +--- - 'exrc' is Nvim-specific; editorconfig works in other editors. +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type boolean +vim.o.exrc = false +vim.o.ex = vim.o.exrc +vim.go.exrc = vim.o.exrc +vim.go.ex = vim.go.exrc + +--- File-content encoding for the current buffer. Conversion is done with +--- iconv() or as specified with 'charconvert'. +--- +--- When 'fileencoding' is not UTF-8, conversion will be done when +--- writing the file. For reading see below. +--- When 'fileencoding' is empty, the file will be saved with UTF-8 +--- encoding (no conversion when reading or writing a file). +--- +--- WARNING: Conversion to a non-Unicode encoding can cause loss of +--- information! +--- +--- See `encoding-names` for the possible values. Additionally, values may be +--- specified that can be handled by the converter, see +--- `mbyte-conversion`. +--- +--- When reading a file 'fileencoding' will be set from 'fileencodings'. +--- To read a file in a certain encoding it won't work by setting +--- 'fileencoding', use the `++enc` argument. One exception: when +--- 'fileencodings' is empty the value of 'fileencoding' is used. +--- For a new file the global value of 'fileencoding' is used. +--- +--- Prepending "8bit-" and "2byte-" has no meaning here, they are ignored. +--- When the option is set, the value is converted to lowercase. Thus +--- you can set it with uppercase values too. '_' characters are +--- replaced with '-'. If a name is recognized from the list at +--- `encoding-names`, it is replaced by the standard name. For example +--- "ISO8859-2" becomes "iso-8859-2". +--- +--- When this option is set, after starting to edit a file, the 'modified' +--- option is set, because the file would be different when written. +--- +--- Keep in mind that changing 'fenc' from a modeline happens +--- AFTER the text has been read, thus it applies to when the file will be +--- written. If you do set 'fenc' in a modeline, you might want to set +--- 'nomodified' to avoid not being able to ":q". +--- +--- This option cannot be changed when 'modifiable' is off. +--- +--- @type string +vim.o.fileencoding = "" +vim.o.fenc = vim.o.fileencoding +vim.bo.fileencoding = vim.o.fileencoding +vim.bo.fenc = vim.bo.fileencoding + +--- This is a list of character encodings considered when starting to edit +--- an existing file. When a file is read, Vim tries to use the first +--- mentioned character encoding. If an error is detected, the next one +--- in the list is tried. When an encoding is found that works, +--- 'fileencoding' is set to it. If all fail, 'fileencoding' is set to +--- an empty string, which means that UTF-8 is used. +--- WARNING: Conversion can cause loss of information! You can use +--- the `++bad` argument to specify what is done with characters +--- that can't be converted. +--- For an empty file or a file with only ASCII characters most encodings +--- will work and the first entry of 'fileencodings' will be used (except +--- "ucs-bom", which requires the BOM to be present). If you prefer +--- another encoding use an BufReadPost autocommand event to test if your +--- preferred encoding is to be used. Example: +--- ``` +--- au BufReadPost * if search('\S', 'w') == 0 | +--- \ set fenc=iso-2022-jp | endif +--- ``` +--- This sets 'fileencoding' to "iso-2022-jp" if the file does not contain +--- non-blank characters. +--- When the `++enc` argument is used then the value of 'fileencodings' is +--- not used. +--- Note that 'fileencodings' is not used for a new file, the global value +--- of 'fileencoding' is used instead. You can set it with: +--- ``` +--- :setglobal fenc=iso-8859-2 +--- ``` +--- This means that a non-existing file may get a different encoding than +--- an empty file. +--- The special value "ucs-bom" can be used to check for a Unicode BOM +--- (Byte Order Mark) at the start of the file. It must not be preceded +--- by "utf-8" or another Unicode encoding for this to work properly. +--- An entry for an 8-bit encoding (e.g., "latin1") should be the last, +--- because Vim cannot detect an error, thus the encoding is always +--- accepted. +--- The special value "default" can be used for the encoding from the +--- environment. It is useful when your environment uses a non-latin1 +--- encoding, such as Russian. +--- When a file contains an illegal UTF-8 byte sequence it won't be +--- recognized as "utf-8". You can use the `8g8` command to find the +--- illegal byte sequence. +--- WRONG VALUES: WHAT'S WRONG: +--- latin1,utf-8 "latin1" will always be used +--- utf-8,ucs-bom,latin1 BOM won't be recognized in an utf-8 +--- file +--- cp1250,latin1 "cp1250" will always be used +--- If 'fileencodings' is empty, 'fileencoding' is not modified. +--- See 'fileencoding' for the possible values. +--- Setting this option does not have an effect until the next time a file +--- is read. +--- +--- @type string +vim.o.fileencodings = "ucs-bom,utf-8,default,latin1" +vim.o.fencs = vim.o.fileencodings +vim.go.fileencodings = vim.o.fileencodings +vim.go.fencs = vim.go.fileencodings + +--- This gives the <EOL> of the current buffer, which is used for +--- reading/writing the buffer from/to a file: +--- dos <CR><NL> +--- unix <NL> +--- mac <CR> +--- When "dos" is used, CTRL-Z at the end of a file is ignored. +--- See `file-formats` and `file-read`. +--- For the character encoding of the file see 'fileencoding'. +--- When 'binary' is set, the value of 'fileformat' is ignored, file I/O +--- works like it was set to "unix". +--- This option is set automatically when starting to edit a file and +--- 'fileformats' is not empty and 'binary' is off. +--- When this option is set, after starting to edit a file, the 'modified' +--- option is set, because the file would be different when written. +--- This option cannot be changed when 'modifiable' is off. +--- +--- @type string +vim.o.fileformat = "unix" +vim.o.ff = vim.o.fileformat +vim.bo.fileformat = vim.o.fileformat +vim.bo.ff = vim.bo.fileformat + +--- This gives the end-of-line (<EOL>) formats that will be tried when +--- starting to edit a new buffer and when reading a file into an existing +--- buffer: +--- - When empty, the format defined with 'fileformat' will be used +--- always. It is not set automatically. +--- - When set to one name, that format will be used whenever a new buffer +--- is opened. 'fileformat' is set accordingly for that buffer. The +--- 'fileformats' name will be used when a file is read into an existing +--- buffer, no matter what 'fileformat' for that buffer is set to. +--- - When more than one name is present, separated by commas, automatic +--- <EOL> detection will be done when reading a file. When starting to +--- edit a file, a check is done for the <EOL>: +--- 1. If all lines end in <CR><NL>, and 'fileformats' includes "dos", +--- 'fileformat' is set to "dos". +--- 2. If a <NL> is found and 'fileformats' includes "unix", 'fileformat' +--- is set to "unix". Note that when a <NL> is found without a +--- preceding <CR>, "unix" is preferred over "dos". +--- 3. If 'fileformat' has not yet been set, and if a <CR> is found, and +--- if 'fileformats' includes "mac", 'fileformat' is set to "mac". +--- This means that "mac" is only chosen when: +--- "unix" is not present or no <NL> is found in the file, and +--- "dos" is not present or no <CR><NL> is found in the file. +--- Except: if "unix" was chosen, but there is a <CR> before +--- the first <NL>, and there appear to be more <CR>s than <NL>s in +--- the first few lines, "mac" is used. +--- 4. If 'fileformat' is still not set, the first name from +--- 'fileformats' is used. +--- When reading a file into an existing buffer, the same is done, but +--- this happens like 'fileformat' has been set appropriately for that +--- file only, the option is not changed. +--- When 'binary' is set, the value of 'fileformats' is not used. +--- +--- When Vim starts up with an empty buffer the first item is used. You +--- can overrule this by setting 'fileformat' in your .vimrc. +--- +--- For systems with a Dos-like <EOL> (<CR><NL>), when reading files that +--- are ":source"ed and for vimrc files, automatic <EOL> detection may be +--- done: +--- - When 'fileformats' is empty, there is no automatic detection. Dos +--- format will be used. +--- - When 'fileformats' is set to one or more names, automatic detection +--- is done. This is based on the first <NL> in the file: If there is a +--- <CR> in front of it, Dos format is used, otherwise Unix format is +--- used. +--- Also see `file-formats`. +--- +--- @type string +vim.o.fileformats = "unix,dos" +vim.o.ffs = vim.o.fileformats +vim.go.fileformats = vim.o.fileformats +vim.go.ffs = vim.go.fileformats + +--- When set case is ignored when using file names and directories. +--- See 'wildignorecase' for only ignoring case when doing completion. +--- +--- @type boolean +vim.o.fileignorecase = false +vim.o.fic = vim.o.fileignorecase +vim.go.fileignorecase = vim.o.fileignorecase +vim.go.fic = vim.go.fileignorecase + +--- When this option is set, the FileType autocommand event is triggered. +--- All autocommands that match with the value of this option will be +--- executed. Thus the value of 'filetype' is used in place of the file +--- name. +--- Otherwise this option does not always reflect the current file type. +--- This option is normally set when the file type is detected. To enable +--- this use the ":filetype on" command. `:filetype` +--- Setting this option to a different value is most useful in a modeline, +--- for a file for which the file type is not automatically recognized. +--- Example, for in an IDL file: +--- ``` +--- /* vim: set filetype=idl : */ +--- ``` +--- `FileType` `filetypes` +--- When a dot appears in the value then this separates two filetype +--- names. Example: +--- ``` +--- /* vim: set filetype=c.doxygen : */ +--- ``` +--- This will use the "c" filetype first, then the "doxygen" filetype. +--- This works both for filetype plugins and for syntax files. More than +--- one dot may appear. +--- This option is not copied to another buffer, independent of the 's' or +--- 'S' flag in 'cpoptions'. +--- Only normal file name characters can be used, `/\*?[|<>` are illegal. +--- +--- @type string +vim.o.filetype = "" +vim.o.ft = vim.o.filetype +vim.bo.filetype = vim.o.filetype +vim.bo.ft = vim.bo.filetype + +--- Characters to fill the statuslines, vertical separators and special +--- lines in the window. +--- It is a comma-separated list of items. Each item has a name, a colon +--- and the value of that item: +--- +--- item default Used for ~ +--- stl ' ' statusline of the current window +--- stlnc ' ' statusline of the non-current windows +--- wbr ' ' window bar +--- horiz '─' or '-' horizontal separators `:split` +--- horizup '┴' or '-' upwards facing horizontal separator +--- horizdown '┬' or '-' downwards facing horizontal separator +--- vert '│' or '|' vertical separators `:vsplit` +--- vertleft '┤' or '|' left facing vertical separator +--- vertright '├' or '|' right facing vertical separator +--- verthoriz '┼' or '+' overlapping vertical and horizontal +--- separator +--- fold '·' or '-' filling 'foldtext' +--- foldopen '-' mark the beginning of a fold +--- foldclose '+' show a closed fold +--- foldsep '│' or '|' open fold middle marker +--- diff '-' deleted lines of the 'diff' option +--- msgsep ' ' message separator 'display' +--- eob '~' empty lines at the end of a buffer +--- lastline '@' 'display' contains lastline/truncate +--- +--- Any one that is omitted will fall back to the default. +--- +--- Note that "horiz", "horizup", "horizdown", "vertleft", "vertright" and +--- "verthoriz" are only used when 'laststatus' is 3, since only vertical +--- window separators are used otherwise. +--- +--- If 'ambiwidth' is "double" then "horiz", "horizup", "horizdown", +--- "vert", "vertleft", "vertright", "verthoriz", "foldsep" and "fold" +--- default to single-byte alternatives. +--- +--- Example: +--- ``` +--- :set fillchars=stl:\ ,stlnc:\ ,vert:│,fold:·,diff:- +--- ``` +--- +--- For the "stl", "stlnc", "foldopen", "foldclose" and "foldsep" items +--- single-byte and multibyte characters are supported. But double-width +--- characters are not supported. +--- +--- The highlighting used for these items: +--- item highlight group ~ +--- stl StatusLine `hl-StatusLine` +--- stlnc StatusLineNC `hl-StatusLineNC` +--- wbr WinBar `hl-WinBar` or `hl-WinBarNC` +--- horiz WinSeparator `hl-WinSeparator` +--- horizup WinSeparator `hl-WinSeparator` +--- horizdown WinSeparator `hl-WinSeparator` +--- vert WinSeparator `hl-WinSeparator` +--- vertleft WinSeparator `hl-WinSeparator` +--- vertright WinSeparator `hl-WinSeparator` +--- verthoriz WinSeparator `hl-WinSeparator` +--- fold Folded `hl-Folded` +--- diff DiffDelete `hl-DiffDelete` +--- eob EndOfBuffer `hl-EndOfBuffer` +--- lastline NonText `hl-NonText` +--- +--- @type string +vim.o.fillchars = "" +vim.o.fcs = vim.o.fillchars +vim.wo.fillchars = vim.o.fillchars +vim.wo.fcs = vim.wo.fillchars +vim.go.fillchars = vim.o.fillchars +vim.go.fcs = vim.go.fillchars + +--- When writing a file and this option is on, <EOL> at the end of file +--- will be restored if missing. Turn this option off if you want to +--- preserve the situation from the original file. +--- When the 'binary' option is set the value of this option doesn't +--- matter. +--- See the 'endofline' option. +--- See `eol-and-eof` for example settings. +--- +--- @type boolean +vim.o.fixendofline = true +vim.o.fixeol = vim.o.fixendofline +vim.bo.fixendofline = vim.o.fixendofline +vim.bo.fixeol = vim.bo.fixendofline + +--- When set to "all", a fold is closed when the cursor isn't in it and +--- its level is higher than 'foldlevel'. Useful if you want folds to +--- automatically close when moving out of them. +--- +--- @type string +vim.o.foldclose = "" +vim.o.fcl = vim.o.foldclose +vim.go.foldclose = vim.o.foldclose +vim.go.fcl = vim.go.foldclose + +--- When and how to draw the foldcolumn. Valid values are: +--- "auto": resize to the minimum amount of folds to display. +--- "auto:[1-9]": resize to accommodate multiple folds up to the +--- selected level +--- "0": to disable foldcolumn +--- "[1-9]": to display a fixed number of columns +--- See `folding`. +--- +--- @type string +vim.o.foldcolumn = "0" +vim.o.fdc = vim.o.foldcolumn +vim.wo.foldcolumn = vim.o.foldcolumn +vim.wo.fdc = vim.wo.foldcolumn + +--- When off, all folds are open. This option can be used to quickly +--- switch between showing all text unfolded and viewing the text with +--- folds (including manually opened or closed folds). It can be toggled +--- with the `zi` command. The 'foldcolumn' will remain blank when +--- 'foldenable' is off. +--- This option is set by commands that create a new fold or close a fold. +--- See `folding`. +--- +--- @type boolean +vim.o.foldenable = true +vim.o.fen = vim.o.foldenable +vim.wo.foldenable = vim.o.foldenable +vim.wo.fen = vim.wo.foldenable + +--- The expression used for when 'foldmethod' is "expr". It is evaluated +--- for each line to obtain its fold level. The context is set to the +--- script where 'foldexpr' was set, script-local items can be accessed. +--- See `fold-expr` for the usage. +--- +--- The expression will be evaluated in the `sandbox` if set from a +--- modeline, see `sandbox-option`. +--- This option can't be set from a `modeline` when the 'diff' option is +--- on or the 'modelineexpr' option is off. +--- +--- It is not allowed to change text or jump to another window while +--- evaluating 'foldexpr' `textlock`. +--- +--- @type string +vim.o.foldexpr = "0" +vim.o.fde = vim.o.foldexpr +vim.wo.foldexpr = vim.o.foldexpr +vim.wo.fde = vim.wo.foldexpr + +--- Used only when 'foldmethod' is "indent". Lines starting with +--- characters in 'foldignore' will get their fold level from surrounding +--- lines. White space is skipped before checking for this character. +--- The default "#" works well for C programs. See `fold-indent`. +--- +--- @type string +vim.o.foldignore = "#" +vim.o.fdi = vim.o.foldignore +vim.wo.foldignore = vim.o.foldignore +vim.wo.fdi = vim.wo.foldignore + +--- Sets the fold level: Folds with a higher level will be closed. +--- Setting this option to zero will close all folds. Higher numbers will +--- close fewer folds. +--- This option is set by commands like `zm`, `zM` and `zR`. +--- See `fold-foldlevel`. +--- +--- @type integer +vim.o.foldlevel = 0 +vim.o.fdl = vim.o.foldlevel +vim.wo.foldlevel = vim.o.foldlevel +vim.wo.fdl = vim.wo.foldlevel + +--- Sets 'foldlevel' when starting to edit another buffer in a window. +--- Useful to always start editing with all folds closed (value zero), +--- some folds closed (one) or no folds closed (99). +--- This is done before reading any modeline, thus a setting in a modeline +--- overrules this option. Starting to edit a file for `diff-mode` also +--- ignores this option and closes all folds. +--- It is also done before BufReadPre autocommands, to allow an autocmd to +--- overrule the 'foldlevel' value for specific files. +--- When the value is negative, it is not used. +--- +--- @type integer +vim.o.foldlevelstart = -1 +vim.o.fdls = vim.o.foldlevelstart +vim.go.foldlevelstart = vim.o.foldlevelstart +vim.go.fdls = vim.go.foldlevelstart + +--- The start and end marker used when 'foldmethod' is "marker". There +--- must be one comma, which separates the start and end marker. The +--- marker is a literal string (a regular expression would be too slow). +--- See `fold-marker`. +--- +--- @type string +vim.o.foldmarker = "{{{,}}}" +vim.o.fmr = vim.o.foldmarker +vim.wo.foldmarker = vim.o.foldmarker +vim.wo.fmr = vim.wo.foldmarker + +--- The kind of folding used for the current window. Possible values: +--- `fold-manual` manual Folds are created manually. +--- `fold-indent` indent Lines with equal indent form a fold. +--- `fold-expr` expr 'foldexpr' gives the fold level of a line. +--- `fold-marker` marker Markers are used to specify folds. +--- `fold-syntax` syntax Syntax highlighting items specify folds. +--- `fold-diff` diff Fold text that is not changed. +--- +--- @type string +vim.o.foldmethod = "manual" +vim.o.fdm = vim.o.foldmethod +vim.wo.foldmethod = vim.o.foldmethod +vim.wo.fdm = vim.wo.foldmethod + +--- Sets the number of screen lines above which a fold can be displayed +--- closed. Also for manually closed folds. With the default value of +--- one a fold can only be closed if it takes up two or more screen lines. +--- Set to zero to be able to close folds of just one screen line. +--- Note that this only has an effect on what is displayed. After using +--- "zc" to close a fold, which is displayed open because it's smaller +--- than 'foldminlines', a following "zc" may close a containing fold. +--- +--- @type integer +vim.o.foldminlines = 1 +vim.o.fml = vim.o.foldminlines +vim.wo.foldminlines = vim.o.foldminlines +vim.wo.fml = vim.wo.foldminlines + +--- Sets the maximum nesting of folds for the "indent" and "syntax" +--- methods. This avoids that too many folds will be created. Using more +--- than 20 doesn't work, because the internal limit is 20. +--- +--- @type integer +vim.o.foldnestmax = 20 +vim.o.fdn = vim.o.foldnestmax +vim.wo.foldnestmax = vim.o.foldnestmax +vim.wo.fdn = vim.wo.foldnestmax + +--- Specifies for which type of commands folds will be opened, if the +--- command moves the cursor into a closed fold. It is a comma-separated +--- list of items. +--- NOTE: When the command is part of a mapping this option is not used. +--- Add the `zv` command to the mapping to get the same effect. +--- (rationale: the mapping may want to control opening folds itself) +--- +--- item commands ~ +--- all any +--- block (, {, [[, [{, etc. +--- hor horizontal movements: "l", "w", "fx", etc. +--- insert any command in Insert mode +--- jump far jumps: "G", "gg", etc. +--- mark jumping to a mark: "'m", CTRL-O, etc. +--- percent "%" +--- quickfix ":cn", ":crew", ":make", etc. +--- search search for a pattern: "/", "n", "*", "gd", etc. +--- (not for a search pattern in a ":" command) +--- Also for `[s` and `]s`. +--- tag jumping to a tag: ":ta", CTRL-T, etc. +--- undo undo or redo: "u" and CTRL-R +--- When a movement command is used for an operator (e.g., "dl" or "y%") +--- this option is not used. This means the operator will include the +--- whole closed fold. +--- Note that vertical movements are not here, because it would make it +--- very difficult to move onto a closed fold. +--- In insert mode the folds containing the cursor will always be open +--- when text is inserted. +--- To close folds you can re-apply 'foldlevel' with the `zx` command or +--- set the 'foldclose' option to "all". +--- +--- @type string +vim.o.foldopen = "block,hor,mark,percent,quickfix,search,tag,undo" +vim.o.fdo = vim.o.foldopen +vim.go.foldopen = vim.o.foldopen +vim.go.fdo = vim.go.foldopen + +--- An expression which is used to specify the text displayed for a closed +--- fold. The context is set to the script where 'foldexpr' was set, +--- script-local items can be accessed. See `fold-foldtext` for the +--- usage. +--- +--- The expression will be evaluated in the `sandbox` if set from a +--- modeline, see `sandbox-option`. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- It is not allowed to change text or jump to another window while +--- evaluating 'foldtext' `textlock`. +--- +--- @type string +vim.o.foldtext = "foldtext()" +vim.o.fdt = vim.o.foldtext +vim.wo.foldtext = vim.o.foldtext +vim.wo.fdt = vim.wo.foldtext + +--- Expression which is evaluated to format a range of lines for the `gq` +--- operator or automatic formatting (see 'formatoptions'). When this +--- option is empty 'formatprg' is used. +--- +--- The `v:lnum` variable holds the first line to be formatted. +--- The `v:count` variable holds the number of lines to be formatted. +--- The `v:char` variable holds the character that is going to be +--- inserted if the expression is being evaluated due to +--- automatic formatting. This can be empty. Don't insert +--- it yet! +--- +--- Example: +--- ``` +--- :set formatexpr=mylang#Format() +--- ``` +--- This will invoke the mylang#Format() function in the +--- autoload/mylang.vim file in 'runtimepath'. `autoload` +--- +--- The expression is also evaluated when 'textwidth' is set and adding +--- text beyond that limit. This happens under the same conditions as +--- when internal formatting is used. Make sure the cursor is kept in the +--- same spot relative to the text then! The `mode()` function will +--- return "i" or "R" in this situation. +--- +--- When the expression evaluates to non-zero Vim will fall back to using +--- the internal format mechanism. +--- +--- If the expression starts with s: or `<SID>`, then it is replaced with +--- the script ID (`local-function`). Example: +--- ``` +--- set formatexpr=s:MyFormatExpr() +--- set formatexpr=<SID>SomeFormatExpr() +--- ``` +--- Otherwise, the expression is evaluated in the context of the script +--- where the option was set, thus script-local items are available. +--- +--- The expression will be evaluated in the `sandbox` when set from a +--- modeline, see `sandbox-option`. That stops the option from working, +--- since changing the buffer text is not allowed. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- NOTE: This option is set to "" when 'compatible' is set. +--- +--- @type string +vim.o.formatexpr = "" +vim.o.fex = vim.o.formatexpr +vim.bo.formatexpr = vim.o.formatexpr +vim.bo.fex = vim.bo.formatexpr + +--- A pattern that is used to recognize a list header. This is used for +--- the "n" flag in 'formatoptions'. +--- The pattern must match exactly the text that will be the indent for +--- the line below it. You can use `/\ze` to mark the end of the match +--- while still checking more characters. There must be a character +--- following the pattern, when it matches the whole line it is handled +--- like there is no match. +--- The default recognizes a number, followed by an optional punctuation +--- character and white space. +--- +--- @type string +vim.o.formatlistpat = "^\\s*\\d\\+[\\]:.)}\\t ]\\s*" +vim.o.flp = vim.o.formatlistpat +vim.bo.formatlistpat = vim.o.formatlistpat +vim.bo.flp = vim.bo.formatlistpat + +--- This is a sequence of letters which describes how automatic +--- formatting is to be done. +--- See `fo-table` for possible values and `gq` for how to format text. +--- Commas can be inserted for readability. +--- To avoid problems with flags that are added in the future, use the +--- "+=" and "-=" feature of ":set" `add-option-flags`. +--- +--- @type string +vim.o.formatoptions = "tcqj" +vim.o.fo = vim.o.formatoptions +vim.bo.formatoptions = vim.o.formatoptions +vim.bo.fo = vim.bo.formatoptions + +--- The name of an external program that will be used to format the lines +--- selected with the `gq` operator. The program must take the input on +--- stdin and produce the output on stdout. The Unix program "fmt" is +--- such a program. +--- If the 'formatexpr' option is not empty it will be used instead. +--- Otherwise, if 'formatprg' option is an empty string, the internal +--- format function will be used `C-indenting`. +--- Environment variables are expanded `:set_env`. See `option-backslash` +--- about including spaces and backslashes. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.formatprg = "" +vim.o.fp = vim.o.formatprg +vim.bo.formatprg = vim.o.formatprg +vim.bo.fp = vim.bo.formatprg +vim.go.formatprg = vim.o.formatprg +vim.go.fp = vim.go.formatprg + +--- When on, the OS function fsync() will be called after saving a file +--- (`:write`, `writefile()`, …), `swap-file`, `undo-persistence` and `shada-file`. +--- This flushes the file to disk, ensuring that it is safely written. +--- Slow on some systems: writing buffers, quitting Nvim, and other +--- operations may sometimes take a few seconds. +--- +--- Files are ALWAYS flushed ('fsync' is ignored) when: +--- - `CursorHold` event is triggered +--- - `:preserve` is called +--- - system signals low battery life +--- - Nvim exits abnormally +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type boolean +vim.o.fsync = true +vim.o.fs = vim.o.fsync +vim.go.fsync = vim.o.fsync +vim.go.fs = vim.go.fsync + +--- When on, the ":substitute" flag 'g' is default on. This means that +--- all matches in a line are substituted instead of one. When a 'g' flag +--- is given to a ":substitute" command, this will toggle the substitution +--- of all or one match. See `complex-change`. +--- +--- command 'gdefault' on 'gdefault' off ~ +--- :s/// subst. all subst. one +--- :s///g subst. one subst. all +--- :s///gg subst. all subst. one +--- +--- DEPRECATED: Setting this option may break plugins that are not aware +--- of this option. Also, many users get confused that adding the /g flag +--- has the opposite effect of that it normally does. +--- +--- @type boolean +vim.o.gdefault = false +vim.o.gd = vim.o.gdefault +vim.go.gdefault = vim.o.gdefault +vim.go.gd = vim.go.gdefault + +--- Format to recognize for the ":grep" command output. +--- This is a scanf-like string that uses the same format as the +--- 'errorformat' option: see `errorformat`. +--- +--- @type string +vim.o.grepformat = "%f:%l:%m,%f:%l%m,%f %l%m" +vim.o.gfm = vim.o.grepformat +vim.go.grepformat = vim.o.grepformat +vim.go.gfm = vim.go.grepformat + +--- Program to use for the `:grep` command. This option may contain '%' +--- and '#' characters, which are expanded like when used in a command- +--- line. The placeholder "$*" is allowed to specify where the arguments +--- will be included. Environment variables are expanded `:set_env`. See +--- `option-backslash` about including spaces and backslashes. +--- When your "grep" accepts the "-H" argument, use this to make ":grep" +--- also work well with a single file: +--- ``` +--- :set grepprg=grep\ -nH +--- ``` +--- Special value: When 'grepprg' is set to "internal" the `:grep` command +--- works like `:vimgrep`, `:lgrep` like `:lvimgrep`, `:grepadd` like +--- `:vimgrepadd` and `:lgrepadd` like `:lvimgrepadd`. +--- See also the section `:make_makeprg`, since most of the comments there +--- apply equally to 'grepprg'. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.grepprg = "grep -n $* /dev/null" +vim.o.gp = vim.o.grepprg +vim.bo.grepprg = vim.o.grepprg +vim.bo.gp = vim.bo.grepprg +vim.go.grepprg = vim.o.grepprg +vim.go.gp = vim.go.grepprg + +--- Configures the cursor style for each mode. Works in the GUI and many +--- terminals. See `tui-cursor-shape`. +--- +--- To disable cursor-styling, reset the option: +--- ``` +--- :set guicursor= +--- ``` +--- To enable mode shapes, "Cursor" highlight, and blinking: +--- ``` +--- :set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50 +--- \,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor +--- \,sm:block-blinkwait175-blinkoff150-blinkon175 +--- ``` +--- The option is a comma-separated list of parts. Each part consists of a +--- mode-list and an argument-list: +--- mode-list:argument-list,mode-list:argument-list,.. +--- The mode-list is a dash separated list of these modes: +--- n Normal mode +--- v Visual mode +--- ve Visual mode with 'selection' "exclusive" (same as 'v', +--- if not specified) +--- o Operator-pending mode +--- i Insert mode +--- r Replace mode +--- c Command-line Normal (append) mode +--- ci Command-line Insert mode +--- cr Command-line Replace mode +--- sm showmatch in Insert mode +--- a all modes +--- The argument-list is a dash separated list of these arguments: +--- hor{N} horizontal bar, {N} percent of the character height +--- ver{N} vertical bar, {N} percent of the character width +--- block block cursor, fills the whole character +--- - Only one of the above three should be present. +--- - Default is "block" for each mode. +--- blinkwait{N} *cursor-blinking* +--- blinkon{N} +--- blinkoff{N} +--- blink times for cursor: blinkwait is the delay before +--- the cursor starts blinking, blinkon is the time that +--- the cursor is shown and blinkoff is the time that the +--- cursor is not shown. Times are in msec. When one of +--- the numbers is zero, there is no blinking. E.g.: +--- ``` +--- :set guicursor=n:blinkon0 +--- ``` +--- - Default is "blinkon0" for each mode. +--- {group-name} +--- Highlight group that decides the color and font of the +--- cursor. +--- In the `TUI`: +--- - `inverse`/reverse and no group-name are interpreted +--- as "host-terminal default cursor colors" which +--- typically means "inverted bg and fg colors". +--- - `ctermfg` and `guifg` are ignored. +--- {group-name}/{group-name} +--- Two highlight group names, the first is used when +--- no language mappings are used, the other when they +--- are. `language-mapping` +--- +--- Examples of parts: +--- n-c-v:block-nCursor In Normal, Command-line and Visual mode, use a +--- block cursor with colors from the "nCursor" +--- highlight group +--- n-v-c-sm:block,i-ci-ve:ver25-Cursor,r-cr-o:hor20 +--- In Normal et al. modes, use a block cursor +--- with the default colors defined by the host +--- terminal. In Insert-like modes, use +--- a vertical bar cursor with colors from +--- "Cursor" highlight group. In Replace-like +--- modes, use an underline cursor with +--- default colors. +--- i-ci:ver30-iCursor-blinkwait300-blinkon200-blinkoff150 +--- In Insert and Command-line Insert mode, use a +--- 30% vertical bar cursor with colors from the +--- "iCursor" highlight group. Blink a bit +--- faster. +--- +--- The 'a' mode is different. It will set the given argument-list for +--- all modes. It does not reset anything to defaults. This can be used +--- to do a common setting for all modes. For example, to switch off +--- blinking: "a:blinkon0" +--- +--- Examples of cursor highlighting: +--- ``` +--- :highlight Cursor gui=reverse guifg=NONE guibg=NONE +--- :highlight Cursor gui=NONE guifg=bg guibg=fg +--- ``` +--- +--- +--- @type string +vim.o.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" +vim.o.gcr = vim.o.guicursor +vim.go.guicursor = vim.o.guicursor +vim.go.gcr = vim.go.guicursor + +--- This is a list of fonts which will be used for the GUI version of Vim. +--- In its simplest form the value is just one font name. When +--- the font cannot be found you will get an error message. To try other +--- font names a list can be specified, font names separated with commas. +--- The first valid font is used. +--- +--- Spaces after a comma are ignored. To include a comma in a font name +--- precede it with a backslash. Setting an option requires an extra +--- backslash before a space and a backslash. See also +--- `option-backslash`. For example: +--- ``` +--- :set guifont=Screen15,\ 7x13,font\\,with\\,commas +--- ``` +--- will make Vim try to use the font "Screen15" first, and if it fails it +--- will try to use "7x13" and then "font,with,commas" instead. +--- +--- If none of the fonts can be loaded, Vim will keep the current setting. +--- If an empty font list is given, Vim will try using other resource +--- settings (for X, it will use the Vim.font resource), and finally it +--- will try some builtin default which should always be there ("7x13" in +--- the case of X). The font names given should be "normal" fonts. Vim +--- will try to find the related bold and italic fonts. +--- +--- For Win32 and Mac OS: +--- ``` +--- :set guifont=* +--- ``` +--- will bring up a font requester, where you can pick the font you want. +--- +--- The font name depends on the GUI used. +--- +--- For Mac OSX you can use something like this: +--- ``` +--- :set guifont=Monaco:h10 +--- ``` +--- *E236* +--- Note that the fonts must be mono-spaced (all characters have the same +--- width). +--- +--- To preview a font on X11, you might be able to use the "xfontsel" +--- program. The "xlsfonts" program gives a list of all available fonts. +--- +--- For the Win32 GUI *E244* *E245* +--- - takes these options in the font name: +--- hXX - height is XX (points, can be floating-point) +--- wXX - width is XX (points, can be floating-point) +--- b - bold +--- i - italic +--- u - underline +--- s - strikeout +--- cXX - character set XX. Valid charsets are: ANSI, ARABIC, +--- BALTIC, CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK, +--- HANGEUL, HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS, +--- SYMBOL, THAI, TURKISH, VIETNAMESE ANSI and BALTIC. +--- Normally you would use "cDEFAULT". +--- +--- Use a ':' to separate the options. +--- - A '_' can be used in the place of a space, so you don't need to use +--- backslashes to escape the spaces. +--- - Examples: +--- ``` +--- :set guifont=courier_new:h12:w5:b:cRUSSIAN +--- :set guifont=Andale_Mono:h7.5:w4.5 +--- ``` +--- +--- +--- @type string +vim.o.guifont = "" +vim.o.gfn = vim.o.guifont +vim.go.guifont = vim.o.guifont +vim.go.gfn = vim.go.guifont + +--- Comma-separated list of fonts to be used for double-width characters. +--- The first font that can be loaded is used. +--- Note: The size of these fonts must be exactly twice as wide as the one +--- specified with 'guifont' and the same height. +--- +--- When 'guifont' has a valid font and 'guifontwide' is empty Vim will +--- attempt to set 'guifontwide' to a matching double-width font. +--- +--- @type string +vim.o.guifontwide = "" +vim.o.gfw = vim.o.guifontwide +vim.go.guifontwide = vim.o.guifontwide +vim.go.gfw = vim.go.guifontwide + +--- This option only has an effect in the GUI version of Vim. It is a +--- sequence of letters which describes what components and options of the +--- GUI should be used. +--- To avoid problems with flags that are added in the future, use the +--- "+=" and "-=" feature of ":set" `add-option-flags`. +--- +--- Valid letters are as follows: +--- *guioptions_a* *'go-a'* +--- 'a' Autoselect: If present, then whenever VISUAL mode is started, +--- or the Visual area extended, Vim tries to become the owner of +--- the windowing system's global selection. This means that the +--- Visually highlighted text is available for pasting into other +--- applications as well as into Vim itself. When the Visual mode +--- ends, possibly due to an operation on the text, or when an +--- application wants to paste the selection, the highlighted text +--- is automatically yanked into the "* selection register. +--- Thus the selection is still available for pasting into other +--- applications after the VISUAL mode has ended. +--- If not present, then Vim won't become the owner of the +--- windowing system's global selection unless explicitly told to +--- by a yank or delete operation for the "* register. +--- The same applies to the modeless selection. +--- *'go-P'* +--- 'P' Like autoselect but using the "+ register instead of the "* +--- register. +--- *'go-A'* +--- 'A' Autoselect for the modeless selection. Like 'a', but only +--- applies to the modeless selection. +--- +--- 'guioptions' autoselect Visual autoselect modeless ~ +--- "" - - +--- "a" yes yes +--- "A" - yes +--- "aA" yes yes +--- +--- *'go-c'* +--- 'c' Use console dialogs instead of popup dialogs for simple +--- choices. +--- *'go-d'* +--- 'd' Use dark theme variant if available. +--- *'go-e'* +--- 'e' Add tab pages when indicated with 'showtabline'. +--- 'guitablabel' can be used to change the text in the labels. +--- When 'e' is missing a non-GUI tab pages line may be used. +--- The GUI tabs are only supported on some systems, currently +--- Mac OS/X and MS-Windows. +--- *'go-i'* +--- 'i' Use a Vim icon. +--- *'go-m'* +--- 'm' Menu bar is present. +--- *'go-M'* +--- 'M' The system menu "$VIMRUNTIME/menu.vim" is not sourced. Note +--- that this flag must be added in the vimrc file, before +--- switching on syntax or filetype recognition (when the `gvimrc` +--- file is sourced the system menu has already been loaded; the +--- `:syntax on` and `:filetype on` commands load the menu too). +--- *'go-g'* +--- 'g' Grey menu items: Make menu items that are not active grey. If +--- 'g' is not included inactive menu items are not shown at all. +--- *'go-T'* +--- 'T' Include Toolbar. Currently only in Win32 GUI. +--- *'go-r'* +--- 'r' Right-hand scrollbar is always present. +--- *'go-R'* +--- 'R' Right-hand scrollbar is present when there is a vertically +--- split window. +--- *'go-l'* +--- 'l' Left-hand scrollbar is always present. +--- *'go-L'* +--- 'L' Left-hand scrollbar is present when there is a vertically +--- split window. +--- *'go-b'* +--- 'b' Bottom (horizontal) scrollbar is present. Its size depends on +--- the longest visible line, or on the cursor line if the 'h' +--- flag is included. `gui-horiz-scroll` +--- *'go-h'* +--- 'h' Limit horizontal scrollbar size to the length of the cursor +--- line. Reduces computations. `gui-horiz-scroll` +--- +--- And yes, you may even have scrollbars on the left AND the right if +--- you really want to :-). See `gui-scrollbars` for more information. +--- +--- *'go-v'* +--- 'v' Use a vertical button layout for dialogs. When not included, +--- a horizontal layout is preferred, but when it doesn't fit a +--- vertical layout is used anyway. Not supported in GTK 3. +--- *'go-p'* +--- 'p' Use Pointer callbacks for X11 GUI. This is required for some +--- window managers. If the cursor is not blinking or hollow at +--- the right moment, try adding this flag. This must be done +--- before starting the GUI. Set it in your `gvimrc`. Adding or +--- removing it after the GUI has started has no effect. +--- *'go-k'* +--- 'k' Keep the GUI window size when adding/removing a scrollbar, or +--- toolbar, tabline, etc. Instead, the behavior is similar to +--- when the window is maximized and will adjust 'lines' and +--- 'columns' to fit to the window. Without the 'k' flag Vim will +--- try to keep 'lines' and 'columns' the same when adding and +--- removing GUI components. +--- +--- @type string +vim.o.guioptions = "" +vim.o.go = vim.o.guioptions +vim.go.guioptions = vim.o.guioptions +vim.go.go = vim.go.guioptions + +--- When non-empty describes the text to use in a label of the GUI tab +--- pages line. When empty and when the result is empty Vim will use a +--- default label. See `setting-guitablabel` for more info. +--- +--- The format of this option is like that of 'statusline'. +--- 'guitabtooltip' is used for the tooltip, see below. +--- The expression will be evaluated in the `sandbox` when set from a +--- modeline, see `sandbox-option`. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- Only used when the GUI tab pages line is displayed. 'e' must be +--- present in 'guioptions'. For the non-GUI tab pages line 'tabline' is +--- used. +--- +--- @type string +vim.o.guitablabel = "" +vim.o.gtl = vim.o.guitablabel +vim.go.guitablabel = vim.o.guitablabel +vim.go.gtl = vim.go.guitablabel + +--- When non-empty describes the text to use in a tooltip for the GUI tab +--- pages line. When empty Vim will use a default tooltip. +--- This option is otherwise just like 'guitablabel' above. +--- You can include a line break. Simplest method is to use `:let`: +--- ``` +--- :let &guitabtooltip = "line one\nline two" +--- ``` +--- +--- +--- @type string +vim.o.guitabtooltip = "" +vim.o.gtt = vim.o.guitabtooltip +vim.go.guitabtooltip = vim.o.guitabtooltip +vim.go.gtt = vim.go.guitabtooltip + +--- Name of the main help file. All distributed help files should be +--- placed together in one directory. Additionally, all "doc" directories +--- in 'runtimepath' will be used. +--- Environment variables are expanded `:set_env`. For example: +--- "$VIMRUNTIME/doc/help.txt". If $VIMRUNTIME is not set, $VIM is also +--- tried. Also see `$VIMRUNTIME` and `option-backslash` about including +--- spaces and backslashes. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.helpfile = "$VIMRUNTIME/doc/help.txt" +vim.o.hf = vim.o.helpfile +vim.go.helpfile = vim.o.helpfile +vim.go.hf = vim.go.helpfile + +--- Minimal initial height of the help window when it is opened with the +--- ":help" command. The initial height of the help window is half of the +--- current window, or (when the 'ea' option is on) the same as other +--- windows. When the height is less than 'helpheight', the height is +--- set to 'helpheight'. Set to zero to disable. +--- +--- @type integer +vim.o.helpheight = 20 +vim.o.hh = vim.o.helpheight +vim.go.helpheight = vim.o.helpheight +vim.go.hh = vim.go.helpheight + +--- Comma-separated list of languages. Vim will use the first language +--- for which the desired help can be found. The English help will always +--- be used as a last resort. You can add "en" to prefer English over +--- another language, but that will only find tags that exist in that +--- language and not in the English help. +--- Example: +--- ``` +--- :set helplang=de,it +--- ``` +--- This will first search German, then Italian and finally English help +--- files. +--- When using `CTRL-]` and ":help!" in a non-English help file Vim will +--- try to find the tag in the current language before using this option. +--- See `help-translated`. +--- +--- @type string +vim.o.helplang = "" +vim.o.hlg = vim.o.helplang +vim.go.helplang = vim.o.helplang +vim.go.hlg = vim.go.helplang + +--- When off a buffer is unloaded (including loss of undo information) +--- when it is `abandon`ed. When on a buffer becomes hidden when it is +--- `abandon`ed. A buffer displayed in another window does not become +--- hidden, of course. +--- +--- Commands that move through the buffer list sometimes hide a buffer +--- although the 'hidden' option is off when these three are true: +--- - the buffer is modified +--- - 'autowrite' is off or writing is not possible +--- - the '!' flag was used +--- Also see `windows`. +--- +--- To hide a specific buffer use the 'bufhidden' option. +--- 'hidden' is set for one command with ":hide {command}" `:hide`. +--- +--- @type boolean +vim.o.hidden = true +vim.o.hid = vim.o.hidden +vim.go.hidden = vim.o.hidden +vim.go.hid = vim.go.hidden + +--- A history of ":" commands, and a history of previous search patterns +--- is remembered. This option decides how many entries may be stored in +--- each of these histories (see `cmdline-editing`). +--- The maximum value is 10000. +--- +--- @type integer +vim.o.history = 10000 +vim.o.hi = vim.o.history +vim.go.history = vim.o.history +vim.go.hi = vim.go.history + +--- When there is a previous search pattern, highlight all its matches. +--- The `hl-Search` highlight group determines the highlighting for all +--- matches not under the cursor while the `hl-CurSearch` highlight group +--- (if defined) determines the highlighting for the match under the +--- cursor. If `hl-CurSearch` is not defined, then `hl-Search` is used for +--- both. Note that only the matching text is highlighted, any offsets +--- are not applied. +--- See also: 'incsearch' and `:match`. +--- When you get bored looking at the highlighted matches, you can turn it +--- off with `:nohlsearch`. This does not change the option value, as +--- soon as you use a search command, the highlighting comes back. +--- 'redrawtime' specifies the maximum time spent on finding matches. +--- When the search pattern can match an end-of-line, Vim will try to +--- highlight all of the matched text. However, this depends on where the +--- search starts. This will be the first line in the window or the first +--- line below a closed fold. A match in a previous line which is not +--- drawn may not continue in a newly drawn line. +--- You can specify whether the highlight status is restored on startup +--- with the 'h' flag in 'shada' `shada-h`. +--- +--- @type boolean +vim.o.hlsearch = true +vim.o.hls = vim.o.hlsearch +vim.go.hlsearch = vim.o.hlsearch +vim.go.hls = vim.go.hlsearch + +--- When on, the icon text of the window will be set to the value of +--- 'iconstring' (if it is not empty), or to the name of the file +--- currently being edited. Only the last part of the name is used. +--- Overridden by the 'iconstring' option. +--- Only works if the terminal supports setting window icons. +--- +--- @type boolean +vim.o.icon = false +vim.go.icon = vim.o.icon + +--- When this option is not empty, it will be used for the icon text of +--- the window. This happens only when the 'icon' option is on. +--- Only works if the terminal supports setting window icon text +--- When this option contains printf-style '%' items, they will be +--- expanded according to the rules used for 'statusline'. See +--- 'titlestring' for example settings. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- @type string +vim.o.iconstring = "" +vim.go.iconstring = vim.o.iconstring + +--- Ignore case in search patterns, `cmdline-completion`, when +--- searching in the tags file, and `expr-==`. +--- Also see 'smartcase' and 'tagcase'. +--- Can be overruled by using "\c" or "\C" in the pattern, see +--- `/ignorecase`. +--- +--- @type boolean +vim.o.ignorecase = false +vim.o.ic = vim.o.ignorecase +vim.go.ignorecase = vim.o.ignorecase +vim.go.ic = vim.go.ignorecase + +--- When set the Input Method is always on when starting to edit a command +--- line, unless entering a search pattern (see 'imsearch' for that). +--- Setting this option is useful when your input method allows entering +--- English characters directly, e.g., when it's used to type accented +--- characters with dead keys. +--- +--- @type boolean +vim.o.imcmdline = false +vim.o.imc = vim.o.imcmdline +vim.go.imcmdline = vim.o.imcmdline +vim.go.imc = vim.go.imcmdline + +--- When set the Input Method is never used. This is useful to disable +--- the IM when it doesn't work properly. +--- Currently this option is on by default for SGI/IRIX machines. This +--- may change in later releases. +--- +--- @type boolean +vim.o.imdisable = false +vim.o.imd = vim.o.imdisable +vim.go.imdisable = vim.o.imdisable +vim.go.imd = vim.go.imdisable + +--- Specifies whether :lmap or an Input Method (IM) is to be used in +--- Insert mode. Valid values: +--- 0 :lmap is off and IM is off +--- 1 :lmap is ON and IM is off +--- 2 :lmap is off and IM is ON +--- To always reset the option to zero when leaving Insert mode with <Esc> +--- this can be used: +--- ``` +--- :inoremap <ESC> <ESC>:set iminsert=0<CR> +--- ``` +--- This makes :lmap and IM turn off automatically when leaving Insert +--- mode. +--- Note that this option changes when using CTRL-^ in Insert mode +--- `i_CTRL-^`. +--- The value is set to 1 when setting 'keymap' to a valid keymap name. +--- It is also used for the argument of commands like "r" and "f". +--- +--- @type integer +vim.o.iminsert = 0 +vim.o.imi = vim.o.iminsert +vim.bo.iminsert = vim.o.iminsert +vim.bo.imi = vim.bo.iminsert + +--- Specifies whether :lmap or an Input Method (IM) is to be used when +--- entering a search pattern. Valid values: +--- -1 the value of 'iminsert' is used, makes it look like +--- 'iminsert' is also used when typing a search pattern +--- 0 :lmap is off and IM is off +--- 1 :lmap is ON and IM is off +--- 2 :lmap is off and IM is ON +--- Note that this option changes when using CTRL-^ in Command-line mode +--- `c_CTRL-^`. +--- The value is set to 1 when it is not -1 and setting the 'keymap' +--- option to a valid keymap name. +--- +--- @type integer +vim.o.imsearch = -1 +vim.o.ims = vim.o.imsearch +vim.bo.imsearch = vim.o.imsearch +vim.bo.ims = vim.bo.imsearch + +--- When nonempty, shows the effects of `:substitute`, `:smagic|, +--- |:snomagic` and user commands with the `:command-preview` flag as you +--- type. +--- +--- Possible values: +--- nosplit Shows the effects of a command incrementally in the +--- buffer. +--- split Like "nosplit", but also shows partial off-screen +--- results in a preview window. +--- +--- If the preview for built-in commands is too slow (exceeds +--- 'redrawtime') then 'inccommand' is automatically disabled until +--- `Command-line-mode` is done. +--- +--- @type string +vim.o.inccommand = "nosplit" +vim.o.icm = vim.o.inccommand +vim.go.inccommand = vim.o.inccommand +vim.go.icm = vim.go.inccommand + +--- Pattern to be used to find an include command. It is a search +--- pattern, just like for the "/" command (See `pattern`). This option +--- is used for the commands "[i", "]I", "[d", etc. +--- Normally the 'isfname' option is used to recognize the file name that +--- comes after the matched pattern. But if "\zs" appears in the pattern +--- then the text matched from "\zs" to the end, or until "\ze" if it +--- appears, is used as the file name. Use this to include characters +--- that are not in 'isfname', such as a space. You can then use +--- 'includeexpr' to process the matched text. +--- See `option-backslash` about including spaces and backslashes. +--- +--- @type string +vim.o.include = "" +vim.o.inc = vim.o.include +vim.bo.include = vim.o.include +vim.bo.inc = vim.bo.include +vim.go.include = vim.o.include +vim.go.inc = vim.go.include + +--- Expression to be used to transform the string found with the 'include' +--- option to a file name. Mostly useful to change "." to "/" for Java: +--- ``` +--- :setlocal includeexpr=substitute(v:fname,'\\.','/','g') +--- ``` +--- The "v:fname" variable will be set to the file name that was detected. +--- Note the double backslash: the `:set` command first halves them, then +--- one remains in the value, where "\." matches a dot literally. For +--- simple character replacements `tr()` avoids the need for escaping: +--- ``` +--- :setlocal includeexpr=tr(v:fname,'.','/') +--- ``` +--- +--- Also used for the `gf` command if an unmodified file name can't be +--- found. Allows doing "gf" on the name after an 'include' statement. +--- Also used for `<cfile>`. +--- +--- If the expression starts with s: or `<SID>`, then it is replaced with +--- the script ID (`local-function`). Example: +--- ``` +--- setlocal includeexpr=s:MyIncludeExpr(v:fname) +--- setlocal includeexpr=<SID>SomeIncludeExpr(v:fname) +--- ``` +--- Otherwise, the expression is evaluated in the context of the script +--- where the option was set, thus script-local items are available. +--- +--- The expression will be evaluated in the `sandbox` when set from a +--- modeline, see `sandbox-option`. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- It is not allowed to change text or jump to another window while +--- evaluating 'includeexpr' `textlock`. +--- +--- @type string +vim.o.includeexpr = "" +vim.o.inex = vim.o.includeexpr +vim.bo.includeexpr = vim.o.includeexpr +vim.bo.inex = vim.bo.includeexpr + +--- While typing a search command, show where the pattern, as it was typed +--- so far, matches. The matched string is highlighted. If the pattern +--- is invalid or not found, nothing is shown. The screen will be updated +--- often, this is only useful on fast terminals. +--- Note that the match will be shown, but the cursor will return to its +--- original position when no match is found and when pressing <Esc>. You +--- still need to finish the search command with <Enter> to move the +--- cursor to the match. +--- You can use the CTRL-G and CTRL-T keys to move to the next and +--- previous match. `c_CTRL-G` `c_CTRL-T` +--- Vim only searches for about half a second. With a complicated +--- pattern and/or a lot of text the match may not be found. This is to +--- avoid that Vim hangs while you are typing the pattern. +--- The `hl-IncSearch` highlight group determines the highlighting. +--- When 'hlsearch' is on, all matched strings are highlighted too while +--- typing a search command. See also: 'hlsearch'. +--- If you don't want to turn 'hlsearch' on, but want to highlight all +--- matches while searching, you can turn on and off 'hlsearch' with +--- autocmd. Example: +--- ``` +--- augroup vimrc-incsearch-highlight +--- autocmd! +--- autocmd CmdlineEnter /,\? :set hlsearch +--- autocmd CmdlineLeave /,\? :set nohlsearch +--- augroup END +--- ``` +--- +--- CTRL-L can be used to add one character from after the current match +--- to the command line. If 'ignorecase' and 'smartcase' are set and the +--- command line has no uppercase characters, the added character is +--- converted to lowercase. +--- CTRL-R CTRL-W can be used to add the word at the end of the current +--- match, excluding the characters that were already typed. +--- +--- @type boolean +vim.o.incsearch = true +vim.o.is = vim.o.incsearch +vim.go.incsearch = vim.o.incsearch +vim.go.is = vim.go.incsearch + +--- Expression which is evaluated to obtain the proper indent for a line. +--- It is used when a new line is created, for the `=` operator and +--- in Insert mode as specified with the 'indentkeys' option. +--- When this option is not empty, it overrules the 'cindent' and +--- 'smartindent' indenting. When 'lisp' is set, this option is +--- is only used when 'lispoptions' contains "expr:1". +--- The expression is evaluated with `v:lnum` set to the line number for +--- which the indent is to be computed. The cursor is also in this line +--- when the expression is evaluated (but it may be moved around). +--- +--- If the expression starts with s: or `<SID>`, then it is replaced with +--- the script ID (`local-function`). Example: +--- ``` +--- set indentexpr=s:MyIndentExpr() +--- set indentexpr=<SID>SomeIndentExpr() +--- ``` +--- Otherwise, the expression is evaluated in the context of the script +--- where the option was set, thus script-local items are available. +--- +--- The expression must return the number of spaces worth of indent. It +--- can return "-1" to keep the current indent (this means 'autoindent' is +--- used for the indent). +--- Functions useful for computing the indent are `indent()`, `cindent()` +--- and `lispindent()`. +--- The evaluation of the expression must not have side effects! It must +--- not change the text, jump to another window, etc. Afterwards the +--- cursor position is always restored, thus the cursor may be moved. +--- Normally this option would be set to call a function: +--- ``` +--- :set indentexpr=GetMyIndent() +--- ``` +--- Error messages will be suppressed, unless the 'debug' option contains +--- "msg". +--- See `indent-expression`. +--- +--- The expression will be evaluated in the `sandbox` when set from a +--- modeline, see `sandbox-option`. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- It is not allowed to change text or jump to another window while +--- evaluating 'indentexpr' `textlock`. +--- +--- @type string +vim.o.indentexpr = "" +vim.o.inde = vim.o.indentexpr +vim.bo.indentexpr = vim.o.indentexpr +vim.bo.inde = vim.bo.indentexpr + +--- A list of keys that, when typed in Insert mode, cause reindenting of +--- the current line. Only happens if 'indentexpr' isn't empty. +--- The format is identical to 'cinkeys', see `indentkeys-format`. +--- See `C-indenting` and `indent-expression`. +--- +--- @type string +vim.o.indentkeys = "0{,0},0),0],:,0#,!^F,o,O,e" +vim.o.indk = vim.o.indentkeys +vim.bo.indentkeys = vim.o.indentkeys +vim.bo.indk = vim.bo.indentkeys + +--- When doing keyword completion in insert mode `ins-completion`, and +--- 'ignorecase' is also on, the case of the match is adjusted depending +--- on the typed text. If the typed text contains a lowercase letter +--- where the match has an upper case letter, the completed part is made +--- lowercase. If the typed text has no lowercase letters and the match +--- has a lowercase letter where the typed text has an uppercase letter, +--- and there is a letter before it, the completed part is made uppercase. +--- With 'noinfercase' the match is used as-is. +--- +--- @type boolean +vim.o.infercase = false +vim.o.inf = vim.o.infercase +vim.bo.infercase = vim.o.infercase +vim.bo.inf = vim.bo.infercase + +--- The characters specified by this option are included in file names and +--- path names. Filenames are used for commands like "gf", "[i" and in +--- the tags file. It is also used for "\f" in a `pattern`. +--- Multi-byte characters 256 and above are always included, only the +--- characters up to 255 are specified with this option. +--- For UTF-8 the characters 0xa0 to 0xff are included as well. +--- Think twice before adding white space to this option. Although a +--- space may appear inside a file name, the effect will be that Vim +--- doesn't know where a file name starts or ends when doing completion. +--- It most likely works better without a space in 'isfname'. +--- +--- Note that on systems using a backslash as path separator, Vim tries to +--- do its best to make it work as you would expect. That is a bit +--- tricky, since Vi originally used the backslash to escape special +--- characters. Vim will not remove a backslash in front of a normal file +--- name character on these systems, but it will on Unix and alikes. The +--- '&' and '^' are not included by default, because these are special for +--- cmd.exe. +--- +--- The format of this option is a list of parts, separated with commas. +--- Each part can be a single character number or a range. A range is two +--- character numbers with '-' in between. A character number can be a +--- decimal number between 0 and 255 or the ASCII character itself (does +--- not work for digits). Example: +--- "_,-,128-140,#-43" (include '_' and '-' and the range +--- 128 to 140 and '#' to 43) +--- If a part starts with '^', the following character number or range +--- will be excluded from the option. The option is interpreted from left +--- to right. Put the excluded character after the range where it is +--- included. To include '^' itself use it as the last character of the +--- option or the end of a range. Example: +--- "^a-z,#,^" (exclude 'a' to 'z', include '#' and '^') +--- If the character is '@', all characters where isalpha() returns TRUE +--- are included. Normally these are the characters a to z and A to Z, +--- plus accented characters. To include '@' itself use "@-@". Examples: +--- "@,^a-z" All alphabetic characters, excluding lower +--- case ASCII letters. +--- "a-z,A-Z,@-@" All letters plus the '@' character. +--- A comma can be included by using it where a character number is +--- expected. Example: +--- "48-57,,,_" Digits, comma and underscore. +--- A comma can be excluded by prepending a '^'. Example: +--- " -~,^,,9" All characters from space to '~', excluding +--- comma, plus <Tab>. +--- See `option-backslash` about including spaces and backslashes. +--- +--- @type string +vim.o.isfname = "@,48-57,/,.,-,_,+,,,#,$,%,~,=" +vim.o.isf = vim.o.isfname +vim.go.isfname = vim.o.isfname +vim.go.isf = vim.go.isfname + +--- The characters given by this option are included in identifiers. +--- Identifiers are used in recognizing environment variables and after a +--- match of the 'define' option. It is also used for "\i" in a +--- `pattern`. See 'isfname' for a description of the format of this +--- option. For '@' only characters up to 255 are used. +--- Careful: If you change this option, it might break expanding +--- environment variables. E.g., when '/' is included and Vim tries to +--- expand "$HOME/.local/state/nvim/shada/main.shada". Maybe you should +--- change 'iskeyword' instead. +--- +--- @type string +vim.o.isident = "@,48-57,_,192-255" +vim.o.isi = vim.o.isident +vim.go.isident = vim.o.isident +vim.go.isi = vim.go.isident + +--- Keywords are used in searching and recognizing with many commands: +--- "w", "*", "[i", etc. It is also used for "\k" in a `pattern`. See +--- 'isfname' for a description of the format of this option. For '@' +--- characters above 255 check the "word" character class (any character +--- that is not white space or punctuation). +--- For C programs you could use "a-z,A-Z,48-57,_,.,-,>". +--- For a help file it is set to all non-blank printable characters except +--- "*", '"' and '|' (so that CTRL-] on a command finds the help for that +--- command). +--- When the 'lisp' option is on the '-' character is always included. +--- This option also influences syntax highlighting, unless the syntax +--- uses `:syn-iskeyword`. +--- +--- @type string +vim.o.iskeyword = "@,48-57,_,192-255" +vim.o.isk = vim.o.iskeyword +vim.bo.iskeyword = vim.o.iskeyword +vim.bo.isk = vim.bo.iskeyword + +--- The characters given by this option are displayed directly on the +--- screen. It is also used for "\p" in a `pattern`. The characters from +--- space (ASCII 32) to '~' (ASCII 126) are always displayed directly, +--- even when they are not included in 'isprint' or excluded. See +--- 'isfname' for a description of the format of this option. +--- +--- Non-printable characters are displayed with two characters: +--- 0 - 31 "^@" - "^_" +--- 32 - 126 always single characters +--- 127 "^?" +--- 128 - 159 "~@" - "~_" +--- 160 - 254 "| " - "|~" +--- 255 "~?" +--- Illegal bytes from 128 to 255 (invalid UTF-8) are +--- displayed as <xx>, with the hexadecimal value of the byte. +--- When 'display' contains "uhex" all unprintable characters are +--- displayed as <xx>. +--- The SpecialKey highlighting will be used for unprintable characters. +--- `hl-SpecialKey` +--- +--- Multi-byte characters 256 and above are always included, only the +--- characters up to 255 are specified with this option. When a character +--- is printable but it is not available in the current font, a +--- replacement character will be shown. +--- Unprintable and zero-width Unicode characters are displayed as <xxxx>. +--- There is no option to specify these characters. +--- +--- @type string +vim.o.isprint = "@,161-255" +vim.o.isp = vim.o.isprint +vim.go.isprint = vim.o.isprint +vim.go.isp = vim.go.isprint + +--- Insert two spaces after a '.', '?' and '!' with a join command. +--- Otherwise only one space is inserted. +--- +--- @type boolean +vim.o.joinspaces = false +vim.o.js = vim.o.joinspaces +vim.go.joinspaces = vim.o.joinspaces +vim.go.js = vim.go.joinspaces + +--- List of words that change the behavior of the `jumplist`. +--- stack Make the jumplist behave like the tagstack. +--- Relative location of entries in the jumplist is +--- preserved at the cost of discarding subsequent entries +--- when navigating backwards in the jumplist and then +--- jumping to a location. `jumplist-stack` +--- +--- view When moving through the jumplist, `changelist|, +--- |alternate-file` or using `mark-motions` try to +--- restore the `mark-view` in which the action occurred. +--- +--- @type string +vim.o.jumpoptions = "" +vim.o.jop = vim.o.jumpoptions +vim.go.jumpoptions = vim.o.jumpoptions +vim.go.jop = vim.go.jumpoptions + +--- Name of a keyboard mapping. See `mbyte-keymap`. +--- Setting this option to a valid keymap name has the side effect of +--- setting 'iminsert' to one, so that the keymap becomes effective. +--- 'imsearch' is also set to one, unless it was -1 +--- Only normal file name characters can be used, `/\*?[|<>` are illegal. +--- +--- @type string +vim.o.keymap = "" +vim.o.kmp = vim.o.keymap +vim.bo.keymap = vim.o.keymap +vim.bo.kmp = vim.bo.keymap + +--- List of comma-separated words, which enable special things that keys +--- can do. These values can be used: +--- startsel Using a shifted special key starts selection (either +--- Select mode or Visual mode, depending on "key" being +--- present in 'selectmode'). +--- stopsel Using a not-shifted special key stops selection. +--- Special keys in this context are the cursor keys, <End>, <Home>, +--- <PageUp> and <PageDown>. +--- +--- @type string +vim.o.keymodel = "" +vim.o.km = vim.o.keymodel +vim.go.keymodel = vim.o.keymodel +vim.go.km = vim.go.keymodel + +--- Program to use for the `K` command. Environment variables are +--- expanded `:set_env`. ":help" may be used to access the Vim internal +--- help. (Note that previously setting the global option to the empty +--- value did this, which is now deprecated.) +--- When the first character is ":", the command is invoked as a Vim +--- Ex command prefixed with [count]. +--- When "man" or "man -s" is used, Vim will automatically translate +--- a [count] for the "K" command to a section number. +--- See `option-backslash` about including spaces and backslashes. +--- Example: +--- ``` +--- :set keywordprg=man\ -s +--- :set keywordprg=:Man +--- ``` +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.keywordprg = ":Man" +vim.o.kp = vim.o.keywordprg +vim.bo.keywordprg = vim.o.keywordprg +vim.bo.kp = vim.bo.keywordprg +vim.go.keywordprg = vim.o.keywordprg +vim.go.kp = vim.go.keywordprg + +--- This option allows switching your keyboard into a special language +--- mode. When you are typing text in Insert mode the characters are +--- inserted directly. When in Normal mode the 'langmap' option takes +--- care of translating these special characters to the original meaning +--- of the key. This means you don't have to change the keyboard mode to +--- be able to execute Normal mode commands. +--- This is the opposite of the 'keymap' option, where characters are +--- mapped in Insert mode. +--- Also consider setting 'langremap' to off, to prevent 'langmap' from +--- applying to characters resulting from a mapping. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- Example (for Greek, in UTF-8): *greek* +--- ``` +--- :set langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz +--- ``` +--- Example (exchanges meaning of z and y for commands): +--- ``` +--- :set langmap=zy,yz,ZY,YZ +--- ``` +--- +--- The 'langmap' option is a list of parts, separated with commas. Each +--- part can be in one of two forms: +--- 1. A list of pairs. Each pair is a "from" character immediately +--- followed by the "to" character. Examples: "aA", "aAbBcC". +--- 2. A list of "from" characters, a semi-colon and a list of "to" +--- characters. Example: "abc;ABC" +--- Example: "aA,fgh;FGH,cCdDeE" +--- Special characters need to be preceded with a backslash. These are +--- ";", ',', '"', '|' and backslash itself. +--- +--- This will allow you to activate vim actions without having to switch +--- back and forth between the languages. Your language characters will +--- be understood as normal vim English characters (according to the +--- langmap mappings) in the following cases: +--- o Normal/Visual mode (commands, buffer/register names, user mappings) +--- o Insert/Replace Mode: Register names after CTRL-R +--- o Insert/Replace Mode: Mappings +--- Characters entered in Command-line mode will NOT be affected by +--- this option. Note that this option can be changed at any time +--- allowing to switch between mappings for different languages/encodings. +--- Use a mapping to avoid having to type it each time! +--- +--- @type string +vim.o.langmap = "" +vim.o.lmap = vim.o.langmap +vim.go.langmap = vim.o.langmap +vim.go.lmap = vim.go.langmap + +--- Language to use for menu translation. Tells which file is loaded +--- from the "lang" directory in 'runtimepath': +--- ``` +--- "lang/menu_" .. &langmenu .. ".vim" +--- ``` +--- (without the spaces). For example, to always use the Dutch menus, no +--- matter what $LANG is set to: +--- ``` +--- :set langmenu=nl_NL.ISO_8859-1 +--- ``` +--- When 'langmenu' is empty, `v:lang` is used. +--- Only normal file name characters can be used, `/\*?[|<>` are illegal. +--- If your $LANG is set to a non-English language but you do want to use +--- the English menus: +--- ``` +--- :set langmenu=none +--- ``` +--- This option must be set before loading menus, switching on filetype +--- detection or syntax highlighting. Once the menus are defined setting +--- this option has no effect. But you could do this: +--- ``` +--- :source $VIMRUNTIME/delmenu.vim +--- :set langmenu=de_DE.ISO_8859-1 +--- :source $VIMRUNTIME/menu.vim +--- ``` +--- Warning: This deletes all menus that you defined yourself! +--- +--- @type string +vim.o.langmenu = "" +vim.o.lm = vim.o.langmenu +vim.go.langmenu = vim.o.langmenu +vim.go.lm = vim.go.langmenu + +--- When off, setting 'langmap' does not apply to characters resulting from +--- a mapping. If setting 'langmap' disables some of your mappings, make +--- sure this option is off. +--- +--- @type boolean +vim.o.langremap = false +vim.o.lrm = vim.o.langremap +vim.go.langremap = vim.o.langremap +vim.go.lrm = vim.go.langremap + +--- The value of this option influences when the last window will have a +--- status line: +--- 0: never +--- 1: only if there are at least two windows +--- 2: always +--- 3: always and ONLY the last window +--- The screen looks nicer with a status line if you have several +--- windows, but it takes another screen line. `status-line` +--- +--- @type integer +vim.o.laststatus = 2 +vim.o.ls = vim.o.laststatus +vim.go.laststatus = vim.o.laststatus +vim.go.ls = vim.go.laststatus + +--- When this option is set, the screen will not be redrawn while +--- executing macros, registers and other commands that have not been +--- typed. Also, updating the window title is postponed. To force an +--- update use `:redraw`. +--- This may occasionally cause display errors. It is only meant to be set +--- temporarily when performing an operation where redrawing may cause +--- flickering or cause a slow down. +--- +--- @type boolean +vim.o.lazyredraw = false +vim.o.lz = vim.o.lazyredraw +vim.go.lazyredraw = vim.o.lazyredraw +vim.go.lz = vim.go.lazyredraw + +--- If on, Vim will wrap long lines at a character in 'breakat' rather +--- than at the last character that fits on the screen. Unlike +--- 'wrapmargin' and 'textwidth', this does not insert <EOL>s in the file, +--- it only affects the way the file is displayed, not its contents. +--- If 'breakindent' is set, line is visually indented. Then, the value +--- of 'showbreak' is used to put in front of wrapped lines. This option +--- is not used when the 'wrap' option is off. +--- Note that <Tab> characters after an <EOL> are mostly not displayed +--- with the right amount of white space. +--- +--- @type boolean +vim.o.linebreak = false +vim.o.lbr = vim.o.linebreak +vim.wo.linebreak = vim.o.linebreak +vim.wo.lbr = vim.wo.linebreak + +--- Number of lines of the Vim window. +--- Normally you don't need to set this. It is done automatically by the +--- terminal initialization code. +--- When Vim is running in the GUI or in a resizable window, setting this +--- option will cause the window size to be changed. When you only want +--- to use the size for the GUI, put the command in your `gvimrc` file. +--- Vim limits the number of lines to what fits on the screen. You can +--- use this command to get the tallest window possible: +--- ``` +--- :set lines=999 +--- ``` +--- Minimum value is 2, maximum value is 1000. +--- +--- @type integer +vim.o.lines = 24 +vim.go.lines = vim.o.lines + +--- only in the GUI +--- Number of pixel lines inserted between characters. Useful if the font +--- uses the full character cell height, making lines touch each other. +--- When non-zero there is room for underlining. +--- With some fonts there can be too much room between lines (to have +--- space for ascents and descents). Then it makes sense to set +--- 'linespace' to a negative value. This may cause display problems +--- though! +--- +--- @type integer +vim.o.linespace = 0 +vim.o.lsp = vim.o.linespace +vim.go.linespace = vim.o.linespace +vim.go.lsp = vim.go.linespace + +--- Lisp mode: When <Enter> is typed in insert mode set the indent for +--- the next line to Lisp standards (well, sort of). Also happens with +--- "cc" or "S". 'autoindent' must also be on for this to work. The 'p' +--- flag in 'cpoptions' changes the method of indenting: Vi compatible or +--- better. Also see 'lispwords'. +--- The '-' character is included in keyword characters. Redefines the +--- "=" operator to use this same indentation algorithm rather than +--- calling an external program if 'equalprg' is empty. +--- +--- @type boolean +vim.o.lisp = false +vim.bo.lisp = vim.o.lisp + +--- Comma-separated list of items that influence the Lisp indenting when +--- enabled with the `'lisp'` option. Currently only one item is +--- supported: +--- expr:1 use 'indentexpr' for Lisp indenting when it is set +--- expr:0 do not use 'indentexpr' for Lisp indenting (default) +--- Note that when using 'indentexpr' the `=` operator indents all the +--- lines, otherwise the first line is not indented (Vi-compatible). +--- +--- @type string +vim.o.lispoptions = "" +vim.o.lop = vim.o.lispoptions +vim.bo.lispoptions = vim.o.lispoptions +vim.bo.lop = vim.bo.lispoptions + +--- Comma-separated list of words that influence the Lisp indenting when +--- enabled with the `'lisp'` option. +--- +--- @type string +vim.o.lispwords = "defun,define,defmacro,set!,lambda,if,case,let,flet,let*,letrec,do,do*,define-syntax,let-syntax,letrec-syntax,destructuring-bind,defpackage,defparameter,defstruct,deftype,defvar,do-all-symbols,do-external-symbols,do-symbols,dolist,dotimes,ecase,etypecase,eval-when,labels,macrolet,multiple-value-bind,multiple-value-call,multiple-value-prog1,multiple-value-setq,prog1,progv,typecase,unless,unwind-protect,when,with-input-from-string,with-open-file,with-open-stream,with-output-to-string,with-package-iterator,define-condition,handler-bind,handler-case,restart-bind,restart-case,with-simple-restart,store-value,use-value,muffle-warning,abort,continue,with-slots,with-slots*,with-accessors,with-accessors*,defclass,defmethod,print-unreadable-object" +vim.o.lw = vim.o.lispwords +vim.bo.lispwords = vim.o.lispwords +vim.bo.lw = vim.bo.lispwords +vim.go.lispwords = vim.o.lispwords +vim.go.lw = vim.go.lispwords + +--- List mode: By default, show tabs as ">", trailing spaces as "-", and +--- non-breakable space characters as "+". Useful to see the difference +--- between tabs and spaces and for trailing blanks. Further changed by +--- the 'listchars' option. +--- +--- The cursor is displayed at the start of the space a Tab character +--- occupies, not at the end as usual in Normal mode. To get this cursor +--- position while displaying Tabs with spaces, use: +--- ``` +--- :set list lcs=tab:\ \ +--- ``` +--- +--- Note that list mode will also affect formatting (set with 'textwidth' +--- or 'wrapmargin') when 'cpoptions' includes 'L'. See 'listchars' for +--- changing the way tabs are displayed. +--- +--- @type boolean +vim.o.list = false +vim.wo.list = vim.o.list + +--- Strings to use in 'list' mode and for the `:list` command. It is a +--- comma-separated list of string settings. +--- +--- *lcs-eol* +--- eol:c Character to show at the end of each line. When +--- omitted, there is no extra character at the end of the +--- line. +--- *lcs-tab* +--- tab:xy[z] Two or three characters to be used to show a tab. +--- The third character is optional. +--- +--- tab:xy The 'x' is always used, then 'y' as many times as will +--- fit. Thus "tab:>-" displays: +--- ``` +--- +--- ``` +--- >- +--- >-- +--- etc. +--- ``` +--- +--- tab:xyz The 'z' is always used, then 'x' is prepended, and +--- then 'y' is used as many times as will fit. Thus +--- "tab:<->" displays: +--- ``` +--- +--- ``` +--- <> +--- <-> +--- <--> +--- etc. +--- ``` +--- +--- When "tab:" is omitted, a tab is shown as ^I. +--- *lcs-space* +--- space:c Character to show for a space. When omitted, spaces +--- are left blank. +--- *lcs-multispace* +--- multispace:c... +--- One or more characters to use cyclically to show for +--- multiple consecutive spaces. Overrides the "space" +--- setting, except for single spaces. When omitted, the +--- "space" setting is used. For example, +--- `:set listchars=multispace:---+` shows ten consecutive +--- spaces as: +--- ``` +--- ---+---+-- +--- ``` +--- +--- *lcs-lead* +--- lead:c Character to show for leading spaces. When omitted, +--- leading spaces are blank. Overrides the "space" and +--- "multispace" settings for leading spaces. You can +--- combine it with "tab:", for example: +--- ``` +--- :set listchars+=tab:>-,lead:. +--- ``` +--- +--- *lcs-leadmultispace* +--- leadmultispace:c... +--- Like the `lcs-multispace` value, but for leading +--- spaces only. Also overrides `lcs-lead` for leading +--- multiple spaces. +--- `:set listchars=leadmultispace:---+` shows ten +--- consecutive leading spaces as: +--- ``` +--- ---+---+--XXX +--- ``` +--- +--- Where "XXX" denotes the first non-blank characters in +--- the line. +--- *lcs-trail* +--- trail:c Character to show for trailing spaces. When omitted, +--- trailing spaces are blank. Overrides the "space" and +--- "multispace" settings for trailing spaces. +--- *lcs-extends* +--- extends:c Character to show in the last column, when 'wrap' is +--- off and the line continues beyond the right of the +--- screen. +--- *lcs-precedes* +--- precedes:c Character to show in the first visible column of the +--- physical line, when there is text preceding the +--- character visible in the first column. +--- *lcs-conceal* +--- conceal:c Character to show in place of concealed text, when +--- 'conceallevel' is set to 1. A space when omitted. +--- *lcs-nbsp* +--- nbsp:c Character to show for a non-breakable space character +--- (0xA0 (160 decimal) and U+202F). Left blank when +--- omitted. +--- +--- The characters ':' and ',' should not be used. UTF-8 characters can +--- be used. All characters must be single width. +--- +--- Each character can be specified as hex: +--- ``` +--- set listchars=eol:\\x24 +--- set listchars=eol:\\u21b5 +--- set listchars=eol:\\U000021b5 +--- ``` +--- Note that a double backslash is used. The number of hex characters +--- must be exactly 2 for \\x, 4 for \\u and 8 for \\U. +--- +--- Examples: +--- ``` +--- :set lcs=tab:>-,trail:- +--- :set lcs=tab:>-,eol:<,nbsp:% +--- :set lcs=extends:>,precedes:< +--- ``` +--- `hl-NonText` highlighting will be used for "eol", "extends" and +--- "precedes". `hl-Whitespace` for "nbsp", "space", "tab", "multispace", +--- "lead" and "trail". +--- +--- @type string +vim.o.listchars = "tab:> ,trail:-,nbsp:+" +vim.o.lcs = vim.o.listchars +vim.wo.listchars = vim.o.listchars +vim.wo.lcs = vim.wo.listchars +vim.go.listchars = vim.o.listchars +vim.go.lcs = vim.go.listchars + +--- When on the plugin scripts are loaded when starting up `load-plugins`. +--- This option can be reset in your `vimrc` file to disable the loading +--- of plugins. +--- Note that using the "-u NONE" and "--noplugin" command line arguments +--- reset this option. `-u` `--noplugin` +--- +--- @type boolean +vim.o.loadplugins = true +vim.o.lpl = vim.o.loadplugins +vim.go.loadplugins = vim.o.loadplugins +vim.go.lpl = vim.go.loadplugins + +--- Changes the special characters that can be used in search patterns. +--- See `pattern`. +--- WARNING: Switching this option off most likely breaks plugins! That +--- is because many patterns assume it's on and will fail when it's off. +--- Only switch it off when working with old Vi scripts. In any other +--- situation write patterns that work when 'magic' is on. Include "\M" +--- when you want to `/\M`. +--- +--- @type boolean +vim.o.magic = true +vim.go.magic = vim.o.magic + +--- Name of the errorfile for the `:make` command (see `:make_makeprg`) +--- and the `:grep` command. +--- When it is empty, an internally generated temp file will be used. +--- When "##" is included, it is replaced by a number to make the name +--- unique. This makes sure that the ":make" command doesn't overwrite an +--- existing file. +--- NOT used for the ":cf" command. See 'errorfile' for that. +--- Environment variables are expanded `:set_env`. +--- See `option-backslash` about including spaces and backslashes. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.makeef = "" +vim.o.mef = vim.o.makeef +vim.go.makeef = vim.o.makeef +vim.go.mef = vim.go.makeef + +--- Encoding used for reading the output of external commands. When empty, +--- encoding is not converted. +--- This is used for `:make`, `:lmake`, `:grep`, `:lgrep`, `:grepadd`, +--- `:lgrepadd`, `:cfile`, `:cgetfile`, `:caddfile`, `:lfile`, `:lgetfile`, +--- and `:laddfile`. +--- +--- This would be mostly useful when you use MS-Windows. If iconv is +--- enabled, setting 'makeencoding' to "char" has the same effect as +--- setting to the system locale encoding. Example: +--- ``` +--- :set makeencoding=char " system locale is used +--- ``` +--- +--- +--- @type string +vim.o.makeencoding = "" +vim.o.menc = vim.o.makeencoding +vim.bo.makeencoding = vim.o.makeencoding +vim.bo.menc = vim.bo.makeencoding +vim.go.makeencoding = vim.o.makeencoding +vim.go.menc = vim.go.makeencoding + +--- Program to use for the ":make" command. See `:make_makeprg`. +--- This option may contain '%' and '#' characters (see `:_%` and `:_#`), +--- which are expanded to the current and alternate file name. Use `::S` +--- to escape file names in case they contain special characters. +--- Environment variables are expanded `:set_env`. See `option-backslash` +--- about including spaces and backslashes. +--- Note that a '|' must be escaped twice: once for ":set" and once for +--- the interpretation of a command. When you use a filter called +--- "myfilter" do it like this: +--- ``` +--- :set makeprg=gmake\ \\\|\ myfilter +--- ``` +--- The placeholder "$*" can be given (even multiple times) to specify +--- where the arguments will be included, for example: +--- ``` +--- :set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*} +--- ``` +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.makeprg = "make" +vim.o.mp = vim.o.makeprg +vim.bo.makeprg = vim.o.makeprg +vim.bo.mp = vim.bo.makeprg +vim.go.makeprg = vim.o.makeprg +vim.go.mp = vim.go.makeprg + +--- Characters that form pairs. The `%` command jumps from one to the +--- other. +--- Only character pairs are allowed that are different, thus you cannot +--- jump between two double quotes. +--- The characters must be separated by a colon. +--- The pairs must be separated by a comma. Example for including '<' and +--- '>' (for HTML): +--- ``` +--- :set mps+=<:> +--- ``` +--- A more exotic example, to jump between the '=' and ';' in an +--- assignment, useful for languages like C and Java: +--- ``` +--- :au FileType c,cpp,java set mps+==:; +--- ``` +--- For a more advanced way of using "%", see the matchit.vim plugin in +--- the $VIMRUNTIME/plugin directory. `add-local-help` +--- +--- @type string +vim.o.matchpairs = "(:),{:},[:]" +vim.o.mps = vim.o.matchpairs +vim.bo.matchpairs = vim.o.matchpairs +vim.bo.mps = vim.bo.matchpairs + +--- Tenths of a second to show the matching paren, when 'showmatch' is +--- set. Note that this is not in milliseconds, like other options that +--- set a time. This is to be compatible with Nvi. +--- +--- @type integer +vim.o.matchtime = 5 +vim.o.mat = vim.o.matchtime +vim.go.matchtime = vim.o.matchtime +vim.go.mat = vim.go.matchtime + +--- Maximum depth of function calls for user functions. This normally +--- catches endless recursion. When using a recursive function with +--- more depth, set 'maxfuncdepth' to a bigger number. But this will use +--- more memory, there is the danger of failing when memory is exhausted. +--- Increasing this limit above 200 also changes the maximum for Ex +--- command recursion, see `E169`. +--- See also `:function`. +--- +--- @type integer +vim.o.maxfuncdepth = 100 +vim.o.mfd = vim.o.maxfuncdepth +vim.go.maxfuncdepth = vim.o.maxfuncdepth +vim.go.mfd = vim.go.maxfuncdepth + +--- Maximum number of times a mapping is done without resulting in a +--- character to be used. This normally catches endless mappings, like +--- ":map x y" with ":map y x". It still does not catch ":map g wg", +--- because the 'w' is used before the next mapping is done. See also +--- `key-mapping`. +--- +--- @type integer +vim.o.maxmapdepth = 1000 +vim.o.mmd = vim.o.maxmapdepth +vim.go.maxmapdepth = vim.o.maxmapdepth +vim.go.mmd = vim.go.maxmapdepth + +--- Maximum amount of memory (in Kbyte) to use for pattern matching. +--- The maximum value is about 2000000. Use this to work without a limit. +--- *E363* +--- When Vim runs into the limit it gives an error message and mostly +--- behaves like CTRL-C was typed. +--- Running into the limit often means that the pattern is very +--- inefficient or too complex. This may already happen with the pattern +--- "\(.\)*" on a very long line. ".*" works much better. +--- Might also happen on redraw, when syntax rules try to match a complex +--- text structure. +--- Vim may run out of memory before hitting the 'maxmempattern' limit, in +--- which case you get an "Out of memory" error instead. +--- +--- @type integer +vim.o.maxmempattern = 1000 +vim.o.mmp = vim.o.maxmempattern +vim.go.maxmempattern = vim.o.maxmempattern +vim.go.mmp = vim.go.maxmempattern + +--- Maximum number of items to use in a menu. Used for menus that are +--- generated from a list of items, e.g., the Buffers menu. Changing this +--- option has no direct effect, the menu must be refreshed first. +--- +--- @type integer +vim.o.menuitems = 25 +vim.o.mis = vim.o.menuitems +vim.go.menuitems = vim.o.menuitems +vim.go.mis = vim.go.menuitems + +--- Parameters for `:mkspell`. This tunes when to start compressing the +--- word tree. Compression can be slow when there are many words, but +--- it's needed to avoid running out of memory. The amount of memory used +--- per word depends very much on how similar the words are, that's why +--- this tuning is complicated. +--- +--- There are three numbers, separated by commas: +--- ``` +--- {start},{inc},{added} +--- ``` +--- +--- For most languages the uncompressed word tree fits in memory. {start} +--- gives the amount of memory in Kbyte that can be used before any +--- compression is done. It should be a bit smaller than the amount of +--- memory that is available to Vim. +--- +--- When going over the {start} limit the {inc} number specifies the +--- amount of memory in Kbyte that can be allocated before another +--- compression is done. A low number means compression is done after +--- less words are added, which is slow. A high number means more memory +--- will be allocated. +--- +--- After doing compression, {added} times 1024 words can be added before +--- the {inc} limit is ignored and compression is done when any extra +--- amount of memory is needed. A low number means there is a smaller +--- chance of hitting the {inc} limit, less memory is used but it's +--- slower. +--- +--- The languages for which these numbers are important are Italian and +--- Hungarian. The default works for when you have about 512 Mbyte. If +--- you have 1 Gbyte you could use: +--- ``` +--- :set mkspellmem=900000,3000,800 +--- ``` +--- If you have less than 512 Mbyte `:mkspell` may fail for some +--- languages, no matter what you set 'mkspellmem' to. +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.mkspellmem = "460000,2000,500" +vim.o.msm = vim.o.mkspellmem +vim.go.mkspellmem = vim.o.mkspellmem +vim.go.msm = vim.go.mkspellmem + +--- If 'modeline' is on 'modelines' gives the number of lines that is +--- checked for set commands. If 'modeline' is off or 'modelines' is zero +--- no lines are checked. See `modeline`. +--- +--- @type boolean +vim.o.modeline = true +vim.o.ml = vim.o.modeline +vim.bo.modeline = vim.o.modeline +vim.bo.ml = vim.bo.modeline + +--- When on allow some options that are an expression to be set in the +--- modeline. Check the option for whether it is affected by +--- 'modelineexpr'. Also see `modeline`. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type boolean +vim.o.modelineexpr = false +vim.o.mle = vim.o.modelineexpr +vim.go.modelineexpr = vim.o.modelineexpr +vim.go.mle = vim.go.modelineexpr + +--- If 'modeline' is on 'modelines' gives the number of lines that is +--- checked for set commands. If 'modeline' is off or 'modelines' is zero +--- no lines are checked. See `modeline`. +--- +--- +--- @type integer +vim.o.modelines = 5 +vim.o.mls = vim.o.modelines +vim.go.modelines = vim.o.modelines +vim.go.mls = vim.go.modelines + +--- When off the buffer contents cannot be changed. The 'fileformat' and +--- 'fileencoding' options also can't be changed. +--- Can be reset on startup with the `-M` command line argument. +--- +--- @type boolean +vim.o.modifiable = true +vim.o.ma = vim.o.modifiable +vim.bo.modifiable = vim.o.modifiable +vim.bo.ma = vim.bo.modifiable + +--- When on, the buffer is considered to be modified. This option is set +--- when: +--- 1. A change was made to the text since it was last written. Using the +--- `undo` command to go back to the original text will reset the +--- option. But undoing changes that were made before writing the +--- buffer will set the option again, since the text is different from +--- when it was written. +--- 2. 'fileformat' or 'fileencoding' is different from its original +--- value. The original value is set when the buffer is read or +--- written. A ":set nomodified" command also resets the original +--- values to the current values and the 'modified' option will be +--- reset. +--- Similarly for 'eol' and 'bomb'. +--- This option is not set when a change is made to the buffer as the +--- result of a BufNewFile, BufRead/BufReadPost, BufWritePost, +--- FileAppendPost or VimLeave autocommand event. See `gzip-example` for +--- an explanation. +--- When 'buftype' is "nowrite" or "nofile" this option may be set, but +--- will be ignored. +--- Note that the text may actually be the same, e.g. 'modified' is set +--- when using "rA" on an "A". +--- +--- @type boolean +vim.o.modified = false +vim.o.mod = vim.o.modified +vim.bo.modified = vim.o.modified +vim.bo.mod = vim.bo.modified + +--- When on, listings pause when the whole screen is filled. You will get +--- the `more-prompt`. When this option is off there are no pauses, the +--- listing continues until finished. +--- +--- @type boolean +vim.o.more = true +vim.go.more = vim.o.more + +--- Enables mouse support. For example, to enable the mouse in Normal mode +--- and Visual mode: +--- ``` +--- :set mouse=nv +--- ``` +--- +--- To temporarily disable mouse support, hold the shift key while using +--- the mouse. +--- +--- Mouse support can be enabled for different modes: +--- n Normal mode +--- v Visual mode +--- i Insert mode +--- c Command-line mode +--- h all previous modes when editing a help file +--- a all previous modes +--- r for `hit-enter` and `more-prompt` prompt +--- +--- Left-click anywhere in a text buffer to place the cursor there. This +--- works with operators too, e.g. type `d` then left-click to delete text +--- from the current cursor position to the position where you clicked. +--- +--- Drag the `status-line` or vertical separator of a window to resize it. +--- +--- If enabled for "v" (Visual mode) then double-click selects word-wise, +--- triple-click makes it line-wise, and quadruple-click makes it +--- rectangular block-wise. +--- +--- For scrolling with a mouse wheel see `scroll-mouse-wheel`. +--- +--- Note: When enabling the mouse in a terminal, copy/paste will use the +--- "* register if possible. See also 'clipboard'. +--- +--- Related options: +--- 'mousefocus' window focus follows mouse pointer +--- 'mousemodel' what mouse button does which action +--- 'mousehide' hide mouse pointer while typing text +--- 'selectmode' whether to start Select mode or Visual mode +--- +--- @type string +vim.o.mouse = "nvi" +vim.go.mouse = vim.o.mouse + +--- The window that the mouse pointer is on is automatically activated. +--- When changing the window layout or window focus in another way, the +--- mouse pointer is moved to the window with keyboard focus. Off is the +--- default because it makes using the pull down menus a little goofy, as +--- a pointer transit may activate a window unintentionally. +--- +--- @type boolean +vim.o.mousefocus = false +vim.o.mousef = vim.o.mousefocus +vim.go.mousefocus = vim.o.mousefocus +vim.go.mousef = vim.go.mousefocus + +--- only in the GUI +--- When on, the mouse pointer is hidden when characters are typed. +--- The mouse pointer is restored when the mouse is moved. +--- +--- @type boolean +vim.o.mousehide = true +vim.o.mh = vim.o.mousehide +vim.go.mousehide = vim.o.mousehide +vim.go.mh = vim.go.mousehide + +--- Sets the model to use for the mouse. The name mostly specifies what +--- the right mouse button is used for: +--- extend Right mouse button extends a selection. This works +--- like in an xterm. +--- popup Right mouse button pops up a menu. The shifted left +--- mouse button extends a selection. This works like +--- with Microsoft Windows. +--- popup_setpos Like "popup", but the cursor will be moved to the +--- position where the mouse was clicked, and thus the +--- selected operation will act upon the clicked object. +--- If clicking inside a selection, that selection will +--- be acted upon, i.e. no cursor move. This implies of +--- course, that right clicking outside a selection will +--- end Visual mode. +--- Overview of what button does what for each model: +--- mouse extend popup(_setpos) ~ +--- left click place cursor place cursor +--- left drag start selection start selection +--- shift-left search word extend selection +--- right click extend selection popup menu (place cursor) +--- right drag extend selection - +--- middle click paste paste +--- +--- In the "popup" model the right mouse button produces a pop-up menu. +--- Nvim creates a default `popup-menu` but you can redefine it. +--- +--- Note that you can further refine the meaning of buttons with mappings. +--- See `mouse-overview`. But mappings are NOT used for modeless selection. +--- +--- Example: +--- ``` +--- :map <S-LeftMouse> <RightMouse> +--- :map <S-LeftDrag> <RightDrag> +--- :map <S-LeftRelease> <RightRelease> +--- :map <2-S-LeftMouse> <2-RightMouse> +--- :map <2-S-LeftDrag> <2-RightDrag> +--- :map <2-S-LeftRelease> <2-RightRelease> +--- :map <3-S-LeftMouse> <3-RightMouse> +--- :map <3-S-LeftDrag> <3-RightDrag> +--- :map <3-S-LeftRelease> <3-RightRelease> +--- :map <4-S-LeftMouse> <4-RightMouse> +--- :map <4-S-LeftDrag> <4-RightDrag> +--- :map <4-S-LeftRelease> <4-RightRelease> +--- ``` +--- +--- Mouse commands requiring the CTRL modifier can be simulated by typing +--- the "g" key before using the mouse: +--- "g<LeftMouse>" is "<C-LeftMouse> (jump to tag under mouse click) +--- "g<RightMouse>" is "<C-RightMouse> ("CTRL-T") +--- +--- @type string +vim.o.mousemodel = "popup_setpos" +vim.o.mousem = vim.o.mousemodel +vim.go.mousemodel = vim.o.mousemodel +vim.go.mousem = vim.go.mousemodel + +--- When on, mouse move events are delivered to the input queue and are +--- available for mapping. The default, off, avoids the mouse movement +--- overhead except when needed. +--- Warning: Setting this option can make pending mappings to be aborted +--- when the mouse is moved. +--- +--- @type boolean +vim.o.mousemoveevent = false +vim.o.mousemev = vim.o.mousemoveevent +vim.go.mousemoveevent = vim.o.mousemoveevent +vim.go.mousemev = vim.go.mousemoveevent + +--- This option controls the number of lines / columns to scroll by when +--- scrolling with a mouse wheel (`scroll-mouse-wheel`). The option is +--- a comma-separated list. Each part consists of a direction and a count +--- as follows: +--- direction:count,direction:count +--- Direction is one of either "hor" or "ver". "hor" controls horizontal +--- scrolling and "ver" controls vertical scrolling. Count sets the amount +--- to scroll by for the given direction, it should be a non negative +--- integer. Each direction should be set at most once. If a direction +--- is omitted, a default value is used (6 for horizontal scrolling and 3 +--- for vertical scrolling). You can disable mouse scrolling by using +--- a count of 0. +--- +--- Example: +--- ``` +--- :set mousescroll=ver:5,hor:2 +--- ``` +--- Will make Nvim scroll 5 lines at a time when scrolling vertically, and +--- scroll 2 columns at a time when scrolling horizontally. +--- +--- @type string +vim.o.mousescroll = "ver:3,hor:6" +vim.go.mousescroll = vim.o.mousescroll + +--- This option tells Vim what the mouse pointer should look like in +--- different modes. The option is a comma-separated list of parts, much +--- like used for 'guicursor'. Each part consist of a mode/location-list +--- and an argument-list: +--- mode-list:shape,mode-list:shape,.. +--- The mode-list is a dash separated list of these modes/locations: +--- In a normal window: ~ +--- n Normal mode +--- v Visual mode +--- ve Visual mode with 'selection' "exclusive" (same as 'v', +--- if not specified) +--- o Operator-pending mode +--- i Insert mode +--- r Replace mode +--- +--- Others: ~ +--- c appending to the command-line +--- ci inserting in the command-line +--- cr replacing in the command-line +--- m at the 'Hit ENTER' or 'More' prompts +--- ml idem, but cursor in the last line +--- e any mode, pointer below last window +--- s any mode, pointer on a status line +--- sd any mode, while dragging a status line +--- vs any mode, pointer on a vertical separator line +--- vd any mode, while dragging a vertical separator line +--- a everywhere +--- +--- The shape is one of the following: +--- avail name looks like ~ +--- w x arrow Normal mouse pointer +--- w x blank no pointer at all (use with care!) +--- w x beam I-beam +--- w x updown up-down sizing arrows +--- w x leftright left-right sizing arrows +--- w x busy The system's usual busy pointer +--- w x no The system's usual "no input" pointer +--- x udsizing indicates up-down resizing +--- x lrsizing indicates left-right resizing +--- x crosshair like a big thin + +--- x hand1 black hand +--- x hand2 white hand +--- x pencil what you write with +--- x question big ? +--- x rightup-arrow arrow pointing right-up +--- w x up-arrow arrow pointing up +--- x <number> any X11 pointer number (see X11/cursorfont.h) +--- +--- The "avail" column contains a 'w' if the shape is available for Win32, +--- x for X11. +--- Any modes not specified or shapes not available use the normal mouse +--- pointer. +--- +--- Example: +--- ``` +--- :set mouseshape=s:udsizing,m:no +--- ``` +--- will make the mouse turn to a sizing arrow over the status lines and +--- indicate no input when the hit-enter prompt is displayed (since +--- clicking the mouse has no effect in this state.) +--- +--- @type string +vim.o.mouseshape = "" +vim.o.mouses = vim.o.mouseshape +vim.go.mouseshape = vim.o.mouseshape +vim.go.mouses = vim.go.mouseshape + +--- Defines the maximum time in msec between two mouse clicks for the +--- second click to be recognized as a multi click. +--- +--- @type integer +vim.o.mousetime = 500 +vim.o.mouset = vim.o.mousetime +vim.go.mousetime = vim.o.mousetime +vim.go.mouset = vim.go.mousetime + +--- This defines what bases Vim will consider for numbers when using the +--- CTRL-A and CTRL-X commands for adding to and subtracting from a number +--- respectively; see `CTRL-A` for more info on these commands. +--- alpha If included, single alphabetical characters will be +--- incremented or decremented. This is useful for a list with a +--- letter index a), b), etc. *octal-nrformats* +--- octal If included, numbers that start with a zero will be considered +--- to be octal. Example: Using CTRL-A on "007" results in "010". +--- hex If included, numbers starting with "0x" or "0X" will be +--- considered to be hexadecimal. Example: Using CTRL-X on +--- "0x100" results in "0x0ff". +--- bin If included, numbers starting with "0b" or "0B" will be +--- considered to be binary. Example: Using CTRL-X on +--- "0b1000" subtracts one, resulting in "0b0111". +--- unsigned If included, numbers are recognized as unsigned. Thus a +--- leading dash or negative sign won't be considered as part of +--- the number. Examples: +--- Using CTRL-X on "2020" in "9-2020" results in "9-2019" +--- (without "unsigned" it would become "9-2021"). +--- Using CTRL-A on "2020" in "9-2020" results in "9-2021" +--- (without "unsigned" it would become "9-2019"). +--- Using CTRL-X on "0" or CTRL-A on "18446744073709551615" +--- (2^64 - 1) has no effect, overflow is prevented. +--- Numbers which simply begin with a digit in the range 1-9 are always +--- considered decimal. This also happens for numbers that are not +--- recognized as octal or hex. +--- +--- @type string +vim.o.nrformats = "bin,hex" +vim.o.nf = vim.o.nrformats +vim.bo.nrformats = vim.o.nrformats +vim.bo.nf = vim.bo.nrformats + +--- Print the line number in front of each line. When the 'n' option is +--- excluded from 'cpoptions' a wrapped line will not use the column of +--- line numbers. +--- Use the 'numberwidth' option to adjust the room for the line number. +--- When a long, wrapped line doesn't start with the first character, '-' +--- characters are put before the number. +--- For highlighting see `hl-LineNr`, `hl-CursorLineNr`, and the +--- `:sign-define` "numhl" argument. +--- *number_relativenumber* +--- The 'relativenumber' option changes the displayed number to be +--- relative to the cursor. Together with 'number' there are these +--- four combinations (cursor in line 3): +--- +--- 'nonu' 'nu' 'nonu' 'nu' +--- 'nornu' 'nornu' 'rnu' 'rnu' +--- ``` +--- |apple | 1 apple | 2 apple | 2 apple +--- |pear | 2 pear | 1 pear | 1 pear +--- |nobody | 3 nobody | 0 nobody |3 nobody +--- |there | 4 there | 1 there | 1 there +--- ``` +--- +--- +--- @type boolean +vim.o.number = false +vim.o.nu = vim.o.number +vim.wo.number = vim.o.number +vim.wo.nu = vim.wo.number + +--- Minimal number of columns to use for the line number. Only relevant +--- when the 'number' or 'relativenumber' option is set or printing lines +--- with a line number. Since one space is always between the number and +--- the text, there is one less character for the number itself. +--- The value is the minimum width. A bigger width is used when needed to +--- fit the highest line number in the buffer respectively the number of +--- rows in the window, depending on whether 'number' or 'relativenumber' +--- is set. Thus with the Vim default of 4 there is room for a line number +--- up to 999. When the buffer has 1000 lines five columns will be used. +--- The minimum value is 1, the maximum value is 20. +--- +--- @type integer +vim.o.numberwidth = 4 +vim.o.nuw = vim.o.numberwidth +vim.wo.numberwidth = vim.o.numberwidth +vim.wo.nuw = vim.wo.numberwidth + +--- This option specifies a function to be used for Insert mode omni +--- completion with CTRL-X CTRL-O. `i_CTRL-X_CTRL-O` +--- See `complete-functions` for an explanation of how the function is +--- invoked and what it should return. The value can be the name of a +--- function, a `lambda` or a `Funcref`. See `option-value-function` for +--- more information. +--- This option is usually set by a filetype plugin: +--- `:filetype-plugin-on` +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.omnifunc = "" +vim.o.ofu = vim.o.omnifunc +vim.bo.omnifunc = vim.o.omnifunc +vim.bo.ofu = vim.bo.omnifunc + +--- only for Windows +--- Enable reading and writing from devices. This may get Vim stuck on a +--- device that can be opened but doesn't actually do the I/O. Therefore +--- it is off by default. +--- Note that on Windows editing "aux.h", "lpt1.txt" and the like also +--- result in editing a device. +--- +--- @type boolean +vim.o.opendevice = false +vim.o.odev = vim.o.opendevice +vim.go.opendevice = vim.o.opendevice +vim.go.odev = vim.go.opendevice + +--- This option specifies a function to be called by the `g@` operator. +--- See `:map-operator` for more info and an example. The value can be +--- the name of a function, a `lambda` or a `Funcref`. See +--- `option-value-function` for more information. +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.operatorfunc = "" +vim.o.opfunc = vim.o.operatorfunc +vim.go.operatorfunc = vim.o.operatorfunc +vim.go.opfunc = vim.go.operatorfunc + +--- Directories used to find packages. +--- See `packages` and `packages-runtimepath`. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.packpath = "..." +vim.o.pp = vim.o.packpath +vim.go.packpath = vim.o.packpath +vim.go.pp = vim.go.packpath + +--- Specifies the nroff macros that separate paragraphs. These are pairs +--- of two letters (see `object-motions`). +--- +--- @type string +vim.o.paragraphs = "IPLPPPQPP TPHPLIPpLpItpplpipbp" +vim.o.para = vim.o.paragraphs +vim.go.paragraphs = vim.o.paragraphs +vim.go.para = vim.go.paragraphs + +--- Expression which is evaluated to apply a patch to a file and generate +--- the resulting new version of the file. See `diff-patchexpr`. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.patchexpr = "" +vim.o.pex = vim.o.patchexpr +vim.go.patchexpr = vim.o.patchexpr +vim.go.pex = vim.go.patchexpr + +--- When non-empty the oldest version of a file is kept. This can be used +--- to keep the original version of a file if you are changing files in a +--- source distribution. Only the first time that a file is written a +--- copy of the original file will be kept. The name of the copy is the +--- name of the original file with the string in the 'patchmode' option +--- appended. This option should start with a dot. Use a string like +--- ".orig" or ".org". 'backupdir' must not be empty for this to work +--- (Detail: The backup file is renamed to the patchmode file after the +--- new file has been successfully written, that's why it must be possible +--- to write a backup file). If there was no file to be backed up, an +--- empty file is created. +--- When the 'backupskip' pattern matches, a patchmode file is not made. +--- Using 'patchmode' for compressed files appends the extension at the +--- end (e.g., "file.gz.orig"), thus the resulting name isn't always +--- recognized as a compressed file. +--- Only normal file name characters can be used, `/\*?[|<>` are illegal. +--- +--- @type string +vim.o.patchmode = "" +vim.o.pm = vim.o.patchmode +vim.go.patchmode = vim.o.patchmode +vim.go.pm = vim.go.patchmode + +--- This is a list of directories which will be searched when using the +--- `gf`, [f, ]f, ^Wf, `:find`, `:sfind`, `:tabfind` and other commands, +--- provided that the file being searched for has a relative path (not +--- starting with "/", "./" or "../"). The directories in the 'path' +--- option may be relative or absolute. +--- - Use commas to separate directory names: +--- ``` +--- :set path=.,/usr/local/include,/usr/include +--- ``` +--- - Spaces can also be used to separate directory names. To have a +--- space in a directory name, precede it with an extra backslash, and +--- escape the space: +--- ``` +--- :set path=.,/dir/with\\\ space +--- ``` +--- - To include a comma in a directory name precede it with an extra +--- backslash: +--- ``` +--- :set path=.,/dir/with\\,comma +--- ``` +--- - To search relative to the directory of the current file, use: +--- ``` +--- :set path=. +--- ``` +--- - To search in the current directory use an empty string between two +--- commas: +--- ``` +--- :set path=,, +--- ``` +--- - A directory name may end in a ':' or '/'. +--- - Environment variables are expanded `:set_env`. +--- - When using `netrw.vim` URLs can be used. For example, adding +--- "https://www.vim.org" will make ":find index.html" work. +--- - Search upwards and downwards in a directory tree using "*", "**" and +--- ";". See `file-searching` for info and syntax. +--- - Careful with '\' characters, type two to get one in the option: +--- ``` +--- :set path=.,c:\\include +--- ``` +--- Or just use '/' instead: +--- ``` +--- :set path=.,c:/include +--- ``` +--- Don't forget "." or files won't even be found in the same directory as +--- the file! +--- The maximum length is limited. How much depends on the system, mostly +--- it is something like 256 or 1024 characters. +--- You can check if all the include files are found, using the value of +--- 'path', see `:checkpath`. +--- The use of `:set+=` and `:set-=` is preferred when adding or removing +--- directories from the list. This avoids problems when a future version +--- uses another default. To remove the current directory use: +--- ``` +--- :set path-= +--- ``` +--- To add the current directory use: +--- ``` +--- :set path+= +--- ``` +--- To use an environment variable, you probably need to replace the +--- separator. Here is an example to append $INCL, in which directory +--- names are separated with a semi-colon: +--- ``` +--- :let &path = &path .. "," .. substitute($INCL, ';', ',', 'g') +--- ``` +--- Replace the ';' with a ':' or whatever separator is used. Note that +--- this doesn't work when $INCL contains a comma or white space. +--- +--- @type string +vim.o.path = ".,," +vim.o.pa = vim.o.path +vim.bo.path = vim.o.path +vim.bo.pa = vim.bo.path +vim.go.path = vim.o.path +vim.go.pa = vim.go.path + +--- When changing the indent of the current line, preserve as much of the +--- indent structure as possible. Normally the indent is replaced by a +--- series of tabs followed by spaces as required (unless `'expandtab'` is +--- enabled, in which case only spaces are used). Enabling this option +--- means the indent will preserve as many existing characters as possible +--- for indenting, and only add additional tabs or spaces as required. +--- 'expandtab' does not apply to the preserved white space, a Tab remains +--- a Tab. +--- NOTE: When using ">>" multiple times the resulting indent is a mix of +--- tabs and spaces. You might not like this. +--- Also see 'copyindent'. +--- Use `:retab` to clean up white space. +--- +--- @type boolean +vim.o.preserveindent = false +vim.o.pi = vim.o.preserveindent +vim.bo.preserveindent = vim.o.preserveindent +vim.bo.pi = vim.bo.preserveindent + +--- Default height for a preview window. Used for `:ptag` and associated +--- commands. Used for `CTRL-W_}` when no count is given. +--- +--- @type integer +vim.o.previewheight = 12 +vim.o.pvh = vim.o.previewheight +vim.go.previewheight = vim.o.previewheight +vim.go.pvh = vim.go.previewheight + +--- Identifies the preview window. Only one window can have this option +--- set. It's normally not set directly, but by using one of the commands +--- `:ptag`, `:pedit`, etc. +--- +--- @type boolean +vim.o.previewwindow = false +vim.o.pvw = vim.o.previewwindow +vim.wo.previewwindow = vim.o.previewwindow +vim.wo.pvw = vim.wo.previewwindow + +--- Enables pseudo-transparency for the `popup-menu`. Valid values are in +--- the range of 0 for fully opaque popupmenu (disabled) to 100 for fully +--- transparent background. Values between 0-30 are typically most useful. +--- +--- It is possible to override the level for individual highlights within +--- the popupmenu using `highlight-blend`. For instance, to enable +--- transparency but force the current selected element to be fully opaque: +--- ``` +--- :set pumblend=15 +--- :hi PmenuSel blend=0 +--- ``` +--- +--- UI-dependent. Works best with RGB colors. 'termguicolors' +--- +--- @type integer +vim.o.pumblend = 0 +vim.o.pb = vim.o.pumblend +vim.go.pumblend = vim.o.pumblend +vim.go.pb = vim.go.pumblend + +--- Maximum number of items to show in the popup menu +--- (`ins-completion-menu`). Zero means "use available screen space". +--- +--- @type integer +vim.o.pumheight = 0 +vim.o.ph = vim.o.pumheight +vim.go.pumheight = vim.o.pumheight +vim.go.ph = vim.go.pumheight + +--- Minimum width for the popup menu (`ins-completion-menu`). If the +--- cursor column + 'pumwidth' exceeds screen width, the popup menu is +--- nudged to fit on the screen. +--- +--- @type integer +vim.o.pumwidth = 15 +vim.o.pw = vim.o.pumwidth +vim.go.pumwidth = vim.o.pumwidth +vim.go.pw = vim.go.pumwidth + +--- Specifies the python version used for pyx* functions and commands +--- `python_x`. As only Python 3 is supported, this always has the value +--- `3`. Setting any other value is an error. +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type integer +vim.o.pyxversion = 3 +vim.o.pyx = vim.o.pyxversion +vim.go.pyxversion = vim.o.pyxversion +vim.go.pyx = vim.go.pyxversion + +--- This option specifies a function to be used to get the text to display +--- in the quickfix and location list windows. This can be used to +--- customize the information displayed in the quickfix or location window +--- for each entry in the corresponding quickfix or location list. See +--- `quickfix-window-function` for an explanation of how to write the +--- function and an example. The value can be the name of a function, a +--- `lambda` or a `Funcref`. See `option-value-function` for more +--- information. +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.quickfixtextfunc = "" +vim.o.qftf = vim.o.quickfixtextfunc +vim.go.quickfixtextfunc = vim.o.quickfixtextfunc +vim.go.qftf = vim.go.quickfixtextfunc + +--- The characters that are used to escape quotes in a string. Used for +--- objects like a', a" and a` `a'`. +--- When one of the characters in this option is found inside a string, +--- the following character will be skipped. The default value makes the +--- text "foo\"bar\\" considered to be one string. +--- +--- @type string +vim.o.quoteescape = "\\" +vim.o.qe = vim.o.quoteescape +vim.bo.quoteescape = vim.o.quoteescape +vim.bo.qe = vim.bo.quoteescape + +--- If on, writes fail unless you use a '!'. Protects you from +--- accidentally overwriting a file. Default on when Vim is started +--- in read-only mode ("vim -R") or when the executable is called "view". +--- When using ":w!" the 'readonly' option is reset for the current +--- buffer, unless the 'Z' flag is in 'cpoptions'. +--- When using the ":view" command the 'readonly' option is set for the +--- newly edited buffer. +--- See 'modifiable' for disallowing changes to the buffer. +--- +--- @type boolean +vim.o.readonly = false +vim.o.ro = vim.o.readonly +vim.bo.readonly = vim.o.readonly +vim.bo.ro = vim.bo.readonly + +--- Flags to change the way redrawing works, for debugging purposes. +--- Most useful with 'writedelay' set to some reasonable value. +--- Supports the following flags: +--- compositor Indicate each redraw event handled by the compositor +--- by briefly flashing the redrawn regions in colors +--- indicating the redraw type. These are the highlight +--- groups used (and their default colors): +--- RedrawDebugNormal gui=reverse normal redraw passed through +--- RedrawDebugClear guibg=Yellow clear event passed through +--- RedrawDebugComposed guibg=Green redraw event modified by the +--- compositor (due to +--- overlapping grids, etc) +--- RedrawDebugRecompose guibg=Red redraw generated by the +--- compositor itself, due to a +--- grid being moved or deleted. +--- line introduce a delay after each line drawn on the screen. +--- When using the TUI or another single-grid UI, "compositor" +--- gives more information and should be preferred (every +--- line is processed as a separate event by the compositor) +--- flush introduce a delay after each "flush" event. +--- nothrottle Turn off throttling of the message grid. This is an +--- optimization that joins many small scrolls to one +--- larger scroll when drawing the message area (with +--- 'display' msgsep flag active). +--- invalid Enable stricter checking (abort) of inconsistencies +--- of the internal screen state. This is mostly +--- useful when running nvim inside a debugger (and +--- the test suite). +--- nodelta Send all internally redrawn cells to the UI, even if +--- they are unchanged from the already displayed state. +--- +--- @type string +vim.o.redrawdebug = "" +vim.o.rdb = vim.o.redrawdebug +vim.go.redrawdebug = vim.o.redrawdebug +vim.go.rdb = vim.go.redrawdebug + +--- Time in milliseconds for redrawing the display. Applies to +--- 'hlsearch', 'inccommand', `:match` highlighting and syntax +--- highlighting. +--- When redrawing takes more than this many milliseconds no further +--- matches will be highlighted. +--- For syntax highlighting the time applies per window. When over the +--- limit syntax highlighting is disabled until `CTRL-L` is used. +--- This is used to avoid that Vim hangs when using a very complicated +--- pattern. +--- +--- @type integer +vim.o.redrawtime = 2000 +vim.o.rdt = vim.o.redrawtime +vim.go.redrawtime = vim.o.redrawtime +vim.go.rdt = vim.go.redrawtime + +--- This selects the default regexp engine. `two-engines` +--- The possible values are: +--- 0 automatic selection +--- 1 old engine +--- 2 NFA engine +--- Note that when using the NFA engine and the pattern contains something +--- that is not supported the pattern will not match. This is only useful +--- for debugging the regexp engine. +--- Using automatic selection enables Vim to switch the engine, if the +--- default engine becomes too costly. E.g., when the NFA engine uses too +--- many states. This should prevent Vim from hanging on a combination of +--- a complex pattern with long text. +--- +--- @type integer +vim.o.regexpengine = 0 +vim.o.re = vim.o.regexpengine +vim.go.regexpengine = vim.o.regexpengine +vim.go.re = vim.go.regexpengine + +--- Show the line number relative to the line with the cursor in front of +--- each line. Relative line numbers help you use the `count` you can +--- precede some vertical motion commands (e.g. j k + -) with, without +--- having to calculate it yourself. Especially useful in combination with +--- other commands (e.g. y d c < > gq gw =). +--- When the 'n' option is excluded from 'cpoptions' a wrapped +--- line will not use the column of line numbers. +--- The 'numberwidth' option can be used to set the room used for the line +--- number. +--- When a long, wrapped line doesn't start with the first character, '-' +--- characters are put before the number. +--- See `hl-LineNr` and `hl-CursorLineNr` for the highlighting used for +--- the number. +--- +--- The number in front of the cursor line also depends on the value of +--- 'number', see `number_relativenumber` for all combinations of the two +--- options. +--- +--- @type boolean +vim.o.relativenumber = false +vim.o.rnu = vim.o.relativenumber +vim.wo.relativenumber = vim.o.relativenumber +vim.wo.rnu = vim.wo.relativenumber + +--- Threshold for reporting number of lines changed. When the number of +--- changed lines is more than 'report' a message will be given for most +--- ":" commands. If you want it always, set 'report' to 0. +--- For the ":substitute" command the number of substitutions is used +--- instead of the number of lines. +--- +--- @type integer +vim.o.report = 2 +vim.go.report = vim.o.report + +--- Inserting characters in Insert mode will work backwards. See "typing +--- backwards" `ins-reverse`. This option can be toggled with the CTRL-_ +--- command in Insert mode, when 'allowrevins' is set. +--- +--- @type boolean +vim.o.revins = false +vim.o.ri = vim.o.revins +vim.go.revins = vim.o.revins +vim.go.ri = vim.go.revins + +--- When on, display orientation becomes right-to-left, i.e., characters +--- that are stored in the file appear from the right to the left. +--- Using this option, it is possible to edit files for languages that +--- are written from the right to the left such as Hebrew and Arabic. +--- This option is per window, so it is possible to edit mixed files +--- simultaneously, or to view the same file in both ways (this is +--- useful whenever you have a mixed text file with both right-to-left +--- and left-to-right strings so that both sets are displayed properly +--- in different windows). Also see `rileft.txt`. +--- +--- @type boolean +vim.o.rightleft = false +vim.o.rl = vim.o.rightleft +vim.wo.rightleft = vim.o.rightleft +vim.wo.rl = vim.wo.rightleft + +--- Each word in this option enables the command line editing to work in +--- right-to-left mode for a group of commands: +--- +--- search "/" and "?" commands +--- +--- This is useful for languages such as Hebrew, Arabic and Farsi. +--- The 'rightleft' option must be set for 'rightleftcmd' to take effect. +--- +--- @type string +vim.o.rightleftcmd = "search" +vim.o.rlc = vim.o.rightleftcmd +vim.wo.rightleftcmd = vim.o.rightleftcmd +vim.wo.rlc = vim.wo.rightleftcmd + +--- Show the line and column number of the cursor position, separated by a +--- comma. When there is room, the relative position of the displayed +--- text in the file is shown on the far right: +--- Top first line is visible +--- Bot last line is visible +--- All first and last line are visible +--- 45% relative position in the file +--- If 'rulerformat' is set, it will determine the contents of the ruler. +--- Each window has its own ruler. If a window has a status line, the +--- ruler is shown there. If a window doesn't have a status line and +--- 'cmdheight' is zero, the ruler is not shown. Otherwise it is shown in +--- the last line of the screen. If the statusline is given by +--- 'statusline' (i.e. not empty), this option takes precedence over +--- 'ruler' and 'rulerformat'. +--- If the number of characters displayed is different from the number of +--- bytes in the text (e.g., for a TAB or a multibyte character), both +--- the text column (byte number) and the screen column are shown, +--- separated with a dash. +--- For an empty line "0-1" is shown. +--- For an empty buffer the line number will also be zero: "0,0-1". +--- If you don't want to see the ruler all the time but want to know where +--- you are, use "g CTRL-G" `g_CTRL-G`. +--- +--- @type boolean +vim.o.ruler = true +vim.o.ru = vim.o.ruler +vim.go.ruler = vim.o.ruler +vim.go.ru = vim.go.ruler + +--- When this option is not empty, it determines the content of the ruler +--- string, as displayed for the 'ruler' option. +--- The format of this option is like that of 'statusline'. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- The default ruler width is 17 characters. To make the ruler 15 +--- characters wide, put "%15(" at the start and "%)" at the end. +--- Example: +--- ``` +--- :set rulerformat=%15(%c%V\ %p%%%) +--- ``` +--- +--- +--- @type string +vim.o.rulerformat = "" +vim.o.ruf = vim.o.rulerformat +vim.go.rulerformat = vim.o.rulerformat +vim.go.ruf = vim.go.rulerformat + +--- List of directories to be searched for these runtime files: +--- filetype.lua filetypes `new-filetype` +--- autoload/ automatically loaded scripts `autoload-functions` +--- colors/ color scheme files `:colorscheme` +--- compiler/ compiler files `:compiler` +--- doc/ documentation `write-local-help` +--- ftplugin/ filetype plugins `write-filetype-plugin` +--- indent/ indent scripts `indent-expression` +--- keymap/ key mapping files `mbyte-keymap` +--- lang/ menu translations `:menutrans` +--- lua/ `Lua` plugins +--- menu.vim GUI menus `menu.vim` +--- pack/ packages `:packadd` +--- parser/ `treesitter` syntax parsers +--- plugin/ plugin scripts `write-plugin` +--- queries/ `treesitter` queries +--- rplugin/ `remote-plugin` scripts +--- spell/ spell checking files `spell` +--- syntax/ syntax files `mysyntaxfile` +--- tutor/ tutorial files `:Tutor` +--- +--- And any other file searched for with the `:runtime` command. +--- +--- Defaults are setup to search these locations: +--- 1. Your home directory, for personal preferences. +--- Given by `stdpath("config")`. `$XDG_CONFIG_HOME` +--- 2. Directories which must contain configuration files according to +--- `xdg` ($XDG_CONFIG_DIRS, defaults to /etc/xdg). This also contains +--- preferences from system administrator. +--- 3. Data home directory, for plugins installed by user. +--- Given by `stdpath("data")/site`. `$XDG_DATA_HOME` +--- 4. nvim/site subdirectories for each directory in $XDG_DATA_DIRS. +--- This is for plugins which were installed by system administrator, +--- but are not part of the Nvim distribution. XDG_DATA_DIRS defaults +--- to /usr/local/share/:/usr/share/, so system administrators are +--- expected to install site plugins to /usr/share/nvim/site. +--- 5. Session state directory, for state data such as swap, backupdir, +--- viewdir, undodir, etc. +--- Given by `stdpath("state")`. `$XDG_STATE_HOME` +--- 6. $VIMRUNTIME, for files distributed with Nvim. +--- *after-directory* +--- 7, 8, 9, 10. In after/ subdirectories of 1, 2, 3 and 4, with reverse +--- ordering. This is for preferences to overrule or add to the +--- distributed defaults or system-wide settings (rarely needed). +--- +--- *packages-runtimepath* +--- "start" packages will also be searched (`runtime-search-path`) for +--- runtime files after these, though such packages are not explicitly +--- reported in &runtimepath. But "opt" packages are explicitly added to +--- &runtimepath by `:packadd`. +--- +--- Note that, unlike 'path', no wildcards like "**" are allowed. Normal +--- wildcards are allowed, but can significantly slow down searching for +--- runtime files. For speed, use as few items as possible and avoid +--- wildcards. +--- See `:runtime`. +--- Example: +--- ``` +--- :set runtimepath=~/vimruntime,/mygroup/vim,$VIMRUNTIME +--- ``` +--- This will use the directory "~/vimruntime" first (containing your +--- personal Nvim runtime files), then "/mygroup/vim", and finally +--- "$VIMRUNTIME" (the default runtime files). +--- You can put a directory before $VIMRUNTIME to find files which replace +--- distributed runtime files. You can put a directory after $VIMRUNTIME +--- to find files which add to distributed runtime files. +--- +--- With `--clean` the home directory entries are not included. +--- +--- @type string +vim.o.runtimepath = "..." +vim.o.rtp = vim.o.runtimepath +vim.go.runtimepath = vim.o.runtimepath +vim.go.rtp = vim.go.runtimepath + +--- Number of lines to scroll with CTRL-U and CTRL-D commands. Will be +--- set to half the number of lines in the window when the window size +--- changes. This may happen when enabling the `status-line` or +--- 'tabline' option after setting the 'scroll' option. +--- If you give a count to the CTRL-U or CTRL-D command it will +--- be used as the new value for 'scroll'. Reset to half the window +--- height with ":set scroll=0". +--- +--- @type integer +vim.o.scroll = 0 +vim.o.scr = vim.o.scroll +vim.wo.scroll = vim.o.scroll +vim.wo.scr = vim.wo.scroll + +--- Maximum number of lines kept beyond the visible screen. Lines at the +--- top are deleted if new lines exceed this limit. +--- Minimum is 1, maximum is 100000. +--- Only in `terminal` buffers. +--- +--- Note: Lines that are not visible and kept in scrollback are not +--- reflown when the terminal buffer is resized horizontally. +--- +--- @type integer +vim.o.scrollback = -1 +vim.o.scbk = vim.o.scrollback +vim.bo.scrollback = vim.o.scrollback +vim.bo.scbk = vim.bo.scrollback + +--- See also `scroll-binding`. When this option is set, scrolling the +--- current window also scrolls other scrollbind windows (windows that +--- also have this option set). This option is useful for viewing the +--- differences between two versions of a file, see 'diff'. +--- See `'scrollopt'` for options that determine how this option should be +--- interpreted. +--- This option is mostly reset when splitting a window to edit another +--- file. This means that ":split | edit file" results in two windows +--- with scroll-binding, but ":split file" does not. +--- +--- @type boolean +vim.o.scrollbind = false +vim.o.scb = vim.o.scrollbind +vim.wo.scrollbind = vim.o.scrollbind +vim.wo.scb = vim.wo.scrollbind + +--- Minimal number of lines to scroll when the cursor gets off the +--- screen (e.g., with "j"). Not used for scroll commands (e.g., CTRL-E, +--- CTRL-D). Useful if your terminal scrolls very slowly. +--- When set to a negative number from -1 to -100 this is used as the +--- percentage of the window height. Thus -50 scrolls half the window +--- height. +--- +--- @type integer +vim.o.scrolljump = 1 +vim.o.sj = vim.o.scrolljump +vim.go.scrolljump = vim.o.scrolljump +vim.go.sj = vim.go.scrolljump + +--- Minimal number of screen lines to keep above and below the cursor. +--- This will make some context visible around where you are working. If +--- you set it to a very large value (999) the cursor line will always be +--- in the middle of the window (except at the start or end of the file or +--- when long lines wrap). +--- After using the local value, go back the global value with one of +--- these two: +--- ``` +--- setlocal scrolloff< +--- setlocal scrolloff=-1 +--- ``` +--- For scrolling horizontally see 'sidescrolloff'. +--- +--- @type integer +vim.o.scrolloff = 0 +vim.o.so = vim.o.scrolloff +vim.wo.scrolloff = vim.o.scrolloff +vim.wo.so = vim.wo.scrolloff +vim.go.scrolloff = vim.o.scrolloff +vim.go.so = vim.go.scrolloff + +--- This is a comma-separated list of words that specifies how +--- 'scrollbind' windows should behave. 'sbo' stands for ScrollBind +--- Options. +--- The following words are available: +--- ver Bind vertical scrolling for 'scrollbind' windows +--- hor Bind horizontal scrolling for 'scrollbind' windows +--- jump Applies to the offset between two windows for vertical +--- scrolling. This offset is the difference in the first +--- displayed line of the bound windows. When moving +--- around in a window, another 'scrollbind' window may +--- reach a position before the start or after the end of +--- the buffer. The offset is not changed though, when +--- moving back the 'scrollbind' window will try to scroll +--- to the desired position when possible. +--- When now making that window the current one, two +--- things can be done with the relative offset: +--- 1. When "jump" is not included, the relative offset is +--- adjusted for the scroll position in the new current +--- window. When going back to the other window, the +--- new relative offset will be used. +--- 2. When "jump" is included, the other windows are +--- scrolled to keep the same relative offset. When +--- going back to the other window, it still uses the +--- same relative offset. +--- Also see `scroll-binding`. +--- When 'diff' mode is active there always is vertical scroll binding, +--- even when "ver" isn't there. +--- +--- @type string +vim.o.scrollopt = "ver,jump" +vim.o.sbo = vim.o.scrollopt +vim.go.scrollopt = vim.o.scrollopt +vim.go.sbo = vim.go.scrollopt + +--- Specifies the nroff macros that separate sections. These are pairs of +--- two letters (See `object-motions`). The default makes a section start +--- at the nroff macros ".SH", ".NH", ".H", ".HU", ".nh" and ".sh". +--- +--- @type string +vim.o.sections = "SHNHH HUnhsh" +vim.o.sect = vim.o.sections +vim.go.sections = vim.o.sections +vim.go.sect = vim.go.sections + +--- This option defines the behavior of the selection. It is only used +--- in Visual and Select mode. +--- Possible values: +--- value past line inclusive ~ +--- old no yes +--- inclusive yes yes +--- exclusive yes no +--- "past line" means that the cursor is allowed to be positioned one +--- character past the line. +--- "inclusive" means that the last character of the selection is included +--- in an operation. For example, when "x" is used to delete the +--- selection. +--- When "old" is used and 'virtualedit' allows the cursor to move past +--- the end of line the line break still isn't included. +--- Note that when "exclusive" is used and selecting from the end +--- backwards, you cannot include the last character of a line, when +--- starting in Normal mode and 'virtualedit' empty. +--- +--- @type string +vim.o.selection = "inclusive" +vim.o.sel = vim.o.selection +vim.go.selection = vim.o.selection +vim.go.sel = vim.go.selection + +--- This is a comma-separated list of words, which specifies when to start +--- Select mode instead of Visual mode, when a selection is started. +--- Possible values: +--- mouse when using the mouse +--- key when using shifted special keys +--- cmd when using "v", "V" or CTRL-V +--- See `Select-mode`. +--- +--- @type string +vim.o.selectmode = "" +vim.o.slm = vim.o.selectmode +vim.go.selectmode = vim.o.selectmode +vim.go.slm = vim.go.selectmode + +--- Changes the effect of the `:mksession` command. It is a comma- +--- separated list of words. Each word enables saving and restoring +--- something: +--- word save and restore ~ +--- blank empty windows +--- buffers hidden and unloaded buffers, not just those in windows +--- curdir the current directory +--- folds manually created folds, opened/closed folds and local +--- fold options +--- globals global variables that start with an uppercase letter +--- and contain at least one lowercase letter. Only +--- String and Number types are stored. +--- help the help window +--- localoptions options and mappings local to a window or buffer (not +--- global values for local options) +--- options all options and mappings (also global values for local +--- options) +--- skiprtp exclude 'runtimepath' and 'packpath' from the options +--- resize size of the Vim window: 'lines' and 'columns' +--- sesdir the directory in which the session file is located +--- will become the current directory (useful with +--- projects accessed over a network from different +--- systems) +--- tabpages all tab pages; without this only the current tab page +--- is restored, so that you can make a session for each +--- tab page separately +--- terminal include terminal windows where the command can be +--- restored +--- winpos position of the whole Vim window +--- winsize window sizes +--- slash `deprecated` Always enabled. Uses "/" in filenames. +--- unix `deprecated` Always enabled. Uses "\n" line endings. +--- +--- Don't include both "curdir" and "sesdir". When neither is included +--- filenames are stored as absolute paths. +--- If you leave out "options" many things won't work well after restoring +--- the session. +--- +--- @type string +vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,terminal" +vim.o.ssop = vim.o.sessionoptions +vim.go.sessionoptions = vim.o.sessionoptions +vim.go.ssop = vim.go.sessionoptions + +--- When non-empty, the shada file is read upon startup and written +--- when exiting Vim (see `shada-file`). The string should be a comma- +--- separated list of parameters, each consisting of a single character +--- identifying the particular parameter, followed by a number or string +--- which specifies the value of that parameter. If a particular +--- character is left out, then the default value is used for that +--- parameter. The following is a list of the identifying characters and +--- the effect of their value. +--- CHAR VALUE ~ +--- *shada-!* +--- ! When included, save and restore global variables that start +--- with an uppercase letter, and don't contain a lowercase +--- letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis" +--- and "_K_L_M" are not. Nested List and Dict items may not be +--- read back correctly, you end up with an empty item. +--- *shada-quote* +--- " Maximum number of lines saved for each register. Old name of +--- the '<' item, with the disadvantage that you need to put a +--- backslash before the ", otherwise it will be recognized as the +--- start of a comment! +--- *shada-%* +--- % When included, save and restore the buffer list. If Vim is +--- started with a file name argument, the buffer list is not +--- restored. If Vim is started without a file name argument, the +--- buffer list is restored from the shada file. Quickfix +--- ('buftype'), unlisted ('buflisted'), unnamed and buffers on +--- removable media (`shada-r`) are not saved. +--- When followed by a number, the number specifies the maximum +--- number of buffers that are stored. Without a number all +--- buffers are stored. +--- *shada-'* +--- ' Maximum number of previously edited files for which the marks +--- are remembered. This parameter must always be included when +--- 'shada' is non-empty. +--- Including this item also means that the `jumplist` and the +--- `changelist` are stored in the shada file. +--- *shada-/* +--- / Maximum number of items in the search pattern history to be +--- saved. If non-zero, then the previous search and substitute +--- patterns are also saved. When not included, the value of +--- 'history' is used. +--- *shada-:* +--- : Maximum number of items in the command-line history to be +--- saved. When not included, the value of 'history' is used. +--- *shada-<* +--- \< Maximum number of lines saved for each register. If zero then +--- registers are not saved. When not included, all lines are +--- saved. '"' is the old name for this item. +--- Also see the 's' item below: limit specified in KiB. +--- *shada-@* +--- @ Maximum number of items in the input-line history to be +--- saved. When not included, the value of 'history' is used. +--- *shada-c* +--- c Dummy option, kept for compatibility reasons. Has no actual +--- effect: ShaDa always uses UTF-8 and 'encoding' value is fixed +--- to UTF-8 as well. +--- *shada-f* +--- f Whether file marks need to be stored. If zero, file marks ('0 +--- to '9, 'A to 'Z) are not stored. When not present or when +--- non-zero, they are all stored. '0 is used for the current +--- cursor position (when exiting or when doing `:wshada`). +--- *shada-h* +--- h Disable the effect of 'hlsearch' when loading the shada +--- file. When not included, it depends on whether ":nohlsearch" +--- has been used since the last search command. +--- *shada-n* +--- n Name of the shada file. The name must immediately follow +--- the 'n'. Must be at the end of the option! If the +--- 'shadafile' option is set, that file name overrides the one +--- given here with 'shada'. Environment variables are +--- expanded when opening the file, not when setting the option. +--- *shada-r* +--- r Removable media. The argument is a string (up to the next +--- ','). This parameter can be given several times. Each +--- specifies the start of a path for which no marks will be +--- stored. This is to avoid removable media. For Windows you +--- could use "ra:,rb:". You can also use it for temp files, +--- e.g., for Unix: "r/tmp". Case is ignored. +--- *shada-s* +--- s Maximum size of an item contents in KiB. If zero then nothing +--- is saved. Unlike Vim this applies to all items, except for +--- the buffer list and header. Full item size is off by three +--- unsigned integers: with `s10` maximum item size may be 1 byte +--- (type: 7-bit integer) + 9 bytes (timestamp: up to 64-bit +--- integer) + 3 bytes (item size: up to 16-bit integer because +--- 2^8 < 10240 < 2^16) + 10240 bytes (requested maximum item +--- contents size) = 10253 bytes. +--- +--- Example: +--- ``` +--- :set shada='50,<1000,s100,:0,n~/nvim/shada +--- ``` +--- +--- '50 Marks will be remembered for the last 50 files you +--- edited. +--- <1000 Contents of registers (up to 1000 lines each) will be +--- remembered. +--- s100 Items with contents occupying more then 100 KiB are +--- skipped. +--- :0 Command-line history will not be saved. +--- n~/nvim/shada The name of the file to use is "~/nvim/shada". +--- no / Since '/' is not specified, the default will be used, +--- that is, save all of the search history, and also the +--- previous search and substitute patterns. +--- no % The buffer list will not be saved nor read back. +--- no h 'hlsearch' highlighting will be restored. +--- +--- When setting 'shada' from an empty value you can use `:rshada` to +--- load the contents of the file, this is not done automatically. +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shada = "!,'100,<50,s10,h" +vim.o.sd = vim.o.shada +vim.go.shada = vim.o.shada +vim.go.sd = vim.go.shada + +--- When non-empty, overrides the file name used for `shada` (viminfo). +--- When equal to "NONE" no shada file will be read or written. +--- This option can be set with the `-i` command line flag. The `--clean` +--- command line flag sets it to "NONE". +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shadafile = "" +vim.o.sdf = vim.o.shadafile +vim.go.shadafile = vim.o.shadafile +vim.go.sdf = vim.go.shadafile + +--- Name of the shell to use for ! and :! commands. When changing the +--- value also check these options: 'shellpipe', 'shellslash' +--- 'shellredir', 'shellquote', 'shellxquote' and 'shellcmdflag'. +--- It is allowed to give an argument to the command, e.g. "csh -f". +--- See `option-backslash` about including spaces and backslashes. +--- Environment variables are expanded `:set_env`. +--- +--- If the name of the shell contains a space, you need to enclose it in +--- quotes. Example with quotes: +--- ``` +--- :set shell=\"c:\program\ files\unix\sh.exe\"\ -f +--- ``` +--- Note the backslash before each quote (to avoid starting a comment) and +--- each space (to avoid ending the option value), so better use `:let-&` +--- like this: +--- ``` +--- :let &shell='"C:\Program Files\unix\sh.exe" -f' +--- ``` +--- Also note that the "-f" is not inside the quotes, because it is not +--- part of the command name. +--- *shell-unquoting* +--- Rules regarding quotes: +--- 1. Option is split on space and tab characters that are not inside +--- quotes: "abc def" runs shell named "abc" with additional argument +--- "def", '"abc def"' runs shell named "abc def" with no additional +--- arguments (here and below: additional means “additional to +--- 'shellcmdflag'”). +--- 2. Quotes in option may be present in any position and any number: +--- '"abc"', '"a"bc', 'a"b"c', 'ab"c"' and '"a"b"c"' are all equivalent +--- to just "abc". +--- 3. Inside quotes backslash preceding backslash means one backslash. +--- Backslash preceding quote means one quote. Backslash preceding +--- anything else means backslash and next character literally: +--- '"a\\b"' is the same as "a\b", '"a\\"b"' runs shell named literally +--- 'a"b', '"a\b"' is the same as "a\b" again. +--- 4. Outside of quotes backslash always means itself, it cannot be used +--- to escape quote: 'a\"b"' is the same as "a\b". +--- Note that such processing is done after `:set` did its own round of +--- unescaping, so to keep yourself sane use `:let-&` like shown above. +--- *shell-powershell* +--- To use PowerShell: +--- ``` +--- let &shell = executable('pwsh') ? 'pwsh' : 'powershell' +--- let &shellcmdflag = '-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';Remove-Alias -Force -ErrorAction SilentlyContinue tee;' +--- let &shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode' +--- let &shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode' +--- set shellquote= shellxquote= +--- ``` +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shell = "sh" +vim.o.sh = vim.o.shell +vim.go.shell = vim.o.shell +vim.go.sh = vim.go.shell + +--- Flag passed to the shell to execute "!" and ":!" commands; e.g., +--- `bash.exe -c ls` or `cmd.exe /s /c "dir"`. For MS-Windows, the +--- default is set according to the value of 'shell', to reduce the need +--- to set this option by the user. +--- On Unix it can have more than one flag. Each white space separated +--- part is passed as an argument to the shell command. +--- See `option-backslash` about including spaces and backslashes. +--- See `shell-unquoting` which talks about separating this option into +--- multiple arguments. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shellcmdflag = "-c" +vim.o.shcf = vim.o.shellcmdflag +vim.go.shellcmdflag = vim.o.shellcmdflag +vim.go.shcf = vim.go.shellcmdflag + +--- String to be used to put the output of the ":make" command in the +--- error file. See also `:make_makeprg`. See `option-backslash` about +--- including spaces and backslashes. +--- The name of the temporary file can be represented by "%s" if necessary +--- (the file name is appended automatically if no %s appears in the value +--- of this option). +--- For MS-Windows the default is "2>&1| tee". The stdout and stderr are +--- saved in a file and echoed to the screen. +--- For Unix the default is "| tee". The stdout of the compiler is saved +--- in a file and echoed to the screen. If the 'shell' option is "csh" or +--- "tcsh" after initializations, the default becomes "|& tee". If the +--- 'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta", +--- "bash", "fish", "ash" or "dash" the default becomes "2>&1| tee". This +--- means that stderr is also included. Before using the 'shell' option a +--- path is removed, thus "/bin/sh" uses "sh". +--- The initialization of this option is done after reading the vimrc +--- and the other initializations, so that when the 'shell' option is set +--- there, the 'shellpipe' option changes automatically, unless it was +--- explicitly set before. +--- When 'shellpipe' is set to an empty string, no redirection of the +--- ":make" output will be done. This is useful if you use a 'makeprg' +--- that writes to 'makeef' by itself. If you want no piping, but do +--- want to include the 'makeef', set 'shellpipe' to a single space. +--- Don't forget to precede the space with a backslash: ":set sp=\ ". +--- In the future pipes may be used for filtering and this option will +--- become obsolete (at least for Unix). +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shellpipe = "| tee" +vim.o.sp = vim.o.shellpipe +vim.go.shellpipe = vim.o.shellpipe +vim.go.sp = vim.go.shellpipe + +--- Quoting character(s), put around the command passed to the shell, for +--- the "!" and ":!" commands. The redirection is kept outside of the +--- quoting. See 'shellxquote' to include the redirection. It's +--- probably not useful to set both options. +--- This is an empty string by default. Only known to be useful for +--- third-party shells on Windows systems, such as the MKS Korn Shell +--- or bash, where it should be "\"". The default is adjusted according +--- the value of 'shell', to reduce the need to set this option by the +--- user. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shellquote = "" +vim.o.shq = vim.o.shellquote +vim.go.shellquote = vim.o.shellquote +vim.go.shq = vim.go.shellquote + +--- String to be used to put the output of a filter command in a temporary +--- file. See also `:!`. See `option-backslash` about including spaces +--- and backslashes. +--- The name of the temporary file can be represented by "%s" if necessary +--- (the file name is appended automatically if no %s appears in the value +--- of this option). +--- The default is ">". For Unix, if the 'shell' option is "csh" or +--- "tcsh" during initializations, the default becomes ">&". If the +--- 'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta", +--- "bash" or "fish", the default becomes ">%s 2>&1". This means that +--- stderr is also included. For Win32, the Unix checks are done and +--- additionally "cmd" is checked for, which makes the default ">%s 2>&1". +--- Also, the same names with ".exe" appended are checked for. +--- The initialization of this option is done after reading the vimrc +--- and the other initializations, so that when the 'shell' option is set +--- there, the 'shellredir' option changes automatically unless it was +--- explicitly set before. +--- In the future pipes may be used for filtering and this option will +--- become obsolete (at least for Unix). +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shellredir = ">" +vim.o.srr = vim.o.shellredir +vim.go.shellredir = vim.o.shellredir +vim.go.srr = vim.go.shellredir + +--- only for MS-Windows +--- When set, a forward slash is used when expanding file names. This is +--- useful when a Unix-like shell is used instead of cmd.exe. Backward +--- slashes can still be typed, but they are changed to forward slashes by +--- Vim. +--- Note that setting or resetting this option has no effect for some +--- existing file names, thus this option needs to be set before opening +--- any file for best results. This might change in the future. +--- 'shellslash' only works when a backslash can be used as a path +--- separator. To test if this is so use: +--- ``` +--- if exists('+shellslash') +--- ``` +--- Also see 'completeslash'. +--- +--- @type boolean +vim.o.shellslash = false +vim.o.ssl = vim.o.shellslash +vim.go.shellslash = vim.o.shellslash +vim.go.ssl = vim.go.shellslash + +--- When on, use temp files for shell commands. When off use a pipe. +--- When using a pipe is not possible temp files are used anyway. +--- The advantage of using a pipe is that nobody can read the temp file +--- and the 'shell' command does not need to support redirection. +--- The advantage of using a temp file is that the file type and encoding +--- can be detected. +--- The `FilterReadPre`, `FilterReadPost` and `FilterWritePre|, +--- |FilterWritePost` autocommands event are not triggered when +--- 'shelltemp' is off. +--- `system()` does not respect this option, it always uses pipes. +--- +--- @type boolean +vim.o.shelltemp = true +vim.o.stmp = vim.o.shelltemp +vim.go.shelltemp = vim.o.shelltemp +vim.go.stmp = vim.go.shelltemp + +--- When 'shellxquote' is set to "(" then the characters listed in this +--- option will be escaped with a '^' character. This makes it possible +--- to execute most external commands with cmd.exe. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shellxescape = "" +vim.o.sxe = vim.o.shellxescape +vim.go.shellxescape = vim.o.shellxescape +vim.go.sxe = vim.go.shellxescape + +--- Quoting character(s), put around the command passed to the shell, for +--- the "!" and ":!" commands. Includes the redirection. See +--- 'shellquote' to exclude the redirection. It's probably not useful +--- to set both options. +--- When the value is '(' then ')' is appended. When the value is '"(' +--- then ')"' is appended. +--- When the value is '(' then also see 'shellxescape'. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.shellxquote = "" +vim.o.sxq = vim.o.shellxquote +vim.go.shellxquote = vim.o.shellxquote +vim.go.sxq = vim.go.shellxquote + +--- Round indent to multiple of 'shiftwidth'. Applies to > and < +--- commands. CTRL-T and CTRL-D in Insert mode always round the indent to +--- a multiple of 'shiftwidth' (this is Vi compatible). +--- +--- @type boolean +vim.o.shiftround = false +vim.o.sr = vim.o.shiftround +vim.go.shiftround = vim.o.shiftround +vim.go.sr = vim.go.shiftround + +--- Number of spaces to use for each step of (auto)indent. Used for +--- `'cindent'`, `>>`, `<<`, etc. +--- When zero the 'tabstop' value will be used. Use the `shiftwidth()` +--- function to get the effective shiftwidth value. +--- +--- @type integer +vim.o.shiftwidth = 8 +vim.o.sw = vim.o.shiftwidth +vim.bo.shiftwidth = vim.o.shiftwidth +vim.bo.sw = vim.bo.shiftwidth + +--- This option helps to avoid all the `hit-enter` prompts caused by file +--- messages, for example with CTRL-G, and to avoid some other messages. +--- It is a list of flags: +--- flag meaning when present ~ +--- l use "999L, 888B" instead of "999 lines, 888 bytes" *shm-l* +--- m use "[+]" instead of "[Modified]" *shm-m* +--- r use "[RO]" instead of "[readonly]" *shm-r* +--- w use "[w]" instead of "written" for file write message *shm-w* +--- and "[a]" instead of "appended" for ':w >> file' command +--- a all of the above abbreviations *shm-a* +--- +--- o overwrite message for writing a file with subsequent *shm-o* +--- message for reading a file (useful for ":wn" or when +--- 'autowrite' on) +--- O message for reading a file overwrites any previous *shm-O* +--- message; also for quickfix message (e.g., ":cn") +--- s don't give "search hit BOTTOM, continuing at TOP" or *shm-s* +--- "search hit TOP, continuing at BOTTOM" messages; when using +--- the search count do not show "W" after the count message (see +--- S below) +--- t truncate file message at the start if it is too long *shm-t* +--- to fit on the command-line, "<" will appear in the left most +--- column; ignored in Ex mode +--- T truncate other messages in the middle if they are too *shm-T* +--- long to fit on the command line; "..." will appear in the +--- middle; ignored in Ex mode +--- W don't give "written" or "[w]" when writing a file *shm-W* +--- A don't give the "ATTENTION" message when an existing *shm-A* +--- swap file is found +--- I don't give the intro message when starting Vim, *shm-I* +--- see `:intro` +--- c don't give `ins-completion-menu` messages; for *shm-c* +--- example, "-- XXX completion (YYY)", "match 1 of 2", "The only +--- match", "Pattern not found", "Back at original", etc. +--- C don't give messages while scanning for ins-completion *shm-C* +--- items, for instance "scanning tags" +--- q use "recording" instead of "recording @a" *shm-q* +--- F don't give the file info when editing a file, like *shm-F* +--- `:silent` was used for the command +--- S do not show search count message when searching, e.g. *shm-S* +--- "[1/5]" +--- +--- This gives you the opportunity to avoid that a change between buffers +--- requires you to hit <Enter>, but still gives as useful a message as +--- possible for the space available. To get the whole message that you +--- would have got with 'shm' empty, use ":file!" +--- Useful values: +--- shm= No abbreviation of message. +--- shm=a Abbreviation, but no loss of information. +--- shm=at Abbreviation, and truncate message when necessary. +--- +--- @type string +vim.o.shortmess = "ltToOCF" +vim.o.shm = vim.o.shortmess +vim.go.shortmess = vim.o.shortmess +vim.go.shm = vim.go.shortmess + +--- String to put at the start of lines that have been wrapped. Useful +--- values are "> " or "+++ ": +--- ``` +--- :let &showbreak = "> " +--- :let &showbreak = '+++ ' +--- ``` +--- Only printable single-cell characters are allowed, excluding <Tab> and +--- comma (in a future version the comma might be used to separate the +--- part that is shown at the end and at the start of a line). +--- The `hl-NonText` highlight group determines the highlighting. +--- Note that tabs after the showbreak will be displayed differently. +--- If you want the 'showbreak' to appear in between line numbers, add the +--- "n" flag to 'cpoptions'. +--- A window-local value overrules a global value. If the global value is +--- set and you want no value in the current window use NONE: +--- ``` +--- :setlocal showbreak=NONE +--- ``` +--- +--- +--- @type string +vim.o.showbreak = "" +vim.o.sbr = vim.o.showbreak +vim.wo.showbreak = vim.o.showbreak +vim.wo.sbr = vim.wo.showbreak +vim.go.showbreak = vim.o.showbreak +vim.go.sbr = vim.go.showbreak + +--- Show (partial) command in the last line of the screen. Set this +--- option off if your terminal is slow. +--- In Visual mode the size of the selected area is shown: +--- - When selecting characters within a line, the number of characters. +--- If the number of bytes is different it is also displayed: "2-6" +--- means two characters and six bytes. +--- - When selecting more than one line, the number of lines. +--- - When selecting a block, the size in screen characters: +--- {lines}x{columns}. +--- This information can be displayed in an alternative location using the +--- 'showcmdloc' option, useful when 'cmdheight' is 0. +--- +--- @type boolean +vim.o.showcmd = true +vim.o.sc = vim.o.showcmd +vim.go.showcmd = vim.o.showcmd +vim.go.sc = vim.go.showcmd + +--- This option can be used to display the (partially) entered command in +--- another location. Possible values are: +--- last Last line of the screen (default). +--- statusline Status line of the current window. +--- tabline First line of the screen if 'showtabline' is enabled. +--- Setting this option to "statusline" or "tabline" means that these will +--- be redrawn whenever the command changes, which can be on every key +--- pressed. +--- The %S 'statusline' item can be used in 'statusline' or 'tabline' to +--- place the text. Without a custom 'statusline' or 'tabline' it will be +--- displayed in a convenient location. +--- +--- @type string +vim.o.showcmdloc = "last" +vim.o.sloc = vim.o.showcmdloc +vim.go.showcmdloc = vim.o.showcmdloc +vim.go.sloc = vim.go.showcmdloc + +--- When completing a word in insert mode (see `ins-completion`) from the +--- tags file, show both the tag name and a tidied-up form of the search +--- pattern (if there is one) as possible matches. Thus, if you have +--- matched a C function, you can see a template for what arguments are +--- required (coding style permitting). +--- Note that this doesn't work well together with having "longest" in +--- 'completeopt', because the completion from the search pattern may not +--- match the typed text. +--- +--- @type boolean +vim.o.showfulltag = false +vim.o.sft = vim.o.showfulltag +vim.go.showfulltag = vim.o.showfulltag +vim.go.sft = vim.go.showfulltag + +--- When a bracket is inserted, briefly jump to the matching one. The +--- jump is only done if the match can be seen on the screen. The time to +--- show the match can be set with 'matchtime'. +--- A Beep is given if there is no match (no matter if the match can be +--- seen or not). +--- When the 'm' flag is not included in 'cpoptions', typing a character +--- will immediately move the cursor back to where it belongs. +--- See the "sm" field in 'guicursor' for setting the cursor shape and +--- blinking when showing the match. +--- The 'matchpairs' option can be used to specify the characters to show +--- matches for. 'rightleft' and 'revins' are used to look for opposite +--- matches. +--- Also see the matchparen plugin for highlighting the match when moving +--- around `pi_paren.txt`. +--- Note: Use of the short form is rated PG. +--- +--- @type boolean +vim.o.showmatch = false +vim.o.sm = vim.o.showmatch +vim.go.showmatch = vim.o.showmatch +vim.go.sm = vim.go.showmatch + +--- If in Insert, Replace or Visual mode put a message on the last line. +--- The `hl-ModeMsg` highlight group determines the highlighting. +--- The option has no effect when 'cmdheight' is zero. +--- +--- @type boolean +vim.o.showmode = true +vim.o.smd = vim.o.showmode +vim.go.showmode = vim.o.showmode +vim.go.smd = vim.go.showmode + +--- The value of this option specifies when the line with tab page labels +--- will be displayed: +--- 0: never +--- 1: only if there are at least two tab pages +--- 2: always +--- This is both for the GUI and non-GUI implementation of the tab pages +--- line. +--- See `tab-page` for more information about tab pages. +--- +--- @type integer +vim.o.showtabline = 1 +vim.o.stal = vim.o.showtabline +vim.go.showtabline = vim.o.showtabline +vim.go.stal = vim.go.showtabline + +--- The minimal number of columns to scroll horizontally. Used only when +--- the 'wrap' option is off and the cursor is moved off of the screen. +--- When it is zero the cursor will be put in the middle of the screen. +--- When using a slow terminal set it to a large number or 0. Not used +--- for "zh" and "zl" commands. +--- +--- @type integer +vim.o.sidescroll = 1 +vim.o.ss = vim.o.sidescroll +vim.go.sidescroll = vim.o.sidescroll +vim.go.ss = vim.go.sidescroll + +--- The minimal number of screen columns to keep to the left and to the +--- right of the cursor if 'nowrap' is set. Setting this option to a +--- value greater than 0 while having `'sidescroll'` also at a non-zero +--- value makes some context visible in the line you are scrolling in +--- horizontally (except at beginning of the line). Setting this option +--- to a large value (like 999) has the effect of keeping the cursor +--- horizontally centered in the window, as long as one does not come too +--- close to the beginning of the line. +--- After using the local value, go back the global value with one of +--- these two: +--- ``` +--- setlocal sidescrolloff< +--- setlocal sidescrolloff=-1 +--- ``` +--- +--- Example: Try this together with 'sidescroll' and 'listchars' as +--- in the following example to never allow the cursor to move +--- onto the "extends" character: +--- ``` +--- :set nowrap sidescroll=1 listchars=extends:>,precedes:< +--- :set sidescrolloff=1 +--- ``` +--- +--- +--- @type integer +vim.o.sidescrolloff = 0 +vim.o.siso = vim.o.sidescrolloff +vim.wo.sidescrolloff = vim.o.sidescrolloff +vim.wo.siso = vim.wo.sidescrolloff +vim.go.sidescrolloff = vim.o.sidescrolloff +vim.go.siso = vim.go.sidescrolloff + +--- When and how to draw the signcolumn. Valid values are: +--- "auto" only when there is a sign to display +--- "auto:[1-9]" resize to accommodate multiple signs up to the +--- given number (maximum 9), e.g. "auto:4" +--- "auto:[1-8]-[2-9]" +--- resize to accommodate multiple signs up to the +--- given maximum number (maximum 9) while keeping +--- at least the given minimum (maximum 8) fixed +--- space. The minimum number should always be less +--- than the maximum number, e.g. "auto:2-5" +--- "no" never +--- "yes" always +--- "yes:[1-9]" always, with fixed space for signs up to the given +--- number (maximum 9), e.g. "yes:3" +--- "number" display signs in the 'number' column. If the number +--- column is not present, then behaves like "auto". +--- +--- @type string +vim.o.signcolumn = "auto" +vim.o.scl = vim.o.signcolumn +vim.wo.signcolumn = vim.o.signcolumn +vim.wo.scl = vim.wo.signcolumn + +--- Override the 'ignorecase' option if the search pattern contains upper +--- case characters. Only used when the search pattern is typed and +--- 'ignorecase' option is on. Used for the commands "/", "?", "n", "N", +--- ":g" and ":s". Not used for "*", "#", "gd", tag search, etc. After +--- "*" and "#" you can make 'smartcase' used by doing a "/" command, +--- recalling the search pattern from history and hitting <Enter>. +--- +--- @type boolean +vim.o.smartcase = false +vim.o.scs = vim.o.smartcase +vim.go.smartcase = vim.o.smartcase +vim.go.scs = vim.go.smartcase + +--- Do smart autoindenting when starting a new line. Works for C-like +--- programs, but can also be used for other languages. 'cindent' does +--- something like this, works better in most cases, but is more strict, +--- see `C-indenting`. When 'cindent' is on or 'indentexpr' is set, +--- setting 'si' has no effect. 'indentexpr' is a more advanced +--- alternative. +--- Normally 'autoindent' should also be on when using 'smartindent'. +--- An indent is automatically inserted: +--- - After a line ending in "{". +--- - After a line starting with a keyword from 'cinwords'. +--- - Before a line starting with "}" (only with the "O" command). +--- When typing '}' as the first character in a new line, that line is +--- given the same indent as the matching "{". +--- When typing '#' as the first character in a new line, the indent for +--- that line is removed, the '#' is put in the first column. The indent +--- is restored for the next line. If you don't want this, use this +--- mapping: ":inoremap # X^H#", where ^H is entered with CTRL-V CTRL-H. +--- When using the ">>" command, lines starting with '#' are not shifted +--- right. +--- +--- @type boolean +vim.o.smartindent = false +vim.o.si = vim.o.smartindent +vim.bo.smartindent = vim.o.smartindent +vim.bo.si = vim.bo.smartindent + +--- When on, a <Tab> in front of a line inserts blanks according to +--- 'shiftwidth'. 'tabstop' or 'softtabstop' is used in other places. A +--- <BS> will delete a 'shiftwidth' worth of space at the start of the +--- line. +--- When off, a <Tab> always inserts blanks according to 'tabstop' or +--- 'softtabstop'. 'shiftwidth' is only used for shifting text left or +--- right `shift-left-right`. +--- What gets inserted (a <Tab> or spaces) depends on the 'expandtab' +--- option. Also see `ins-expandtab`. When 'expandtab' is not set, the +--- number of spaces is minimized by using <Tab>s. +--- +--- @type boolean +vim.o.smarttab = true +vim.o.sta = vim.o.smarttab +vim.go.smarttab = vim.o.smarttab +vim.go.sta = vim.go.smarttab + +--- Scrolling works with screen lines. When 'wrap' is set and the first +--- line in the window wraps part of it may not be visible, as if it is +--- above the window. "<<<" is displayed at the start of the first line, +--- highlighted with `hl-NonText`. +--- You may also want to add "lastline" to the 'display' option to show as +--- much of the last line as possible. +--- NOTE: only partly implemented, currently works with CTRL-E, CTRL-Y +--- and scrolling with the mouse. +--- +--- @type boolean +vim.o.smoothscroll = false +vim.o.sms = vim.o.smoothscroll +vim.wo.smoothscroll = vim.o.smoothscroll +vim.wo.sms = vim.wo.smoothscroll + +--- Number of spaces that a <Tab> counts for while performing editing +--- operations, like inserting a <Tab> or using <BS>. It "feels" like +--- <Tab>s are being inserted, while in fact a mix of spaces and <Tab>s is +--- used. This is useful to keep the 'ts' setting at its standard value +--- of 8, while being able to edit like it is set to 'sts'. However, +--- commands like "x" still work on the actual characters. +--- When 'sts' is zero, this feature is off. +--- When 'sts' is negative, the value of 'shiftwidth' is used. +--- See also `ins-expandtab`. When 'expandtab' is not set, the number of +--- spaces is minimized by using <Tab>s. +--- The 'L' flag in 'cpoptions' changes how tabs are used when 'list' is +--- set. +--- +--- The value of 'softtabstop' will be ignored if `'varsofttabstop'` is set +--- to anything other than an empty string. +--- +--- @type integer +vim.o.softtabstop = 0 +vim.o.sts = vim.o.softtabstop +vim.bo.softtabstop = vim.o.softtabstop +vim.bo.sts = vim.bo.softtabstop + +--- When on spell checking will be done. See `spell`. +--- The languages are specified with 'spelllang'. +--- +--- @type boolean +vim.o.spell = false +vim.wo.spell = vim.o.spell + +--- Pattern to locate the end of a sentence. The following word will be +--- checked to start with a capital letter. If not then it is highlighted +--- with SpellCap `hl-SpellCap` (unless the word is also badly spelled). +--- When this check is not wanted make this option empty. +--- Only used when 'spell' is set. +--- Be careful with special characters, see `option-backslash` about +--- including spaces and backslashes. +--- To set this option automatically depending on the language, see +--- `set-spc-auto`. +--- +--- @type string +vim.o.spellcapcheck = "[.?!]\\_[\\])'\"\\t ]\\+" +vim.o.spc = vim.o.spellcapcheck +vim.bo.spellcapcheck = vim.o.spellcapcheck +vim.bo.spc = vim.bo.spellcapcheck + +--- Name of the word list file where words are added for the `zg` and `zw` +--- commands. It must end in ".{encoding}.add". You need to include the +--- path, otherwise the file is placed in the current directory. +--- The path may include characters from 'isfname', space, comma and '@'. +--- *E765* +--- It may also be a comma-separated list of names. A count before the +--- `zg` and `zw` commands can be used to access each. This allows using +--- a personal word list file and a project word list file. +--- When a word is added while this option is empty Vim will set it for +--- you: Using the first directory in 'runtimepath' that is writable. If +--- there is no "spell" directory yet it will be created. For the file +--- name the first language name that appears in 'spelllang' is used, +--- ignoring the region. +--- The resulting ".spl" file will be used for spell checking, it does not +--- have to appear in 'spelllang'. +--- Normally one file is used for all regions, but you can add the region +--- name if you want to. However, it will then only be used when +--- 'spellfile' is set to it, for entries in 'spelllang' only files +--- without region name will be found. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.spellfile = "" +vim.o.spf = vim.o.spellfile +vim.bo.spellfile = vim.o.spellfile +vim.bo.spf = vim.bo.spellfile + +--- A comma-separated list of word list names. When the 'spell' option is +--- on spellchecking will be done for these languages. Example: +--- ``` +--- set spelllang=en_us,nl,medical +--- ``` +--- This means US English, Dutch and medical words are recognized. Words +--- that are not recognized will be highlighted. +--- The word list name must consist of alphanumeric characters, a dash or +--- an underscore. It should not include a comma or dot. Using a dash is +--- recommended to separate the two letter language name from a +--- specification. Thus "en-rare" is used for rare English words. +--- A region name must come last and have the form "_xx", where "xx" is +--- the two-letter, lower case region name. You can use more than one +--- region by listing them: "en_us,en_ca" supports both US and Canadian +--- English, but not words specific for Australia, New Zealand or Great +--- Britain. (Note: currently en_au and en_nz dictionaries are older than +--- en_ca, en_gb and en_us). +--- If the name "cjk" is included East Asian characters are excluded from +--- spell checking. This is useful when editing text that also has Asian +--- words. +--- Note that the "medical" dictionary does not exist, it is just an +--- example of a longer name. +--- *E757* +--- As a special case the name of a .spl file can be given as-is. The +--- first "_xx" in the name is removed and used as the region name +--- (_xx is an underscore, two letters and followed by a non-letter). +--- This is mainly for testing purposes. You must make sure the correct +--- encoding is used, Vim doesn't check it. +--- How the related spell files are found is explained here: `spell-load`. +--- +--- If the `spellfile.vim` plugin is active and you use a language name +--- for which Vim cannot find the .spl file in 'runtimepath' the plugin +--- will ask you if you want to download the file. +--- +--- After this option has been set successfully, Vim will source the files +--- "spell/LANG.vim" in 'runtimepath'. "LANG" is the value of 'spelllang' +--- up to the first character that is not an ASCII letter or number and +--- not a dash. Also see `set-spc-auto`. +--- +--- @type string +vim.o.spelllang = "en" +vim.o.spl = vim.o.spelllang +vim.bo.spelllang = vim.o.spelllang +vim.bo.spl = vim.bo.spelllang + +--- A comma-separated list of options for spell checking: +--- camel When a word is CamelCased, assume "Cased" is a +--- separate word: every upper-case character in a word +--- that comes after a lower case character indicates the +--- start of a new word. +--- noplainbuffer Only spellcheck a buffer when 'syntax' is enabled, +--- or when extmarks are set within the buffer. Only +--- designated regions of the buffer are spellchecked in +--- this case. +--- +--- @type string +vim.o.spelloptions = "" +vim.o.spo = vim.o.spelloptions +vim.bo.spelloptions = vim.o.spelloptions +vim.bo.spo = vim.bo.spelloptions + +--- Methods used for spelling suggestions. Both for the `z=` command and +--- the `spellsuggest()` function. This is a comma-separated list of +--- items: +--- +--- best Internal method that works best for English. Finds +--- changes like "fast" and uses a bit of sound-a-like +--- scoring to improve the ordering. +--- +--- double Internal method that uses two methods and mixes the +--- results. The first method is "fast", the other method +--- computes how much the suggestion sounds like the bad +--- word. That only works when the language specifies +--- sound folding. Can be slow and doesn't always give +--- better results. +--- +--- fast Internal method that only checks for simple changes: +--- character inserts/deletes/swaps. Works well for +--- simple typing mistakes. +--- +--- {number} The maximum number of suggestions listed for `z=`. +--- Not used for `spellsuggest()`. The number of +--- suggestions is never more than the value of 'lines' +--- minus two. +--- +--- timeout:{millisec} Limit the time searching for suggestions to +--- {millisec} milli seconds. Applies to the following +--- methods. When omitted the limit is 5000. When +--- negative there is no limit. +--- +--- file:{filename} Read file {filename}, which must have two columns, +--- separated by a slash. The first column contains the +--- bad word, the second column the suggested good word. +--- Example: +--- theribal/terrible ~ +--- Use this for common mistakes that do not appear at the +--- top of the suggestion list with the internal methods. +--- Lines without a slash are ignored, use this for +--- comments. +--- The word in the second column must be correct, +--- otherwise it will not be used. Add the word to an +--- ".add" file if it is currently flagged as a spelling +--- mistake. +--- The file is used for all languages. +--- +--- expr:{expr} Evaluate expression {expr}. Use a function to avoid +--- trouble with spaces. `v:val` holds the badly spelled +--- word. The expression must evaluate to a List of +--- Lists, each with a suggestion and a score. +--- Example: +--- [['the', 33], ['that', 44]] ~ +--- Set 'verbose' and use `z=` to see the scores that the +--- internal methods use. A lower score is better. +--- This may invoke `spellsuggest()` if you temporarily +--- set 'spellsuggest' to exclude the "expr:" part. +--- Errors are silently ignored, unless you set the +--- 'verbose' option to a non-zero value. +--- +--- Only one of "best", "double" or "fast" may be used. The others may +--- appear several times in any order. Example: +--- ``` +--- :set sps=file:~/.config/nvim/sugg,best,expr:MySuggest() +--- ``` +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.spellsuggest = "best" +vim.o.sps = vim.o.spellsuggest +vim.go.spellsuggest = vim.o.spellsuggest +vim.go.sps = vim.go.spellsuggest + +--- When on, splitting a window will put the new window below the current +--- one. `:split` +--- +--- @type boolean +vim.o.splitbelow = false +vim.o.sb = vim.o.splitbelow +vim.go.splitbelow = vim.o.splitbelow +vim.go.sb = vim.go.splitbelow + +--- The value of this option determines the scroll behavior when opening, +--- closing or resizing horizontal splits. +--- +--- Possible values are: +--- cursor Keep the same relative cursor position. +--- screen Keep the text on the same screen line. +--- topline Keep the topline the same. +--- +--- For the "screen" and "topline" values, the cursor position will be +--- changed when necessary. In this case, the jumplist will be populated +--- with the previous cursor position. For "screen", the text cannot always +--- be kept on the same screen line when 'wrap' is enabled. +--- +--- @type string +vim.o.splitkeep = "cursor" +vim.o.spk = vim.o.splitkeep +vim.go.splitkeep = vim.o.splitkeep +vim.go.spk = vim.go.splitkeep + +--- When on, splitting a window will put the new window right of the +--- current one. `:vsplit` +--- +--- @type boolean +vim.o.splitright = false +vim.o.spr = vim.o.splitright +vim.go.splitright = vim.o.splitright +vim.go.spr = vim.go.splitright + +--- When "on" the commands listed below move the cursor to the first +--- non-blank of the line. When off the cursor is kept in the same column +--- (if possible). This applies to the commands: +--- - CTRL-D, CTRL-U, CTRL-B, CTRL-F, "G", "H", "M", "L", "gg" +--- - "d", "<<" and ">>" with a linewise operator +--- - "%" with a count +--- - buffer changing commands (CTRL-^, :bnext, :bNext, etc.) +--- - Ex commands that only have a line number, e.g., ":25" or ":+". +--- In case of buffer changing commands the cursor is placed at the column +--- where it was the last time the buffer was edited. +--- +--- @type boolean +vim.o.startofline = false +vim.o.sol = vim.o.startofline +vim.go.startofline = vim.o.startofline +vim.go.sol = vim.go.startofline + +--- EXPERIMENTAL +--- When non-empty, this option determines the content of the area to the +--- side of a window, normally containing the fold, sign and number columns. +--- The format of this option is like that of 'statusline'. +--- +--- Some of the items from the 'statusline' format are different for +--- 'statuscolumn': +--- +--- %l line number of currently drawn line +--- %r relative line number of currently drawn line +--- %s sign column for currently drawn line +--- %C fold column for currently drawn line +--- +--- NOTE: To draw the sign and fold columns, their items must be included in +--- 'statuscolumn'. Even when they are not included, the status column width +--- will adapt to the 'signcolumn' and 'foldcolumn' width. +--- +--- The `v:lnum` variable holds the line number to be drawn. +--- The `v:relnum` variable holds the relative line number to be drawn. +--- The `v:virtnum` variable is negative when drawing virtual lines, zero +--- when drawing the actual buffer line, and positive when +--- drawing the wrapped part of a buffer line. +--- +--- NOTE: The %@ click execute function item is supported as well but the +--- specified function will be the same for each row in the same column. +--- It cannot be switched out through a dynamic 'statuscolumn' format, the +--- handler should be written with this in mind. +--- +--- Examples: +--- +--- ```vim +--- " Relative number with bar separator and click handlers: +--- :set statuscolumn=%@SignCb@%s%=%T%@NumCb@%r│%T +--- +--- " Right aligned relative cursor line number: +--- :let &stc='%=%{v:relnum?v:relnum:v:lnum} ' +--- +--- " Line numbers in hexadecimal for non wrapped part of lines: +--- :let &stc='%=%{v:virtnum>0?"":printf("%x",v:lnum)} ' +--- +--- " Human readable line numbers with thousands separator: +--- :let &stc='%{substitute(v:lnum,"\\d\\zs\\ze\\' +--- . '%(\\d\\d\\d\\)\\+$",",","g")}' +--- +--- " Both relative and absolute line numbers with different +--- " highlighting for odd and even relative numbers: +--- :let &stc='%#NonText#%{&nu?v:lnum:""}' . +--- '%=%{&rnu&&(v:lnum%2)?"\ ".v:relnum:""}' . +--- '%#LineNr#%{&rnu&&!(v:lnum%2)?"\ ".v:relnum:""}' +--- ``` +--- WARNING: this expression is evaluated for each screen line so defining +--- an expensive expression can negatively affect render performance. +--- +--- @type string +vim.o.statuscolumn = "" +vim.o.stc = vim.o.statuscolumn +vim.wo.statuscolumn = vim.o.statuscolumn +vim.wo.stc = vim.wo.statuscolumn + +--- When non-empty, this option determines the content of the status line. +--- Also see `status-line`. +--- +--- The option consists of printf style '%' items interspersed with +--- normal text. Each status line item is of the form: +--- %-0{minwid}.{maxwid}{item} +--- All fields except the {item} are optional. A single percent sign can +--- be given as "%%". +--- +--- When the option starts with "%!" then it is used as an expression, +--- evaluated and the result is used as the option value. Example: +--- ``` +--- :set statusline=%!MyStatusLine() +--- ``` +--- The *g:statusline_winid* variable will be set to the `window-ID` of the +--- window that the status line belongs to. +--- The result can contain %{} items that will be evaluated too. +--- Note that the "%!" expression is evaluated in the context of the +--- current window and buffer, while %{} items are evaluated in the +--- context of the window that the statusline belongs to. +--- +--- When there is error while evaluating the option then it will be made +--- empty to avoid further errors. Otherwise screen updating would loop. +--- When the result contains unprintable characters the result is +--- unpredictable. +--- +--- Note that the only effect of 'ruler' when this option is set (and +--- 'laststatus' is 2 or 3) is controlling the output of `CTRL-G`. +--- +--- field meaning ~ +--- - Left justify the item. The default is right justified +--- when minwid is larger than the length of the item. +--- 0 Leading zeroes in numeric items. Overridden by "-". +--- minwid Minimum width of the item, padding as set by "-" & "0". +--- Value must be 50 or less. +--- maxwid Maximum width of the item. Truncation occurs with a "<" +--- on the left for text items. Numeric items will be +--- shifted down to maxwid-2 digits followed by ">"number +--- where number is the amount of missing digits, much like +--- an exponential notation. +--- item A one letter code as described below. +--- +--- Following is a description of the possible statusline items. The +--- second character in "item" is the type: +--- N for number +--- S for string +--- F for flags as described below +--- - not applicable +--- +--- item meaning ~ +--- f S Path to the file in the buffer, as typed or relative to current +--- directory. +--- F S Full path to the file in the buffer. +--- t S File name (tail) of file in the buffer. +--- m F Modified flag, text is "[+]"; "[-]" if 'modifiable' is off. +--- M F Modified flag, text is ",+" or ",-". +--- r F Readonly flag, text is "[RO]". +--- R F Readonly flag, text is ",RO". +--- h F Help buffer flag, text is "[help]". +--- H F Help buffer flag, text is ",HLP". +--- w F Preview window flag, text is "[Preview]". +--- W F Preview window flag, text is ",PRV". +--- y F Type of file in the buffer, e.g., "[vim]". See 'filetype'. +--- Y F Type of file in the buffer, e.g., ",VIM". See 'filetype'. +--- q S "[Quickfix List]", "[Location List]" or empty. +--- k S Value of "b:keymap_name" or 'keymap' when `:lmap` mappings are +--- being used: "<keymap>" +--- n N Buffer number. +--- b N Value of character under cursor. +--- B N As above, in hexadecimal. +--- o N Byte number in file of byte under cursor, first byte is 1. +--- Mnemonic: Offset from start of file (with one added) +--- O N As above, in hexadecimal. +--- l N Line number. +--- L N Number of lines in buffer. +--- c N Column number (byte index). +--- v N Virtual column number (screen column). +--- V N Virtual column number as -{num}. Not displayed if equal to 'c'. +--- p N Percentage through file in lines as in `CTRL-G`. +--- P S Percentage through file of displayed window. This is like the +--- percentage described for 'ruler'. Always 3 in length, unless +--- translated. +--- S S 'showcmd' content, see 'showcmdloc'. +--- a S Argument list status as in default title. ({current} of {max}) +--- Empty if the argument file count is zero or one. +--- { NF Evaluate expression between "%{" and "}" and substitute result. +--- Note that there is no "%" before the closing "}". The +--- expression cannot contain a "}" character, call a function to +--- work around that. See `stl-%{` below. +--- `{%` - This is almost same as "{" except the result of the expression is +--- re-evaluated as a statusline format string. Thus if the +--- return value of expr contains "%" items they will get expanded. +--- The expression can contain the "}" character, the end of +--- expression is denoted by "%}". +--- For example: +--- ``` +--- func! Stl_filename() abort +--- return "%t" +--- endfunc +--- ``` +--- `stl=%{Stl_filename()}` results in `"%t"` +--- `stl=%{%Stl_filename()%}` results in `"Name of current file"` +--- %} - End of "{%" expression +--- ( - Start of item group. Can be used for setting the width and +--- alignment of a section. Must be followed by %) somewhere. +--- ) - End of item group. No width fields allowed. +--- T N For 'tabline': start of tab page N label. Use %T or %X to end +--- the label. Clicking this label with left mouse button switches +--- to the specified tab page. +--- X N For 'tabline': start of close tab N label. Use %X or %T to end +--- the label, e.g.: %3Xclose%X. Use %999X for a "close current +--- tab" label. Clicking this label with left mouse button closes +--- specified tab page. +--- @ N Start of execute function label. Use %X or %T to +--- end the label, e.g.: %10@SwitchBuffer@foo.c%X. Clicking this +--- label runs specified function: in the example when clicking once +--- using left mouse button on "foo.c" "SwitchBuffer(10, 1, 'l', +--- ' ')" expression will be run. Function receives the +--- following arguments in order: +--- 1. minwid field value or zero if no N was specified +--- 2. number of mouse clicks to detect multiple clicks +--- 3. mouse button used: "l", "r" or "m" for left, right or middle +--- button respectively; one should not rely on third argument +--- being only "l", "r" or "m": any other non-empty string value +--- that contains only ASCII lower case letters may be expected +--- for other mouse buttons +--- 4. modifiers pressed: string which contains "s" if shift +--- modifier was pressed, "c" for control, "a" for alt and "m" +--- for meta; currently if modifier is not pressed string +--- contains space instead, but one should not rely on presence +--- of spaces or specific order of modifiers: use `stridx()` to +--- test whether some modifier is present; string is guaranteed +--- to contain only ASCII letters and spaces, one letter per +--- modifier; "?" modifier may also be present, but its presence +--- is a bug that denotes that new mouse button recognition was +--- added without modifying code that reacts on mouse clicks on +--- this label. +--- Use `getmousepos()`.winid in the specified function to get the +--- corresponding window id of the clicked item. +--- \< - Where to truncate line if too long. Default is at the start. +--- No width fields allowed. +--- = - Separation point between alignment sections. Each section will +--- be separated by an equal number of spaces. With one %= what +--- comes after it will be right-aligned. With two %= there is a +--- middle part, with white space left and right of it. +--- No width fields allowed. +--- # - Set highlight group. The name must follow and then a # again. +--- Thus use %#HLname# for highlight group HLname. The same +--- highlighting is used, also for the statusline of non-current +--- windows. +--- * - Set highlight group to User{N}, where {N} is taken from the +--- minwid field, e.g. %1*. Restore normal highlight with %* or %0*. +--- The difference between User{N} and StatusLine will be applied to +--- StatusLineNC for the statusline of non-current windows. +--- The number N must be between 1 and 9. See `hl-User1..9` +--- +--- When displaying a flag, Vim removes the leading comma, if any, when +--- that flag comes right after plaintext. This will make a nice display +--- when flags are used like in the examples below. +--- +--- When all items in a group becomes an empty string (i.e. flags that are +--- not set) and a minwid is not set for the group, the whole group will +--- become empty. This will make a group like the following disappear +--- completely from the statusline when none of the flags are set. +--- ``` +--- :set statusline=...%(\ [%M%R%H]%)... +--- ``` +--- Beware that an expression is evaluated each and every time the status +--- line is displayed. +--- *stl-%{* *g:actual_curbuf* *g:actual_curwin* +--- While evaluating %{} the current buffer and current window will be set +--- temporarily to that of the window (and buffer) whose statusline is +--- currently being drawn. The expression will evaluate in this context. +--- The variable "g:actual_curbuf" is set to the `bufnr()` number of the +--- real current buffer and "g:actual_curwin" to the `window-ID` of the +--- real current window. These values are strings. +--- +--- The 'statusline' option will be evaluated in the `sandbox` if set from +--- a modeline, see `sandbox-option`. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- It is not allowed to change text or jump to another window while +--- evaluating 'statusline' `textlock`. +--- +--- If the statusline is not updated when you want it (e.g., after setting +--- a variable that's used in an expression), you can force an update by +--- using `:redrawstatus`. +--- +--- A result of all digits is regarded a number for display purposes. +--- Otherwise the result is taken as flag text and applied to the rules +--- described above. +--- +--- Watch out for errors in expressions. They may render Vim unusable! +--- If you are stuck, hold down ':' or 'Q' to get a prompt, then quit and +--- edit your vimrc or whatever with "vim --clean" to get it right. +--- +--- Examples: +--- Emulate standard status line with 'ruler' set +--- ``` +--- :set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P +--- ``` +--- Similar, but add ASCII value of char under the cursor (like "ga") +--- ``` +--- :set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P +--- ``` +--- Display byte count and byte value, modified flag in red. +--- ``` +--- :set statusline=%<%f%=\ [%1*%M%*%n%R%H]\ %-19(%3l,%02c%03V%)%O'%02b' +--- :hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red +--- ``` +--- Display a ,GZ flag if a compressed file is loaded +--- ``` +--- :set statusline=...%r%{VarExists('b:gzflag','\ [GZ]')}%h... +--- ``` +--- In the `:autocmd`'s: +--- ``` +--- :let b:gzflag = 1 +--- ``` +--- And: +--- ``` +--- :unlet b:gzflag +--- ``` +--- And define this function: +--- ``` +--- :function VarExists(var, val) +--- : if exists(a:var) | return a:val | else | return '' | endif +--- :endfunction +--- ``` +--- +--- +--- @type string +vim.o.statusline = "" +vim.o.stl = vim.o.statusline +vim.wo.statusline = vim.o.statusline +vim.wo.stl = vim.wo.statusline +vim.go.statusline = vim.o.statusline +vim.go.stl = vim.go.statusline + +--- Files with these suffixes get a lower priority when multiple files +--- match a wildcard. See `suffixes`. Commas can be used to separate the +--- suffixes. Spaces after the comma are ignored. A dot is also seen as +--- the start of a suffix. To avoid a dot or comma being recognized as a +--- separator, precede it with a backslash (see `option-backslash` about +--- including spaces and backslashes). +--- See 'wildignore' for completely ignoring files. +--- The use of `:set+=` and `:set-=` is preferred when adding or removing +--- suffixes from the list. This avoids problems when a future version +--- uses another default. +--- +--- @type string +vim.o.suffixes = ".bak,~,.o,.h,.info,.swp,.obj" +vim.o.su = vim.o.suffixes +vim.go.suffixes = vim.o.suffixes +vim.go.su = vim.go.suffixes + +--- Comma-separated list of suffixes, which are used when searching for a +--- file for the "gf", "[I", etc. commands. Example: +--- ``` +--- :set suffixesadd=.java +--- ``` +--- +--- +--- @type string +vim.o.suffixesadd = "" +vim.o.sua = vim.o.suffixesadd +vim.bo.suffixesadd = vim.o.suffixesadd +vim.bo.sua = vim.bo.suffixesadd + +--- Use a swapfile for the buffer. This option can be reset when a +--- swapfile is not wanted for a specific buffer. For example, with +--- confidential information that even root must not be able to access. +--- Careful: All text will be in memory: +--- - Don't use this for big files. +--- - Recovery will be impossible! +--- A swapfile will only be present when `'updatecount'` is non-zero and +--- 'swapfile' is set. +--- When 'swapfile' is reset, the swap file for the current buffer is +--- immediately deleted. When 'swapfile' is set, and 'updatecount' is +--- non-zero, a swap file is immediately created. +--- Also see `swap-file`. +--- If you want to open a new buffer without creating a swap file for it, +--- use the `:noswapfile` modifier. +--- See 'directory' for where the swap file is created. +--- +--- This option is used together with 'bufhidden' and 'buftype' to +--- specify special kinds of buffers. See `special-buffers`. +--- +--- @type boolean +vim.o.swapfile = true +vim.o.swf = vim.o.swapfile +vim.bo.swapfile = vim.o.swapfile +vim.bo.swf = vim.bo.swapfile + +--- This option controls the behavior when switching between buffers. +--- This option is checked, when +--- - jumping to errors with the `quickfix` commands (`:cc`, `:cn`, `:cp`, +--- etc.). +--- - jumping to a tag using the `:stag` command. +--- - opening a file using the `CTRL-W_f` or `CTRL-W_F` command. +--- - jumping to a buffer using a buffer split command (e.g. `:sbuffer`, +--- `:sbnext`, or `:sbrewind`). +--- Possible values (comma-separated list): +--- useopen If included, jump to the first open window in the +--- current tab page that contains the specified buffer +--- (if there is one). Otherwise: Do not examine other +--- windows. +--- usetab Like "useopen", but also consider windows in other tab +--- pages. +--- split If included, split the current window before loading +--- a buffer for a `quickfix` command that display errors. +--- Otherwise: do not split, use current window (when used +--- in the quickfix window: the previously used window or +--- split if there is no other window). +--- vsplit Just like "split" but split vertically. +--- newtab Like "split", but open a new tab page. Overrules +--- "split" when both are present. +--- uselast If included, jump to the previously used window when +--- jumping to errors with `quickfix` commands. +--- +--- @type string +vim.o.switchbuf = "uselast" +vim.o.swb = vim.o.switchbuf +vim.go.switchbuf = vim.o.switchbuf +vim.go.swb = vim.go.switchbuf + +--- Maximum column in which to search for syntax items. In long lines the +--- text after this column is not highlighted and following lines may not +--- be highlighted correctly, because the syntax state is cleared. +--- This helps to avoid very slow redrawing for an XML file that is one +--- long line. +--- Set to zero to remove the limit. +--- +--- @type integer +vim.o.synmaxcol = 3000 +vim.o.smc = vim.o.synmaxcol +vim.bo.synmaxcol = vim.o.synmaxcol +vim.bo.smc = vim.bo.synmaxcol + +--- When this option is set, the syntax with this name is loaded, unless +--- syntax highlighting has been switched off with ":syntax off". +--- Otherwise this option does not always reflect the current syntax (the +--- b:current_syntax variable does). +--- This option is most useful in a modeline, for a file which syntax is +--- not automatically recognized. Example, in an IDL file: +--- ``` +--- /* vim: set syntax=idl : */ +--- ``` +--- When a dot appears in the value then this separates two filetype +--- names. Example: +--- ``` +--- /* vim: set syntax=c.doxygen : */ +--- ``` +--- This will use the "c" syntax first, then the "doxygen" syntax. +--- Note that the second one must be prepared to be loaded as an addition, +--- otherwise it will be skipped. More than one dot may appear. +--- To switch off syntax highlighting for the current file, use: +--- ``` +--- :set syntax=OFF +--- ``` +--- To switch syntax highlighting on according to the current value of the +--- 'filetype' option: +--- ``` +--- :set syntax=ON +--- ``` +--- What actually happens when setting the 'syntax' option is that the +--- Syntax autocommand event is triggered with the value as argument. +--- This option is not copied to another buffer, independent of the 's' or +--- 'S' flag in 'cpoptions'. +--- Only normal file name characters can be used, `/\*?[|<>` are illegal. +--- +--- @type string +vim.o.syntax = "" +vim.o.syn = vim.o.syntax +vim.bo.syntax = vim.o.syntax +vim.bo.syn = vim.bo.syntax + +--- When non-empty, this option determines the content of the tab pages +--- line at the top of the Vim window. When empty Vim will use a default +--- tab pages line. See `setting-tabline` for more info. +--- +--- The tab pages line only appears as specified with the 'showtabline' +--- option and only when there is no GUI tab line. When 'e' is in +--- 'guioptions' and the GUI supports a tab line 'guitablabel' is used +--- instead. Note that the two tab pages lines are very different. +--- +--- The value is evaluated like with 'statusline'. You can use +--- `tabpagenr()`, `tabpagewinnr()` and `tabpagebuflist()` to figure out +--- the text to be displayed. Use "%1T" for the first label, "%2T" for +--- the second one, etc. Use "%X" items for closing labels. +--- +--- When changing something that is used in 'tabline' that does not +--- trigger it to be updated, use `:redrawtabline`. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- Keep in mind that only one of the tab pages is the current one, others +--- are invisible and you can't jump to their windows. +--- +--- @type string +vim.o.tabline = "" +vim.o.tal = vim.o.tabline +vim.go.tabline = vim.o.tabline +vim.go.tal = vim.go.tabline + +--- Maximum number of tab pages to be opened by the `-p` command line +--- argument or the ":tab all" command. `tabpage` +--- +--- @type integer +vim.o.tabpagemax = 50 +vim.o.tpm = vim.o.tabpagemax +vim.go.tabpagemax = vim.o.tabpagemax +vim.go.tpm = vim.go.tabpagemax + +--- Number of spaces that a <Tab> in the file counts for. Also see +--- the `:retab` command, and the 'softtabstop' option. +--- +--- Note: Setting 'tabstop' to any other value than 8 can make your file +--- appear wrong in many places. +--- The value must be more than 0 and less than 10000. +--- +--- There are four main ways to use tabs in Vim: +--- 1. Always keep 'tabstop' at 8, set 'softtabstop' and 'shiftwidth' to 4 +--- (or 3 or whatever you prefer) and use 'noexpandtab'. Then Vim +--- will use a mix of tabs and spaces, but typing <Tab> and <BS> will +--- behave like a tab appears every 4 (or 3) characters. +--- This is the recommended way, the file will look the same with other +--- tools and when listing it in a terminal. +--- 2. Set 'softtabstop' and 'shiftwidth' to whatever you prefer and use +--- 'expandtab'. This way you will always insert spaces. The +--- formatting will never be messed up when 'tabstop' is changed (leave +--- it at 8 just in case). The file will be a bit larger. +--- You do need to check if no Tabs exist in the file. You can get rid +--- of them by first setting 'expandtab' and using `%retab!`, making +--- sure the value of 'tabstop' is set correctly. +--- 3. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use +--- 'expandtab'. This way you will always insert spaces. The +--- formatting will never be messed up when 'tabstop' is changed. +--- You do need to check if no Tabs exist in the file, just like in the +--- item just above. +--- 4. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use a +--- `modeline` to set these values when editing the file again. Only +--- works when using Vim to edit the file, other tools assume a tabstop +--- is worth 8 spaces. +--- 5. Always set 'tabstop' and 'shiftwidth' to the same value, and +--- 'noexpandtab'. This should then work (for initial indents only) +--- for any tabstop setting that people use. It might be nice to have +--- tabs after the first non-blank inserted as spaces if you do this +--- though. Otherwise aligned comments will be wrong when 'tabstop' is +--- changed. +--- +--- The value of 'tabstop' will be ignored if `'vartabstop'` is set to +--- anything other than an empty string. +--- +--- @type integer +vim.o.tabstop = 8 +vim.o.ts = vim.o.tabstop +vim.bo.tabstop = vim.o.tabstop +vim.bo.ts = vim.bo.tabstop + +--- When searching for a tag (e.g., for the `:ta` command), Vim can either +--- use a binary search or a linear search in a tags file. Binary +--- searching makes searching for a tag a LOT faster, but a linear search +--- will find more tags if the tags file wasn't properly sorted. +--- Vim normally assumes that your tags files are sorted, or indicate that +--- they are not sorted. Only when this is not the case does the +--- 'tagbsearch' option need to be switched off. +--- +--- When 'tagbsearch' is on, binary searching is first used in the tags +--- files. In certain situations, Vim will do a linear search instead for +--- certain files, or retry all files with a linear search. When +--- 'tagbsearch' is off, only a linear search is done. +--- +--- Linear searching is done anyway, for one file, when Vim finds a line +--- at the start of the file indicating that it's not sorted: +--- ``` +--- !_TAG_FILE_SORTED 0 /some comment/ +--- ``` +--- [The whitespace before and after the '0' must be a single <Tab>] +--- +--- When a binary search was done and no match was found in any of the +--- files listed in 'tags', and case is ignored or a pattern is used +--- instead of a normal tag name, a retry is done with a linear search. +--- Tags in unsorted tags files, and matches with different case will only +--- be found in the retry. +--- +--- If a tag file indicates that it is case-fold sorted, the second, +--- linear search can be avoided when case is ignored. Use a value of '2' +--- in the "!_TAG_FILE_SORTED" line for this. A tag file can be case-fold +--- sorted with the -f switch to "sort" in most unices, as in the command: +--- "sort -f -o tags tags". For Universal ctags and Exuberant ctags +--- version 5.x or higher (at least 5.5) the --sort=foldcase switch can be +--- used for this as well. Note that case must be folded to uppercase for +--- this to work. +--- +--- By default, tag searches are case-sensitive. Case is ignored when +--- 'ignorecase' is set and 'tagcase' is "followic", or when 'tagcase' is +--- "ignore". +--- Also when 'tagcase' is "followscs" and 'smartcase' is set, or +--- 'tagcase' is "smart", and the pattern contains only lowercase +--- characters. +--- +--- When 'tagbsearch' is off, tags searching is slower when a full match +--- exists, but faster when no full match exists. Tags in unsorted tags +--- files may only be found with 'tagbsearch' off. +--- When the tags file is not sorted, or sorted in a wrong way (not on +--- ASCII byte value), 'tagbsearch' should be off, or the line given above +--- must be included in the tags file. +--- This option doesn't affect commands that find all matching tags (e.g., +--- command-line completion and ":help"). +--- +--- @type boolean +vim.o.tagbsearch = true +vim.o.tbs = vim.o.tagbsearch +vim.go.tagbsearch = vim.o.tagbsearch +vim.go.tbs = vim.go.tagbsearch + +--- This option specifies how case is handled when searching the tags +--- file: +--- followic Follow the 'ignorecase' option +--- followscs Follow the 'smartcase' and 'ignorecase' options +--- ignore Ignore case +--- match Match case +--- smart Ignore case unless an upper case letter is used +--- +--- @type string +vim.o.tagcase = "followic" +vim.o.tc = vim.o.tagcase +vim.bo.tagcase = vim.o.tagcase +vim.bo.tc = vim.bo.tagcase +vim.go.tagcase = vim.o.tagcase +vim.go.tc = vim.go.tagcase + +--- This option specifies a function to be used to perform tag searches. +--- The function gets the tag pattern and should return a List of matching +--- tags. See `tag-function` for an explanation of how to write the +--- function and an example. The value can be the name of a function, a +--- `lambda` or a `Funcref`. See `option-value-function` for more +--- information. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.tagfunc = "" +vim.o.tfu = vim.o.tagfunc +vim.bo.tagfunc = vim.o.tagfunc +vim.bo.tfu = vim.bo.tagfunc + +--- If non-zero, tags are significant up to this number of characters. +--- +--- @type integer +vim.o.taglength = 0 +vim.o.tl = vim.o.taglength +vim.go.taglength = vim.o.taglength +vim.go.tl = vim.go.taglength + +--- If on and using a tags file in another directory, file names in that +--- tags file are relative to the directory where the tags file is. +--- +--- @type boolean +vim.o.tagrelative = true +vim.o.tr = vim.o.tagrelative +vim.go.tagrelative = vim.o.tagrelative +vim.go.tr = vim.go.tagrelative + +--- Filenames for the tag command, separated by spaces or commas. To +--- include a space or comma in a file name, precede it with backslashes +--- (see `option-backslash` about including spaces/commas and backslashes). +--- When a file name starts with "./", the '.' is replaced with the path +--- of the current file. But only when the 'd' flag is not included in +--- 'cpoptions'. Environment variables are expanded `:set_env`. Also see +--- `tags-option`. +--- "*", "**" and other wildcards can be used to search for tags files in +--- a directory tree. See `file-searching`. E.g., "/lib/**/tags" will +--- find all files named "tags" below "/lib". The filename itself cannot +--- contain wildcards, it is used as-is. E.g., "/lib/**/tags?" will find +--- files called "tags?". +--- The `tagfiles()` function can be used to get a list of the file names +--- actually used. +--- The use of `:set+=` and `:set-=` is preferred when adding or removing +--- file names from the list. This avoids problems when a future version +--- uses another default. +--- +--- @type string +vim.o.tags = "./tags;,tags" +vim.o.tag = vim.o.tags +vim.bo.tags = vim.o.tags +vim.bo.tag = vim.bo.tags +vim.go.tags = vim.o.tags +vim.go.tag = vim.go.tags + +--- When on, the `tagstack` is used normally. When off, a ":tag" or +--- ":tselect" command with an argument will not push the tag onto the +--- tagstack. A following ":tag" without an argument, a ":pop" command or +--- any other command that uses the tagstack will use the unmodified +--- tagstack, but does change the pointer to the active entry. +--- Resetting this option is useful when using a ":tag" command in a +--- mapping which should not change the tagstack. +--- +--- @type boolean +vim.o.tagstack = true +vim.o.tgst = vim.o.tagstack +vim.go.tagstack = vim.o.tagstack +vim.go.tgst = vim.go.tagstack + +--- The terminal is in charge of Bi-directionality of text (as specified +--- by Unicode). The terminal is also expected to do the required shaping +--- that some languages (such as Arabic) require. +--- Setting this option implies that 'rightleft' will not be set when +--- 'arabic' is set and the value of 'arabicshape' will be ignored. +--- Note that setting 'termbidi' has the immediate effect that +--- 'arabicshape' is ignored, but 'rightleft' isn't changed automatically. +--- For further details see `arabic.txt`. +--- +--- @type boolean +vim.o.termbidi = false +vim.o.tbidi = vim.o.termbidi +vim.go.termbidi = vim.o.termbidi +vim.go.tbidi = vim.go.termbidi + +--- Enables 24-bit RGB color in the `TUI`. Uses "gui" `:highlight` +--- attributes instead of "cterm" attributes. `guifg` +--- Requires an ISO-8613-3 compatible terminal. +--- +--- @type boolean +vim.o.termguicolors = false +vim.o.tgc = vim.o.termguicolors +vim.go.termguicolors = vim.o.termguicolors +vim.go.tgc = vim.go.termguicolors + +--- A comma-separated list of options for specifying control characters +--- to be removed from the text pasted into the terminal window. The +--- supported values are: +--- +--- BS Backspace +--- +--- HT TAB +--- +--- FF Form feed +--- +--- ESC Escape +--- +--- DEL DEL +--- +--- C0 Other control characters, excluding Line feed and +--- Carriage return < ' ' +--- +--- C1 Control characters 0x80...0x9F +--- +--- @type string +vim.o.termpastefilter = "BS,HT,ESC,DEL" +vim.o.tpf = vim.o.termpastefilter +vim.go.termpastefilter = vim.o.termpastefilter +vim.go.tpf = vim.go.termpastefilter + +--- If the host terminal supports it, buffer all screen updates +--- made during a redraw cycle so that each screen is displayed in +--- the terminal all at once. This can prevent tearing or flickering +--- when the terminal updates faster than Nvim can redraw. +--- +--- @type boolean +vim.o.termsync = true +vim.go.termsync = vim.o.termsync + +--- Maximum width of text that is being inserted. A longer line will be +--- broken after white space to get this width. A zero value disables +--- this. +--- When 'textwidth' is zero, 'wrapmargin' may be used. See also +--- 'formatoptions' and `ins-textwidth`. +--- When 'formatexpr' is set it will be used to break the line. +--- +--- @type integer +vim.o.textwidth = 0 +vim.o.tw = vim.o.textwidth +vim.bo.textwidth = vim.o.textwidth +vim.bo.tw = vim.bo.textwidth + +--- List of file names, separated by commas, that are used to lookup words +--- for thesaurus completion commands `i_CTRL-X_CTRL-T`. See +--- `compl-thesaurus`. +--- +--- This option is not used if 'thesaurusfunc' is set, either for the +--- buffer or globally. +--- +--- To include a comma in a file name precede it with a backslash. Spaces +--- after a comma are ignored, otherwise spaces are included in the file +--- name. See `option-backslash` about using backslashes. The use of +--- `:set+=` and `:set-=` is preferred when adding or removing directories +--- from the list. This avoids problems when a future version uses +--- another default. Backticks cannot be used in this option for security +--- reasons. +--- +--- @type string +vim.o.thesaurus = "" +vim.o.tsr = vim.o.thesaurus +vim.bo.thesaurus = vim.o.thesaurus +vim.bo.tsr = vim.bo.thesaurus +vim.go.thesaurus = vim.o.thesaurus +vim.go.tsr = vim.go.thesaurus + +--- This option specifies a function to be used for thesaurus completion +--- with CTRL-X CTRL-T. `i_CTRL-X_CTRL-T` See `compl-thesaurusfunc`. +--- The value can be the name of a function, a `lambda` or a `Funcref`. +--- See `option-value-function` for more information. +--- +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.thesaurusfunc = "" +vim.o.tsrfu = vim.o.thesaurusfunc +vim.bo.thesaurusfunc = vim.o.thesaurusfunc +vim.bo.tsrfu = vim.bo.thesaurusfunc +vim.go.thesaurusfunc = vim.o.thesaurusfunc +vim.go.tsrfu = vim.go.thesaurusfunc + +--- When on: The tilde command "~" behaves like an operator. +--- +--- @type boolean +vim.o.tildeop = false +vim.o.top = vim.o.tildeop +vim.go.tildeop = vim.o.tildeop +vim.go.top = vim.go.tildeop + +--- This option and 'timeoutlen' determine the behavior when part of a +--- mapped key sequence has been received. For example, if <c-f> is +--- pressed and 'timeout' is set, Nvim will wait 'timeoutlen' milliseconds +--- for any key that can follow <c-f> in a mapping. +--- +--- @type boolean +vim.o.timeout = true +vim.o.to = vim.o.timeout +vim.go.timeout = vim.o.timeout +vim.go.to = vim.go.timeout + +--- Time in milliseconds to wait for a mapped sequence to complete. +--- +--- @type integer +vim.o.timeoutlen = 1000 +vim.o.tm = vim.o.timeoutlen +vim.go.timeoutlen = vim.o.timeoutlen +vim.go.tm = vim.go.timeoutlen + +--- When on, the title of the window will be set to the value of +--- 'titlestring' (if it is not empty), or to: +--- filename [+=-] (path) - NVIM +--- Where: +--- filename the name of the file being edited +--- - indicates the file cannot be modified, 'ma' off +--- + indicates the file was modified +--- = indicates the file is read-only +--- =+ indicates the file is read-only and modified +--- (path) is the path of the file being edited +--- - NVIM the server name `v:servername` or "NVIM" +--- +--- @type boolean +vim.o.title = false +vim.go.title = vim.o.title + +--- Gives the percentage of 'columns' to use for the length of the window +--- title. When the title is longer, only the end of the path name is +--- shown. A '<' character before the path name is used to indicate this. +--- Using a percentage makes this adapt to the width of the window. But +--- it won't work perfectly, because the actual number of characters +--- available also depends on the font used and other things in the title +--- bar. When 'titlelen' is zero the full path is used. Otherwise, +--- values from 1 to 30000 percent can be used. +--- 'titlelen' is also used for the 'titlestring' option. +--- +--- @type integer +vim.o.titlelen = 85 +vim.go.titlelen = vim.o.titlelen + +--- If not empty, this option will be used to set the window title when +--- exiting. Only if 'title' is enabled. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.titleold = "" +vim.go.titleold = vim.o.titleold + +--- When this option is not empty, it will be used for the title of the +--- window. This happens only when the 'title' option is on. +--- +--- When this option contains printf-style '%' items, they will be +--- expanded according to the rules used for 'statusline'. +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- Example: +--- ``` +--- :auto BufEnter * let &titlestring = hostname() .. "/" .. expand("%:p") +--- :set title titlestring=%<%F%=%l/%L-%P titlelen=70 +--- ``` +--- The value of 'titlelen' is used to align items in the middle or right +--- of the available space. +--- Some people prefer to have the file name first: +--- ``` +--- :set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:.:h\")})%)%(\ %a%) +--- ``` +--- Note the use of "%{ }" and an expression to get the path of the file, +--- without the file name. The "%( %)" constructs are used to add a +--- separating space only when needed. +--- NOTE: Use of special characters in 'titlestring' may cause the display +--- to be garbled (e.g., when it contains a CR or NL character). +--- +--- @type string +vim.o.titlestring = "" +vim.go.titlestring = vim.o.titlestring + +--- This option and 'ttimeoutlen' determine the behavior when part of a +--- key code sequence has been received by the `TUI`. +--- +--- For example if <Esc> (the \x1b byte) is received and 'ttimeout' is +--- set, Nvim waits 'ttimeoutlen' milliseconds for the terminal to +--- complete a key code sequence. If no input arrives before the timeout, +--- a single <Esc> is assumed. Many TUI cursor key codes start with <Esc>. +--- +--- On very slow systems this may fail, causing cursor keys not to work +--- sometimes. If you discover this problem you can ":set ttimeoutlen=9999". +--- Nvim will wait for the next character to arrive after an <Esc>. +--- +--- @type boolean +vim.o.ttimeout = true +vim.go.ttimeout = vim.o.ttimeout + +--- Time in milliseconds to wait for a key code sequence to complete. Also +--- used for CTRL-\ CTRL-N and CTRL-\ CTRL-G when part of a command has +--- been typed. +--- +--- @type integer +vim.o.ttimeoutlen = 50 +vim.o.ttm = vim.o.ttimeoutlen +vim.go.ttimeoutlen = vim.o.ttimeoutlen +vim.go.ttm = vim.go.ttimeoutlen + +--- List of directory names for undo files, separated with commas. +--- See 'backupdir' for details of the format. +--- "." means using the directory of the file. The undo file name for +--- "file.txt" is ".file.txt.un~". +--- For other directories the file name is the full path of the edited +--- file, with path separators replaced with "%". +--- When writing: The first directory that exists is used. "." always +--- works, no directories after "." will be used for writing. If none of +--- the directories exist Nvim will attempt to create the last directory in +--- the list. +--- When reading all entries are tried to find an undo file. The first +--- undo file that exists is used. When it cannot be read an error is +--- given, no further entry is used. +--- See `undo-persistence`. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- Note that unlike 'directory' and 'backupdir', 'undodir' always acts as +--- though the trailing slashes are present (see 'backupdir' for what this +--- means). +--- +--- @type string +vim.o.undodir = "$XDG_STATE_HOME/nvim/undo//" +vim.o.udir = vim.o.undodir +vim.go.undodir = vim.o.undodir +vim.go.udir = vim.go.undodir + +--- When on, Vim automatically saves undo history to an undo file when +--- writing a buffer to a file, and restores undo history from the same +--- file on buffer read. +--- The directory where the undo file is stored is specified by 'undodir'. +--- For more information about this feature see `undo-persistence`. +--- The undo file is not read when 'undoreload' causes the buffer from +--- before a reload to be saved for undo. +--- When 'undofile' is turned off the undo file is NOT deleted. +--- +--- @type boolean +vim.o.undofile = false +vim.o.udf = vim.o.undofile +vim.bo.undofile = vim.o.undofile +vim.bo.udf = vim.bo.undofile + +--- Maximum number of changes that can be undone. Since undo information +--- is kept in memory, higher numbers will cause more memory to be used. +--- Nevertheless, a single change can already use a large amount of memory. +--- Set to 0 for Vi compatibility: One level of undo and "u" undoes +--- itself: +--- ``` +--- set ul=0 +--- ``` +--- But you can also get Vi compatibility by including the 'u' flag in +--- 'cpoptions', and still be able to use CTRL-R to repeat undo. +--- Also see `undo-two-ways`. +--- Set to -1 for no undo at all. You might want to do this only for the +--- current buffer: +--- ``` +--- setlocal ul=-1 +--- ``` +--- This helps when you run out of memory for a single change. +--- +--- The local value is set to -123456 when the global value is to be used. +--- +--- Also see `clear-undo`. +--- +--- @type integer +vim.o.undolevels = 1000 +vim.o.ul = vim.o.undolevels +vim.bo.undolevels = vim.o.undolevels +vim.bo.ul = vim.bo.undolevels +vim.go.undolevels = vim.o.undolevels +vim.go.ul = vim.go.undolevels + +--- Save the whole buffer for undo when reloading it. This applies to the +--- ":e!" command and reloading for when the buffer changed outside of +--- Vim. `FileChangedShell` +--- The save only happens when this option is negative or when the number +--- of lines is smaller than the value of this option. +--- Set this option to zero to disable undo for a reload. +--- +--- When saving undo for a reload, any undo file is not read. +--- +--- Note that this causes the whole buffer to be stored in memory. Set +--- this option to a lower value if you run out of memory. +--- +--- @type integer +vim.o.undoreload = 10000 +vim.o.ur = vim.o.undoreload +vim.go.undoreload = vim.o.undoreload +vim.go.ur = vim.go.undoreload + +--- After typing this many characters the swap file will be written to +--- disk. When zero, no swap file will be created at all (see chapter on +--- recovery `crash-recovery`). 'updatecount' is set to zero by starting +--- Vim with the "-n" option, see `startup`. When editing in readonly +--- mode this option will be initialized to 10000. +--- The swapfile can be disabled per buffer with `'swapfile'`. +--- When 'updatecount' is set from zero to non-zero, swap files are +--- created for all buffers that have 'swapfile' set. When 'updatecount' +--- is set to zero, existing swap files are not deleted. +--- This option has no meaning in buffers where `'buftype'` is "nofile" +--- or "nowrite". +--- +--- @type integer +vim.o.updatecount = 200 +vim.o.uc = vim.o.updatecount +vim.go.updatecount = vim.o.updatecount +vim.go.uc = vim.go.updatecount + +--- If this many milliseconds nothing is typed the swap file will be +--- written to disk (see `crash-recovery`). Also used for the +--- `CursorHold` autocommand event. +--- +--- @type integer +vim.o.updatetime = 4000 +vim.o.ut = vim.o.updatetime +vim.go.updatetime = vim.o.updatetime +vim.go.ut = vim.go.updatetime + +--- A list of the number of spaces that a <Tab> counts for while editing, +--- such as inserting a <Tab> or using <BS>. It "feels" like variable- +--- width <Tab>s are being inserted, while in fact a mixture of spaces +--- and <Tab>s is used. Tab widths are separated with commas, with the +--- final value applying to all subsequent tabs. +--- +--- For example, when editing assembly language files where statements +--- start in the 9th column and comments in the 41st, it may be useful +--- to use the following: +--- ``` +--- :set varsofttabstop=8,32,8 +--- ``` +--- This will set soft tabstops with 8 and 8 + 32 spaces, and 8 more +--- for every column thereafter. +--- +--- Note that the value of `'softtabstop'` will be ignored while +--- 'varsofttabstop' is set. +--- +--- @type string +vim.o.varsofttabstop = "" +vim.o.vsts = vim.o.varsofttabstop +vim.bo.varsofttabstop = vim.o.varsofttabstop +vim.bo.vsts = vim.bo.varsofttabstop + +--- A list of the number of spaces that a <Tab> in the file counts for, +--- separated by commas. Each value corresponds to one tab, with the +--- final value applying to all subsequent tabs. For example: +--- ``` +--- :set vartabstop=4,20,10,8 +--- ``` +--- This will make the first tab 4 spaces wide, the second 20 spaces, +--- the third 10 spaces, and all following tabs 8 spaces. +--- +--- Note that the value of `'tabstop'` will be ignored while 'vartabstop' +--- is set. +--- +--- @type string +vim.o.vartabstop = "" +vim.o.vts = vim.o.vartabstop +vim.bo.vartabstop = vim.o.vartabstop +vim.bo.vts = vim.bo.vartabstop + +--- Sets the verbosity level. Also set by `-V` and `:verbose`. +--- +--- Tracing of options in Lua scripts is activated at level 1; Lua scripts +--- are not traced with verbose=0, for performance. +--- +--- If greater than or equal to a given level, Nvim produces the following +--- messages: +--- +--- Level Messages ~ +--- ---------------------------------------------------------------------- +--- 1 Lua assignments to options, mappings, etc. +--- 2 When a file is ":source"'ed, or `shada` file is read or written. +--- 3 UI info, terminal capabilities. +--- 4 Shell commands. +--- 5 Every searched tags file and include file. +--- 8 Files for which a group of autocommands is executed. +--- 9 Executed autocommands. +--- 11 Finding items in a path. +--- 12 Vimscript function calls. +--- 13 When an exception is thrown, caught, finished, or discarded. +--- 14 Anything pending in a ":finally" clause. +--- 15 Ex commands from a script (truncated at 200 characters). +--- 16 Ex commands. +--- +--- If 'verbosefile' is set then the verbose messages are not displayed. +--- +--- @type integer +vim.o.verbose = 0 +vim.o.vbs = vim.o.verbose +vim.go.verbose = vim.o.verbose +vim.go.vbs = vim.go.verbose + +--- When not empty all messages are written in a file with this name. +--- When the file exists messages are appended. +--- Writing to the file ends when Vim exits or when 'verbosefile' is made +--- empty. Writes are buffered, thus may not show up for some time. +--- Setting 'verbosefile' to a new value is like making it empty first. +--- The difference with `:redir` is that verbose messages are not +--- displayed when 'verbosefile' is set. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.verbosefile = "" +vim.o.vfile = vim.o.verbosefile +vim.go.verbosefile = vim.o.verbosefile +vim.go.vfile = vim.go.verbosefile + +--- Name of the directory where to store files for `:mkview`. +--- This option cannot be set from a `modeline` or in the `sandbox`, for +--- security reasons. +--- +--- @type string +vim.o.viewdir = "$XDG_STATE_HOME/nvim/view//" +vim.o.vdir = vim.o.viewdir +vim.go.viewdir = vim.o.viewdir +vim.go.vdir = vim.go.viewdir + +--- Changes the effect of the `:mkview` command. It is a comma-separated +--- list of words. Each word enables saving and restoring something: +--- word save and restore ~ +--- cursor cursor position in file and in window +--- curdir local current directory, if set with `:lcd` +--- folds manually created folds, opened/closed folds and local +--- fold options +--- options options and mappings local to a window or buffer (not +--- global values for local options) +--- localoptions same as "options" +--- slash `deprecated` Always enabled. Uses "/" in filenames. +--- unix `deprecated` Always enabled. Uses "\n" line endings. +--- +--- @type string +vim.o.viewoptions = "folds,cursor,curdir" +vim.o.vop = vim.o.viewoptions +vim.go.viewoptions = vim.o.viewoptions +vim.go.vop = vim.go.viewoptions + +--- A comma-separated list of these words: +--- block Allow virtual editing in Visual block mode. +--- insert Allow virtual editing in Insert mode. +--- all Allow virtual editing in all modes. +--- onemore Allow the cursor to move just past the end of the line +--- none When used as the local value, do not allow virtual +--- editing even when the global value is set. When used +--- as the global value, "none" is the same as "". +--- NONE Alternative spelling of "none". +--- +--- Virtual editing means that the cursor can be positioned where there is +--- no actual character. This can be halfway into a tab or beyond the end +--- of the line. Useful for selecting a rectangle in Visual mode and +--- editing a table. +--- "onemore" is not the same, it will only allow moving the cursor just +--- after the last character of the line. This makes some commands more +--- consistent. Previously the cursor was always past the end of the line +--- if the line was empty. But it is far from Vi compatible. It may also +--- break some plugins or Vim scripts. For example because `l` can move +--- the cursor after the last character. Use with care! +--- Using the `$` command will move to the last character in the line, not +--- past it. This may actually move the cursor to the left! +--- The `g$` command will move to the end of the screen line. +--- It doesn't make sense to combine "all" with "onemore", but you will +--- not get a warning for it. +--- When combined with other words, "none" is ignored. +--- +--- @type string +vim.o.virtualedit = "" +vim.o.ve = vim.o.virtualedit +vim.wo.virtualedit = vim.o.virtualedit +vim.wo.ve = vim.wo.virtualedit +vim.go.virtualedit = vim.o.virtualedit +vim.go.ve = vim.go.virtualedit + +--- Use visual bell instead of beeping. Also see 'errorbells'. +--- +--- @type boolean +vim.o.visualbell = false +vim.o.vb = vim.o.visualbell +vim.go.visualbell = vim.o.visualbell +vim.go.vb = vim.go.visualbell + +--- Give a warning message when a shell command is used while the buffer +--- has been changed. +--- +--- @type boolean +vim.o.warn = true +vim.go.warn = vim.o.warn + +--- Allow specified keys that move the cursor left/right to move to the +--- previous/next line when the cursor is on the first/last character in +--- the line. Concatenate characters to allow this for these keys: +--- char key mode ~ +--- b <BS> Normal and Visual +--- s <Space> Normal and Visual +--- h "h" Normal and Visual (not recommended) +--- l "l" Normal and Visual (not recommended) +--- < <Left> Normal and Visual +--- > <Right> Normal and Visual +--- ~ "~" Normal +--- [ <Left> Insert and Replace +--- ] <Right> Insert and Replace +--- For example: +--- ``` +--- :set ww=<,>,[,] +--- ``` +--- allows wrap only when cursor keys are used. +--- When the movement keys are used in combination with a delete or change +--- operator, the <EOL> also counts for a character. This makes "3h" +--- different from "3dh" when the cursor crosses the end of a line. This +--- is also true for "x" and "X", because they do the same as "dl" and +--- "dh". If you use this, you may also want to use the mapping +--- ":map <BS> X" to make backspace delete the character in front of the +--- cursor. +--- When 'l' is included and it is used after an operator at the end of a +--- line (not an empty line) then it will not move to the next line. This +--- makes "dl", "cl", "yl" etc. work normally. +--- +--- @type string +vim.o.whichwrap = "b,s" +vim.o.ww = vim.o.whichwrap +vim.go.whichwrap = vim.o.whichwrap +vim.go.ww = vim.go.whichwrap + +--- Character you have to type to start wildcard expansion in the +--- command-line, as specified with 'wildmode'. +--- More info here: `cmdline-completion`. +--- The character is not recognized when used inside a macro. See +--- 'wildcharm' for that. +--- Some keys will not work, such as CTRL-C, <CR> and Enter. +--- <Esc> can be used, but hitting it twice in a row will still exit +--- command-line as a failsafe measure. +--- Although 'wc' is a number option, you can set it to a special key: +--- ``` +--- :set wc=<Tab> +--- ``` +--- +--- +--- @type integer +vim.o.wildchar = 9 +vim.o.wc = vim.o.wildchar +vim.go.wildchar = vim.o.wildchar +vim.go.wc = vim.go.wildchar + +--- 'wildcharm' works exactly like 'wildchar', except that it is +--- recognized when used inside a macro. You can find "spare" command-line +--- keys suitable for this option by looking at `ex-edit-index`. Normally +--- you'll never actually type 'wildcharm', just use it in mappings that +--- automatically invoke completion mode, e.g.: +--- ``` +--- :set wcm=<C-Z> +--- :cnoremap ss so $vim/sessions/*.vim<C-Z> +--- ``` +--- Then after typing :ss you can use CTRL-P & CTRL-N. +--- +--- @type integer +vim.o.wildcharm = 0 +vim.o.wcm = vim.o.wildcharm +vim.go.wildcharm = vim.o.wildcharm +vim.go.wcm = vim.go.wildcharm + +--- A list of file patterns. A file that matches with one of these +--- patterns is ignored when expanding `wildcards`, completing file or +--- directory names, and influences the result of `expand()`, `glob()` and +--- `globpath()` unless a flag is passed to disable this. +--- The pattern is used like with `:autocmd`, see `autocmd-pattern`. +--- Also see 'suffixes'. +--- Example: +--- ``` +--- :set wildignore=*.o,*.obj +--- ``` +--- The use of `:set+=` and `:set-=` is preferred when adding or removing +--- a pattern from the list. This avoids problems when a future version +--- uses another default. +--- +--- @type string +vim.o.wildignore = "" +vim.o.wig = vim.o.wildignore +vim.go.wildignore = vim.o.wildignore +vim.go.wig = vim.go.wildignore + +--- When set case is ignored when completing file names and directories. +--- Has no effect when 'fileignorecase' is set. +--- Does not apply when the shell is used to expand wildcards, which +--- happens when there are special characters. +--- +--- @type boolean +vim.o.wildignorecase = false +vim.o.wic = vim.o.wildignorecase +vim.go.wildignorecase = vim.o.wildignorecase +vim.go.wic = vim.go.wildignorecase + +--- When 'wildmenu' is on, command-line completion operates in an enhanced +--- mode. On pressing 'wildchar' (usually <Tab>) to invoke completion, +--- the possible matches are shown. +--- When 'wildoptions' contains "pum", then the completion matches are +--- shown in a popup menu. Otherwise they are displayed just above the +--- command line, with the first match highlighted (overwriting the status +--- line, if there is one). +--- Keys that show the previous/next match, such as <Tab> or +--- CTRL-P/CTRL-N, cause the highlight to move to the appropriate match. +--- 'wildmode' must specify "full": "longest" and "list" do not start +--- 'wildmenu' mode. You can check the current mode with `wildmenumode()`. +--- The menu is cancelled when a key is hit that is not used for selecting +--- a completion. +--- +--- While the menu is active these keys have special meanings: +--- CTRL-P - go to the previous entry +--- CTRL-N - go to the next entry +--- <Left> <Right> - select previous/next match (like CTRL-P/CTRL-N) +--- <PageUp> - select a match several entries back +--- <PageDown> - select a match several entries further +--- <Up> - in filename/menu name completion: move up into +--- parent directory or parent menu. +--- <Down> - in filename/menu name completion: move into a +--- subdirectory or submenu. +--- <CR> - in menu completion, when the cursor is just after a +--- dot: move into a submenu. +--- CTRL-E - end completion, go back to what was there before +--- selecting a match. +--- CTRL-Y - accept the currently selected match and stop +--- completion. +--- +--- If you want <Left> and <Right> to move the cursor instead of selecting +--- a different match, use this: +--- ``` +--- :cnoremap <Left> <Space><BS><Left> +--- :cnoremap <Right> <Space><BS><Right> +--- ``` +--- +--- `hl-WildMenu` highlights the current match. +--- +--- @type boolean +vim.o.wildmenu = true +vim.o.wmnu = vim.o.wildmenu +vim.go.wildmenu = vim.o.wildmenu +vim.go.wmnu = vim.go.wildmenu + +--- Completion mode that is used for the character specified with +--- 'wildchar'. It is a comma-separated list of up to four parts. Each +--- part specifies what to do for each consecutive use of 'wildchar'. The +--- first part specifies the behavior for the first use of 'wildchar', +--- The second part for the second use, etc. +--- +--- Each part consists of a colon separated list consisting of the +--- following possible values: +--- "" Complete only the first match. +--- "full" Complete the next full match. After the last match, +--- the original string is used and then the first match +--- again. Will also start 'wildmenu' if it is enabled. +--- "longest" Complete till longest common string. If this doesn't +--- result in a longer string, use the next part. +--- "list" When more than one match, list all matches. +--- "lastused" When completing buffer names and more than one buffer +--- matches, sort buffers by time last used (other than +--- the current buffer). +--- When there is only a single match, it is fully completed in all cases. +--- +--- Examples of useful colon-separated values: +--- "longest:full" Like "longest", but also start 'wildmenu' if it is +--- enabled. Will not complete to the next full match. +--- "list:full" When more than one match, list all matches and +--- complete first match. +--- "list:longest" When more than one match, list all matches and +--- complete till longest common string. +--- "list:lastused" When more than one buffer matches, list all matches +--- and sort buffers by time last used (other than the +--- current buffer). +--- +--- Examples: +--- ``` +--- :set wildmode=full +--- ``` +--- Complete first full match, next match, etc. (the default) +--- ``` +--- :set wildmode=longest,full +--- ``` +--- Complete longest common string, then each full match +--- ``` +--- :set wildmode=list:full +--- ``` +--- List all matches and complete each full match +--- ``` +--- :set wildmode=list,full +--- ``` +--- List all matches without completing, then each full match +--- ``` +--- :set wildmode=longest,list +--- ``` +--- Complete longest common string, then list alternatives. +--- More info here: `cmdline-completion`. +--- +--- @type string +vim.o.wildmode = "full" +vim.o.wim = vim.o.wildmode +vim.go.wildmode = vim.o.wildmode +vim.go.wim = vim.go.wildmode + +--- A list of words that change how `cmdline-completion` is done. +--- The following values are supported: +--- fuzzy Use `fuzzy-matching` to find completion matches. When +--- this value is specified, wildcard expansion will not +--- be used for completion. The matches will be sorted by +--- the "best match" rather than alphabetically sorted. +--- This will find more matches than the wildcard +--- expansion. Currently fuzzy matching based completion +--- is not supported for file and directory names and +--- instead wildcard expansion is used. +--- pum Display the completion matches using the popup menu +--- in the same style as the `ins-completion-menu`. +--- tagfile When using CTRL-D to list matching tags, the kind of +--- tag and the file of the tag is listed. Only one match +--- is displayed per line. Often used tag kinds are: +--- d #define +--- f function +--- +--- @type string +vim.o.wildoptions = "pum,tagfile" +vim.o.wop = vim.o.wildoptions +vim.go.wildoptions = vim.o.wildoptions +vim.go.wop = vim.go.wildoptions + +--- only used in Win32 +--- Some GUI versions allow the access to menu entries by using the ALT +--- key in combination with a character that appears underlined in the +--- menu. This conflicts with the use of the ALT key for mappings and +--- entering special characters. This option tells what to do: +--- no Don't use ALT keys for menus. ALT key combinations can be +--- mapped, but there is no automatic handling. +--- yes ALT key handling is done by the windowing system. ALT key +--- combinations cannot be mapped. +--- menu Using ALT in combination with a character that is a menu +--- shortcut key, will be handled by the windowing system. Other +--- keys can be mapped. +--- If the menu is disabled by excluding 'm' from 'guioptions', the ALT +--- key is never used for the menu. +--- This option is not used for <F10>; on Win32. +--- +--- @type string +vim.o.winaltkeys = "menu" +vim.o.wak = vim.o.winaltkeys +vim.go.winaltkeys = vim.o.winaltkeys +vim.go.wak = vim.go.winaltkeys + +--- When non-empty, this option enables the window bar and determines its +--- contents. The window bar is a bar that's shown at the top of every +--- window with it enabled. The value of 'winbar' is evaluated like with +--- 'statusline'. +--- +--- When changing something that is used in 'winbar' that does not trigger +--- it to be updated, use `:redrawstatus`. +--- +--- Floating windows do not use the global value of 'winbar'. The +--- window-local value of 'winbar' must be set for a floating window to +--- have a window bar. +--- +--- This option cannot be set in a modeline when 'modelineexpr' is off. +--- +--- @type string +vim.o.winbar = "" +vim.o.wbr = vim.o.winbar +vim.wo.winbar = vim.o.winbar +vim.wo.wbr = vim.wo.winbar +vim.go.winbar = vim.o.winbar +vim.go.wbr = vim.go.winbar + +--- Enables pseudo-transparency for a floating window. Valid values are in +--- the range of 0 for fully opaque window (disabled) to 100 for fully +--- transparent background. Values between 0-30 are typically most useful. +--- +--- UI-dependent. Works best with RGB colors. 'termguicolors' +--- +--- @type integer +vim.o.winblend = 0 +vim.o.winbl = vim.o.winblend +vim.wo.winblend = vim.o.winblend +vim.wo.winbl = vim.wo.winblend + +--- Window height used for `CTRL-F` and `CTRL-B` when there is only one +--- window and the value is smaller than 'lines' minus one. The screen +--- will scroll 'window' minus two lines, with a minimum of one. +--- When 'window' is equal to 'lines' minus one CTRL-F and CTRL-B scroll +--- in a much smarter way, taking care of wrapping lines. +--- When resizing the Vim window, the value is smaller than 1 or more than +--- or equal to 'lines' it will be set to 'lines' minus 1. +--- Note: Do not confuse this with the height of the Vim window, use +--- 'lines' for that. +--- +--- @type integer +vim.o.window = 0 +vim.o.wi = vim.o.window +vim.go.window = vim.o.window +vim.go.wi = vim.go.window + +--- Keep the window height when windows are opened or closed and +--- 'equalalways' is set. Also for `CTRL-W_=`. Set by default for the +--- `preview-window` and `quickfix-window`. +--- The height may be changed anyway when running out of room. +--- +--- @type boolean +vim.o.winfixheight = false +vim.o.wfh = vim.o.winfixheight +vim.wo.winfixheight = vim.o.winfixheight +vim.wo.wfh = vim.wo.winfixheight + +--- Keep the window width when windows are opened or closed and +--- 'equalalways' is set. Also for `CTRL-W_=`. +--- The width may be changed anyway when running out of room. +--- +--- @type boolean +vim.o.winfixwidth = false +vim.o.wfw = vim.o.winfixwidth +vim.wo.winfixwidth = vim.o.winfixwidth +vim.wo.wfw = vim.wo.winfixwidth + +--- Minimal number of lines for the current window. This is not a hard +--- minimum, Vim will use fewer lines if there is not enough room. If the +--- focus goes to a window that is smaller, its size is increased, at the +--- cost of the height of other windows. +--- Set 'winheight' to a small number for normal editing. +--- Set it to 999 to make the current window fill most of the screen. +--- Other windows will be only 'winminheight' high. This has the drawback +--- that ":all" will create only two windows. To avoid "vim -o 1 2 3 4" +--- to create only two windows, set the option after startup is done, +--- using the `VimEnter` event: +--- ``` +--- au VimEnter * set winheight=999 +--- ``` +--- Minimum value is 1. +--- The height is not adjusted after one of the commands that change the +--- height of the current window. +--- 'winheight' applies to the current window. Use 'winminheight' to set +--- the minimal height for other windows. +--- +--- @type integer +vim.o.winheight = 1 +vim.o.wh = vim.o.winheight +vim.go.winheight = vim.o.winheight +vim.go.wh = vim.go.winheight + +--- Window-local highlights. Comma-delimited list of highlight +--- `group-name` pairs "{hl-from}:{hl-to},..." where each {hl-from} is +--- a `highlight-groups` item to be overridden by {hl-to} group in +--- the window. +--- +--- Note: highlight namespaces take precedence over 'winhighlight'. +--- See `nvim_win_set_hl_ns()` and `nvim_set_hl()`. +--- +--- Highlights of vertical separators are determined by the window to the +--- left of the separator. The 'tabline' highlight of a tabpage is +--- decided by the last-focused window of the tabpage. Highlights of +--- the popupmenu are determined by the current window. Highlights in the +--- message area cannot be overridden. +--- +--- Example: show a different color for non-current windows: +--- ``` +--- set winhighlight=Normal:MyNormal,NormalNC:MyNormalNC +--- ``` +--- +--- +--- @type string +vim.o.winhighlight = "" +vim.o.winhl = vim.o.winhighlight +vim.wo.winhighlight = vim.o.winhighlight +vim.wo.winhl = vim.wo.winhighlight + +--- The minimal height of a window, when it's not the current window. +--- This is a hard minimum, windows will never become smaller. +--- When set to zero, windows may be "squashed" to zero lines (i.e. just a +--- status bar) if necessary. They will return to at least one line when +--- they become active (since the cursor has to have somewhere to go.) +--- Use 'winheight' to set the minimal height of the current window. +--- This option is only checked when making a window smaller. Don't use a +--- large number, it will cause errors when opening more than a few +--- windows. A value of 0 to 3 is reasonable. +--- +--- @type integer +vim.o.winminheight = 1 +vim.o.wmh = vim.o.winminheight +vim.go.winminheight = vim.o.winminheight +vim.go.wmh = vim.go.winminheight + +--- The minimal width of a window, when it's not the current window. +--- This is a hard minimum, windows will never become smaller. +--- When set to zero, windows may be "squashed" to zero columns (i.e. just +--- a vertical separator) if necessary. They will return to at least one +--- line when they become active (since the cursor has to have somewhere +--- to go.) +--- Use 'winwidth' to set the minimal width of the current window. +--- This option is only checked when making a window smaller. Don't use a +--- large number, it will cause errors when opening more than a few +--- windows. A value of 0 to 12 is reasonable. +--- +--- @type integer +vim.o.winminwidth = 1 +vim.o.wmw = vim.o.winminwidth +vim.go.winminwidth = vim.o.winminwidth +vim.go.wmw = vim.go.winminwidth + +--- Minimal number of columns for the current window. This is not a hard +--- minimum, Vim will use fewer columns if there is not enough room. If +--- the current window is smaller, its size is increased, at the cost of +--- the width of other windows. Set it to 999 to make the current window +--- always fill the screen. Set it to a small number for normal editing. +--- The width is not adjusted after one of the commands to change the +--- width of the current window. +--- 'winwidth' applies to the current window. Use 'winminwidth' to set +--- the minimal width for other windows. +--- +--- @type integer +vim.o.winwidth = 20 +vim.o.wiw = vim.o.winwidth +vim.go.winwidth = vim.o.winwidth +vim.go.wiw = vim.go.winwidth + +--- This option changes how text is displayed. It doesn't change the text +--- in the buffer, see 'textwidth' for that. +--- When on, lines longer than the width of the window will wrap and +--- displaying continues on the next line. When off lines will not wrap +--- and only part of long lines will be displayed. When the cursor is +--- moved to a part that is not shown, the screen will scroll +--- horizontally. +--- The line will be broken in the middle of a word if necessary. See +--- 'linebreak' to get the break at a word boundary. +--- To make scrolling horizontally a bit more useful, try this: +--- ``` +--- :set sidescroll=5 +--- :set listchars+=precedes:<,extends:> +--- ``` +--- See 'sidescroll', 'listchars' and `wrap-off`. +--- This option can't be set from a `modeline` when the 'diff' option is +--- on. +--- +--- @type boolean +vim.o.wrap = true +vim.wo.wrap = vim.o.wrap + +--- Number of characters from the right window border where wrapping +--- starts. When typing text beyond this limit, an <EOL> will be inserted +--- and inserting continues on the next line. +--- Options that add a margin, such as 'number' and 'foldcolumn', cause +--- the text width to be further reduced. +--- When 'textwidth' is non-zero, this option is not used. +--- See also 'formatoptions' and `ins-textwidth`. +--- +--- @type integer +vim.o.wrapmargin = 0 +vim.o.wm = vim.o.wrapmargin +vim.bo.wrapmargin = vim.o.wrapmargin +vim.bo.wm = vim.bo.wrapmargin + +--- Searches wrap around the end of the file. Also applies to `]s` and +--- `[s`, searching for spelling mistakes. +--- +--- @type boolean +vim.o.wrapscan = true +vim.o.ws = vim.o.wrapscan +vim.go.wrapscan = vim.o.wrapscan +vim.go.ws = vim.go.wrapscan + +--- Allows writing files. When not set, writing a file is not allowed. +--- Can be used for a view-only mode, where modifications to the text are +--- still allowed. Can be reset with the `-m` or `-M` command line +--- argument. Filtering text is still possible, even though this requires +--- writing a temporary file. +--- +--- @type boolean +vim.o.write = true +vim.go.write = vim.o.write + +--- Allows writing to any file with no need for "!" override. +--- +--- @type boolean +vim.o.writeany = false +vim.o.wa = vim.o.writeany +vim.go.writeany = vim.o.writeany +vim.go.wa = vim.go.writeany + +--- Make a backup before overwriting a file. The backup is removed after +--- the file was successfully written, unless the 'backup' option is +--- also on. +--- WARNING: Switching this option off means that when Vim fails to write +--- your buffer correctly and then, for whatever reason, Vim exits, you +--- lose both the original file and what you were writing. Only reset +--- this option if your file system is almost full and it makes the write +--- fail (and make sure not to exit Vim until the write was successful). +--- See `backup-table` for another explanation. +--- When the 'backupskip' pattern matches, a backup is not made anyway. +--- Depending on 'backupcopy' the backup is a new file or the original +--- file renamed (and a new file is written). +--- +--- @type boolean +vim.o.writebackup = true +vim.o.wb = vim.o.writebackup +vim.go.writebackup = vim.o.writebackup +vim.go.wb = vim.go.writebackup + +--- Only takes effect together with 'redrawdebug'. +--- The number of milliseconds to wait after each line or each flush +--- +--- @type integer +vim.o.writedelay = 0 +vim.o.wd = vim.o.writedelay +vim.go.writedelay = vim.o.writedelay +vim.go.wd = vim.go.writedelay diff --git a/runtime/lua/vim/_meta/regex.lua b/runtime/lua/vim/_meta/regex.lua new file mode 100644 index 0000000000..58aa2be8c2 --- /dev/null +++ b/runtime/lua/vim/_meta/regex.lua @@ -0,0 +1,36 @@ +--- @meta + +-- luacheck: no unused args + +--- @defgroup vim.regex +--- +--- @brief Vim regexes can be used directly from Lua. Currently they only allow +--- matching within a single line. + +--- Parse the Vim regex {re} and return a regex object. Regexes are "magic" +--- and case-sensitive by default, regardless of 'magic' and 'ignorecase'. +--- They can be controlled with flags, see |/magic| and |/ignorecase|. +--- @param re string +--- @return vim.regex +function vim.regex(re) end + +--- @class vim.regex +local regex = {} -- luacheck: no unused + +--- Match the string against the regex. If the string should match the regex +--- precisely, surround the regex with `^` and `$`. If there was a match, the +--- byte indices for the beginning and end of the match are returned. When +--- there is no match, `nil` is returned. Because any integer is "truthy", +--- `regex:match_str()` can be directly used as a condition in an if-statement. +--- @param str string +function regex:match_str(str) end + +--- Match line {line_idx} (zero-based) in buffer {bufnr}. If {start} and {end} +--- are supplied, match only this byte index range. Otherwise see +--- |regex:match_str()|. If {start} is used, then the returned byte indices +--- will be relative {start}. +--- @param bufnr integer +--- @param line_idx integer +--- @param start? integer +--- @param end_? integer +function regex:match_line(bufnr, line_idx, start, end_) end diff --git a/runtime/lua/vim/_meta/spell.lua b/runtime/lua/vim/_meta/spell.lua new file mode 100644 index 0000000000..57f2180895 --- /dev/null +++ b/runtime/lua/vim/_meta/spell.lua @@ -0,0 +1,32 @@ +--- @meta + +-- luacheck: no unused args + +--- Check {str} for spelling errors. Similar to the Vimscript function +--- |spellbadword()|. +--- +--- Note: The behaviour of this function is dependent on: 'spelllang', +--- 'spellfile', 'spellcapcheck' and 'spelloptions' which can all be local to +--- the buffer. Consider calling this with |nvim_buf_call()|. +--- +--- Example: +--- +--- ```lua +--- vim.spell.check("the quik brown fox") +--- -- => +--- -- { +--- -- {'quik', 'bad', 5} +--- -- } +--- ``` +--- +--- @param str string +--- @return {[1]: string, [2]: string, [3]: string}[] +--- List of tuples with three items: +--- - The badly spelled word. +--- - The type of the spelling error: +--- "bad" spelling mistake +--- "rare" rare word +--- "local" word only valid in another region +--- "caps" word should start with Capital +--- - The position in {str} where the word begins. +function vim.spell.check(str) end diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua new file mode 100644 index 0000000000..05e5b2b871 --- /dev/null +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -0,0 +1,10689 @@ +--- @meta _ +-- THIS FILE IS GENERATED +-- DO NOT EDIT +error('Cannot require a meta file') + +--- Return the absolute value of {expr}. When {expr} evaluates to +--- a |Float| abs() returns a |Float|. When {expr} can be +--- converted to a |Number| abs() returns a |Number|. Otherwise +--- abs() gives an error message and returns -1. +--- Examples: >vim +--- echo abs(1.456) +--- < 1.456 >vim +--- echo abs(-5.456) +--- < 5.456 >vim +--- echo abs(-4) +--- < 4 +--- +--- @param expr any +--- @return number +function vim.fn.abs(expr) end + +--- Return the arc cosine of {expr} measured in radians, as a +--- |Float| in the range of [0, pi]. +--- {expr} must evaluate to a |Float| or a |Number| in the range +--- [-1, 1]. +--- Returns NaN if {expr} is outside the range [-1, 1]. Returns +--- 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo acos(0) +--- < 1.570796 >vim +--- echo acos(-0.5) +--- < 2.094395 +--- +--- @param expr any +--- @return number +function vim.fn.acos(expr) end + +--- Append the item {expr} to |List| or |Blob| {object}. Returns +--- the resulting |List| or |Blob|. Examples: >vim +--- let alist = add([1, 2, 3], item) +--- call add(mylist, "woodstock") +--- <Note that when {expr} is a |List| it is appended as a single +--- item. Use |extend()| to concatenate |Lists|. +--- When {object} is a |Blob| then {expr} must be a number. +--- Use |insert()| to add an item at another position. +--- Returns 1 if {object} is not a |List| or a |Blob|. +--- +--- @param object any +--- @param expr any +--- @return any +function vim.fn.add(object, expr) end + +--- Bitwise AND on the two arguments. The arguments are converted +--- to a number. A List, Dict or Float argument causes an error. +--- Also see `or()` and `xor()`. +--- Example: >vim +--- let flag = and(bits, 0x80) +--- < +--- +--- @param expr any +--- @param expr1 any +--- @return integer +vim.fn['and'] = function(expr, expr1) end + +--- Returns Dictionary of |api-metadata|. +--- +--- View it in a nice human-readable format: >vim +--- lua vim.print(vim.fn.api_info()) +--- < +--- +--- @return table +function vim.fn.api_info() end + +--- When {text} is a |List|: Append each item of the |List| as a +--- text line below line {lnum} in the current buffer. +--- Otherwise append {text} as one text line below line {lnum} in +--- the current buffer. +--- Any type of item is accepted and converted to a String. +--- {lnum} can be zero to insert a line before the first one. +--- {lnum} is used like with |getline()|. +--- Returns 1 for failure ({lnum} out of range or out of memory), +--- 0 for success. When {text} is an empty list zero is returned, +--- no matter the value of {lnum}. Example: >vim +--- let failed = append(line('$'), "# THE END") +--- let failed = append(0, ["Chapter 1", "the beginning"]) +--- < +--- +--- @param lnum integer +--- @param text any +--- @return 0|1 +function vim.fn.append(lnum, text) end + +--- Like |append()| but append the text in buffer {expr}. +--- +--- This function works only for loaded buffers. First call +--- |bufload()| if needed. +--- +--- For the use of {buf}, see |bufname()|. +--- +--- {lnum} is the line number to append below. Note that using +--- |line()| would use the current buffer, not the one appending +--- to. Use "$" to append at the end of the buffer. Other string +--- values are not supported. +--- +--- On success 0 is returned, on failure 1 is returned. +--- +--- If {buf} is not a valid buffer or {lnum} is not valid, an +--- error message is given. Example: >vim +--- let failed = appendbufline(13, 0, "# THE START") +--- <However, when {text} is an empty list then no error is given +--- for an invalid {lnum}, since {lnum} isn't actually used. +--- +--- @param buf any +--- @param lnum integer +--- @param text string +--- @return 0|1 +function vim.fn.appendbufline(buf, lnum, text) end + +--- The result is the number of files in the argument list. See +--- |arglist|. +--- If {winid} is not supplied, the argument list of the current +--- window is used. +--- If {winid} is -1, the global argument list is used. +--- Otherwise {winid} specifies the window of which the argument +--- list is used: either the window number or the window ID. +--- Returns -1 if the {winid} argument is invalid. +--- +--- @param winid? integer +--- @return integer +function vim.fn.argc(winid) end + +--- The result is the current index in the argument list. 0 is +--- the first file. argc() - 1 is the last one. See |arglist|. +--- +--- @return integer +function vim.fn.argidx() end + +--- Return the argument list ID. This is a number which +--- identifies the argument list being used. Zero is used for the +--- global argument list. See |arglist|. +--- Returns -1 if the arguments are invalid. +--- +--- Without arguments use the current window. +--- With {winnr} only use this window in the current tab page. +--- With {winnr} and {tabnr} use the window in the specified tab +--- page. +--- {winnr} can be the window number or the |window-ID|. +--- +--- @param winnr? integer +--- @param tabnr? integer +--- @return integer +function vim.fn.arglistid(winnr, tabnr) end + +--- The result is the {nr}th file in the argument list. See +--- |arglist|. "argv(0)" is the first one. Example: >vim +--- let i = 0 +--- while i < argc() +--- let f = escape(fnameescape(argv(i)), '.') +--- exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>' +--- let i = i + 1 +--- endwhile +--- <Without the {nr} argument, or when {nr} is -1, a |List| with +--- the whole |arglist| is returned. +--- +--- The {winid} argument specifies the window ID, see |argc()|. +--- For the Vim command line arguments see |v:argv|. +--- +--- Returns an empty string if {nr}th argument is not present in +--- the argument list. Returns an empty List if the {winid} +--- argument is invalid. +--- +--- @param nr? integer +--- @param winid? integer +--- @return string|string[] +function vim.fn.argv(nr, winid) end + +--- Return the arc sine of {expr} measured in radians, as a |Float| +--- in the range of [-pi/2, pi/2]. +--- {expr} must evaluate to a |Float| or a |Number| in the range +--- [-1, 1]. +--- Returns NaN if {expr} is outside the range [-1, 1]. Returns +--- 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo asin(0.8) +--- < 0.927295 >vim +--- echo asin(-0.5) +--- < -0.523599 +--- +--- @param expr any +--- @return number +function vim.fn.asin(expr) end + +--- Run {cmd} and add an error message to |v:errors| if it does +--- NOT produce a beep or visual bell. +--- Also see |assert_fails()|, |assert_nobeep()| and +--- |assert-return|. +--- +--- @param cmd any +--- @return 0|1 +function vim.fn.assert_beeps(cmd) end + +--- When {expected} and {actual} are not equal an error message is +--- added to |v:errors| and 1 is returned. Otherwise zero is +--- returned. |assert-return| +--- The error is in the form "Expected {expected} but got +--- {actual}". When {msg} is present it is prefixed to that. +--- +--- There is no automatic conversion, the String "4" is different +--- from the Number 4. And the number 4 is different from the +--- Float 4.0. The value of 'ignorecase' is not used here, case +--- always matters. +--- Example: >vim +--- assert_equal('foo', 'bar') +--- <Will result in a string to be added to |v:errors|: +--- test.vim line 12: Expected 'foo' but got 'bar' ~ +--- +--- @param expected any +--- @param actual any +--- @param msg? any +--- @return 0|1 +function vim.fn.assert_equal(expected, actual, msg) end + +--- When the files {fname-one} and {fname-two} do not contain +--- exactly the same text an error message is added to |v:errors|. +--- Also see |assert-return|. +--- When {fname-one} or {fname-two} does not exist the error will +--- mention that. +--- +--- @return 0|1 +function vim.fn.assert_equalfile() end + +--- When v:exception does not contain the string {error} an error +--- message is added to |v:errors|. Also see |assert-return|. +--- This can be used to assert that a command throws an exception. +--- Using the error number, followed by a colon, avoids problems +--- with translations: >vim +--- try +--- commandthatfails +--- call assert_false(1, 'command should have failed') +--- catch +--- call assert_exception('E492:') +--- endtry +--- < +--- +--- @param error any +--- @param msg? any +--- @return 0|1 +function vim.fn.assert_exception(error, msg) end + +--- Run {cmd} and add an error message to |v:errors| if it does +--- NOT produce an error or when {error} is not found in the +--- error message. Also see |assert-return|. +--- +--- When {error} is a string it must be found literally in the +--- first reported error. Most often this will be the error code, +--- including the colon, e.g. "E123:". >vim +--- assert_fails('bad cmd', 'E987:') +--- < +--- When {error} is a |List| with one or two strings, these are +--- used as patterns. The first pattern is matched against the +--- first reported error: >vim +--- assert_fails('cmd', ['E987:.*expected bool']) +--- <The second pattern, if present, is matched against the last +--- reported error. To only match the last error use an empty +--- string for the first error: >vim +--- assert_fails('cmd', ['', 'E987:']) +--- < +--- If {msg} is empty then it is not used. Do this to get the +--- default message when passing the {lnum} argument. +--- +--- When {lnum} is present and not negative, and the {error} +--- argument is present and matches, then this is compared with +--- the line number at which the error was reported. That can be +--- the line number in a function or in a script. +--- +--- When {context} is present it is used as a pattern and matched +--- against the context (script name or function name) where +--- {lnum} is located in. +--- +--- Note that beeping is not considered an error, and some failing +--- commands only beep. Use |assert_beeps()| for those. +--- +--- @param cmd any +--- @param error? any +--- @param msg? any +--- @param lnum? integer +--- @param context? any +--- @return 0|1 +function vim.fn.assert_fails(cmd, error, msg, lnum, context) end + +--- When {actual} is not false an error message is added to +--- |v:errors|, like with |assert_equal()|. +--- The error is in the form "Expected False but got {actual}". +--- When {msg} is present it is prepended to that. +--- Also see |assert-return|. +--- +--- A value is false when it is zero. When {actual} is not a +--- number the assert fails. +--- +--- @param actual any +--- @param msg? any +--- @return 0|1 +function vim.fn.assert_false(actual, msg) end + +--- This asserts number and |Float| values. When {actual} is lower +--- than {lower} or higher than {upper} an error message is added +--- to |v:errors|. Also see |assert-return|. +--- The error is in the form "Expected range {lower} - {upper}, +--- but got {actual}". When {msg} is present it is prefixed to +--- that. +--- +--- @param lower any +--- @param upper any +--- @param actual any +--- @param msg? any +--- @return 0|1 +function vim.fn.assert_inrange(lower, upper, actual, msg) end + +--- When {pattern} does not match {actual} an error message is +--- added to |v:errors|. Also see |assert-return|. +--- The error is in the form "Pattern {pattern} does not match +--- {actual}". When {msg} is present it is prefixed to that. +--- +--- {pattern} is used as with |expr-=~|: The matching is always done +--- like 'magic' was set and 'cpoptions' is empty, no matter what +--- the actual value of 'magic' or 'cpoptions' is. +--- +--- {actual} is used as a string, automatic conversion applies. +--- Use "^" and "$" to match with the start and end of the text. +--- Use both to match the whole text. +--- +--- Example: >vim +--- assert_match('^f.*o$', 'foobar') +--- <Will result in a string to be added to |v:errors|: +--- test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~ +--- +--- @param pattern any +--- @param actual any +--- @param msg? any +--- @return 0|1 +function vim.fn.assert_match(pattern, actual, msg) end + +--- Run {cmd} and add an error message to |v:errors| if it +--- produces a beep or visual bell. +--- Also see |assert_beeps()|. +--- +--- @param cmd any +--- @return 0|1 +function vim.fn.assert_nobeep(cmd) end + +--- The opposite of `assert_equal()`: add an error message to +--- |v:errors| when {expected} and {actual} are equal. +--- Also see |assert-return|. +--- +--- @param expected any +--- @param actual any +--- @param msg? any +--- @return 0|1 +function vim.fn.assert_notequal(expected, actual, msg) end + +--- The opposite of `assert_match()`: add an error message to +--- |v:errors| when {pattern} matches {actual}. +--- Also see |assert-return|. +--- +--- @param pattern any +--- @param actual any +--- @param msg? any +--- @return 0|1 +function vim.fn.assert_notmatch(pattern, actual, msg) end + +--- Report a test failure directly, using String {msg}. +--- Always returns one. +--- +--- @param msg any +--- @return 0|1 +function vim.fn.assert_report(msg) end + +--- When {actual} is not true an error message is added to +--- |v:errors|, like with |assert_equal()|. +--- Also see |assert-return|. +--- A value is |TRUE| when it is a non-zero number or |v:true|. +--- When {actual} is not a number or |v:true| the assert fails. +--- When {msg} is given it precedes the default message. +--- +--- @param actual any +--- @param msg? any +--- @return 0|1 +function vim.fn.assert_true(actual, msg) end + +--- Return the principal value of the arc tangent of {expr}, in +--- the range [-pi/2, +pi/2] radians, as a |Float|. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo atan(100) +--- < 1.560797 >vim +--- echo atan(-4.01) +--- < -1.326405 +--- +--- @param expr any +--- @return number +function vim.fn.atan(expr) end + +--- Return the arc tangent of {expr1} / {expr2}, measured in +--- radians, as a |Float| in the range [-pi, pi]. +--- {expr1} and {expr2} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr1} or {expr2} is not a |Float| or a +--- |Number|. +--- Examples: >vim +--- echo atan2(-1, 1) +--- < -0.785398 >vim +--- echo atan2(1, -1) +--- < 2.356194 +--- +--- @param expr1 any +--- @param expr2 any +--- @return number +function vim.fn.atan2(expr1, expr2) end + +--- Return a List containing the number value of each byte in Blob +--- {blob}. Examples: >vim +--- blob2list(0z0102.0304) " returns [1, 2, 3, 4] +--- blob2list(0z) " returns [] +--- <Returns an empty List on error. |list2blob()| does the +--- opposite. +--- +--- @param blob any +--- @return any[] +function vim.fn.blob2list(blob) end + +--- Put up a file requester. This only works when "has("browse")" +--- returns |TRUE| (only in some GUI versions). +--- The input fields are: +--- {save} when |TRUE|, select file to write +--- {title} title for the requester +--- {initdir} directory to start browsing in +--- {default} default file name +--- An empty string is returned when the "Cancel" button is hit, +--- something went wrong, or browsing is not possible. +--- +--- @param save any +--- @param title any +--- @param initdir any +--- @param default any +--- @return 0|1 +function vim.fn.browse(save, title, initdir, default) end + +--- Put up a directory requester. This only works when +--- "has("browse")" returns |TRUE| (only in some GUI versions). +--- On systems where a directory browser is not supported a file +--- browser is used. In that case: select a file in the directory +--- to be used. +--- The input fields are: +--- {title} title for the requester +--- {initdir} directory to start browsing in +--- When the "Cancel" button is hit, something went wrong, or +--- browsing is not possible, an empty string is returned. +--- +--- @param title any +--- @param initdir any +--- @return 0|1 +function vim.fn.browsedir(title, initdir) end + +--- Add a buffer to the buffer list with name {name} (must be a +--- String). +--- If a buffer for file {name} already exists, return that buffer +--- number. Otherwise return the buffer number of the newly +--- created buffer. When {name} is an empty string then a new +--- buffer is always created. +--- The buffer will not have 'buflisted' set and not be loaded +--- yet. To add some text to the buffer use this: >vim +--- let bufnr = bufadd('someName') +--- call bufload(bufnr) +--- call setbufline(bufnr, 1, ['some', 'text']) +--- <Returns 0 on error. +--- +--- @param name string +--- @return integer +function vim.fn.bufadd(name) end + +--- The result is a Number, which is |TRUE| if a buffer called +--- {buf} exists. +--- If the {buf} argument is a number, buffer numbers are used. +--- Number zero is the alternate buffer for the current window. +--- +--- If the {buf} argument is a string it must match a buffer name +--- exactly. The name can be: +--- - Relative to the current directory. +--- - A full path. +--- - The name of a buffer with 'buftype' set to "nofile". +--- - A URL name. +--- Unlisted buffers will be found. +--- Note that help files are listed by their short name in the +--- output of |:buffers|, but bufexists() requires using their +--- long name to be able to find them. +--- bufexists() may report a buffer exists, but to use the name +--- with a |:buffer| command you may need to use |expand()|. Esp +--- for MS-Windows 8.3 names in the form "c:\DOCUME~1" +--- Use "bufexists(0)" to test for the existence of an alternate +--- file name. +--- +--- @param buf any +--- @return 0|1 +function vim.fn.bufexists(buf) end + +--- @deprecated +--- Obsolete name for |bufexists()|. +--- +--- @param ... any +--- @return 0|1 +function vim.fn.buffer_exists(...) end + +--- @deprecated +--- Obsolete name for |bufname()|. +--- +--- @param ... any +--- @return string +function vim.fn.buffer_name(...) end + +--- @deprecated +--- Obsolete name for |bufnr()|. +--- +--- @param ... any +--- @return integer +function vim.fn.buffer_number(...) end + +--- The result is a Number, which is |TRUE| if a buffer called +--- {buf} exists and is listed (has the 'buflisted' option set). +--- The {buf} argument is used like with |bufexists()|. +--- +--- @param buf any +--- @return 0|1 +function vim.fn.buflisted(buf) end + +--- Ensure the buffer {buf} is loaded. When the buffer name +--- refers to an existing file then the file is read. Otherwise +--- the buffer will be empty. If the buffer was already loaded +--- then there is no change. If the buffer is not related to a +--- file then no file is read (e.g., when 'buftype' is "nofile"). +--- If there is an existing swap file for the file of the buffer, +--- there will be no dialog, the buffer will be loaded anyway. +--- The {buf} argument is used like with |bufexists()|. +--- +--- @param buf any +function vim.fn.bufload(buf) end + +--- The result is a Number, which is |TRUE| if a buffer called +--- {buf} exists and is loaded (shown in a window or hidden). +--- The {buf} argument is used like with |bufexists()|. +--- +--- @param buf any +--- @return 0|1 +function vim.fn.bufloaded(buf) end + +--- The result is the name of a buffer. Mostly as it is displayed +--- by the `:ls` command, but not using special names such as +--- "[No Name]". +--- If {buf} is omitted the current buffer is used. +--- If {buf} is a Number, that buffer number's name is given. +--- Number zero is the alternate buffer for the current window. +--- If {buf} is a String, it is used as a |file-pattern| to match +--- with the buffer names. This is always done like 'magic' is +--- set and 'cpoptions' is empty. When there is more than one +--- match an empty string is returned. +--- "" or "%" can be used for the current buffer, "#" for the +--- alternate buffer. +--- A full match is preferred, otherwise a match at the start, end +--- or middle of the buffer name is accepted. If you only want a +--- full match then put "^" at the start and "$" at the end of the +--- pattern. +--- Listed buffers are found first. If there is a single match +--- with a listed buffer, that one is returned. Next unlisted +--- buffers are searched for. +--- If the {buf} is a String, but you want to use it as a buffer +--- number, force it to be a Number by adding zero to it: >vim +--- echo bufname("3" + 0) +--- <If the buffer doesn't exist, or doesn't have a name, an empty +--- string is returned. >vim +--- echo bufname("#") " alternate buffer name +--- echo bufname(3) " name of buffer 3 +--- echo bufname("%") " name of current buffer +--- echo bufname("file2") " name of buffer where "file2" matches. +--- < +--- +--- @param buf? any +--- @return string +function vim.fn.bufname(buf) end + +--- The result is the number of a buffer, as it is displayed by +--- the `:ls` command. For the use of {buf}, see |bufname()| +--- above. +--- If the buffer doesn't exist, -1 is returned. Or, if the +--- {create} argument is present and TRUE, a new, unlisted, +--- buffer is created and its number is returned. +--- bufnr("$") is the last buffer: >vim +--- let last_buffer = bufnr("$") +--- <The result is a Number, which is the highest buffer number +--- of existing buffers. Note that not all buffers with a smaller +--- number necessarily exist, because ":bwipeout" may have removed +--- them. Use bufexists() to test for the existence of a buffer. +--- +--- @param buf? any +--- @param create? any +--- @return integer +function vim.fn.bufnr(buf, create) end + +--- The result is a Number, which is the |window-ID| of the first +--- window associated with buffer {buf}. For the use of {buf}, +--- see |bufname()| above. If buffer {buf} doesn't exist or +--- there is no such window, -1 is returned. Example: >vim +--- +--- echo "A window containing buffer 1 is " .. (bufwinid(1)) +--- < +--- Only deals with the current tab page. See |win_findbuf()| for +--- finding more. +--- +--- @param buf any +--- @return integer +function vim.fn.bufwinid(buf) end + +--- Like |bufwinid()| but return the window number instead of the +--- |window-ID|. +--- If buffer {buf} doesn't exist or there is no such window, -1 +--- is returned. Example: >vim +--- +--- echo "A window containing buffer 1 is " .. (bufwinnr(1)) +--- +--- <The number can be used with |CTRL-W_w| and ":wincmd w" +--- |:wincmd|. +--- +--- @param buf any +--- @return integer +function vim.fn.bufwinnr(buf) end + +--- Return the line number that contains the character at byte +--- count {byte} in the current buffer. This includes the +--- end-of-line character, depending on the 'fileformat' option +--- for the current buffer. The first character has byte count +--- one. +--- Also see |line2byte()|, |go| and |:goto|. +--- +--- Returns -1 if the {byte} value is invalid. +--- +--- @param byte any +--- @return integer +function vim.fn.byte2line(byte) end + +--- Return byte index of the {nr}th character in the String +--- {expr}. Use zero for the first character, it then returns +--- zero. +--- If there are no multibyte characters the returned value is +--- equal to {nr}. +--- Composing characters are not counted separately, their byte +--- length is added to the preceding base character. See +--- |byteidxcomp()| below for counting composing characters +--- separately. +--- When {utf16} is present and TRUE, {nr} is used as the UTF-16 +--- index in the String {expr} instead of as the character index. +--- The UTF-16 index is the index in the string when it is encoded +--- with 16-bit words. If the specified UTF-16 index is in the +--- middle of a character (e.g. in a 4-byte character), then the +--- byte index of the first byte in the character is returned. +--- Refer to |string-offset-encoding| for more information. +--- Example : >vim +--- echo matchstr(str, ".", byteidx(str, 3)) +--- <will display the fourth character. Another way to do the +--- same: >vim +--- let s = strpart(str, byteidx(str, 3)) +--- echo strpart(s, 0, byteidx(s, 1)) +--- <Also see |strgetchar()| and |strcharpart()|. +--- +--- If there are less than {nr} characters -1 is returned. +--- If there are exactly {nr} characters the length of the string +--- in bytes is returned. +--- See |charidx()| and |utf16idx()| for getting the character and +--- UTF-16 index respectively from the byte index. +--- Examples: >vim +--- echo byteidx('a😊😊', 2) " returns 5 +--- echo byteidx('a😊😊', 2, 1) " returns 1 +--- echo byteidx('a😊😊', 3, 1) " returns 5 +--- < +--- +--- @param expr any +--- @param nr integer +--- @param utf16? any +--- @return integer +function vim.fn.byteidx(expr, nr, utf16) end + +--- Like byteidx(), except that a composing character is counted +--- as a separate character. Example: >vim +--- let s = 'e' .. nr2char(0x301) +--- echo byteidx(s, 1) +--- echo byteidxcomp(s, 1) +--- echo byteidxcomp(s, 2) +--- <The first and third echo result in 3 ('e' plus composing +--- character is 3 bytes), the second echo results in 1 ('e' is +--- one byte). +--- +--- @param expr any +--- @param nr integer +--- @param utf16? any +--- @return integer +function vim.fn.byteidxcomp(expr, nr, utf16) end + +--- Call function {func} with the items in |List| {arglist} as +--- arguments. +--- {func} can either be a |Funcref| or the name of a function. +--- a:firstline and a:lastline are set to the cursor line. +--- Returns the return value of the called function. +--- {dict} is for functions with the "dict" attribute. It will be +--- used to set the local variable "self". |Dictionary-function| +--- +--- @param func any +--- @param arglist any +--- @param dict? any +--- @return any +function vim.fn.call(func, arglist, dict) end + +--- Return the smallest integral value greater than or equal to +--- {expr} as a |Float| (round up). +--- {expr} must evaluate to a |Float| or a |Number|. +--- Examples: >vim +--- echo ceil(1.456) +--- < 2.0 >vim +--- echo ceil(-5.456) +--- < -5.0 >vim +--- echo ceil(4.0) +--- < 4.0 +--- +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- +--- @param expr any +--- @return number +function vim.fn.ceil(expr) end + +--- Close a channel or a specific stream associated with it. +--- For a job, {stream} can be one of "stdin", "stdout", +--- "stderr" or "rpc" (closes stdin/stdout for a job started +--- with `"rpc":v:true`) If {stream} is omitted, all streams +--- are closed. If the channel is a pty, this will then close the +--- pty master, sending SIGHUP to the job process. +--- For a socket, there is only one stream, and {stream} should be +--- omitted. +--- +--- @param id any +--- @param stream? any +--- @return 0|1 +function vim.fn.chanclose(id, stream) end + +--- Return the number of the most recent change. This is the same +--- number as what is displayed with |:undolist| and can be used +--- with the |:undo| command. +--- When a change was made it is the number of that change. After +--- redo it is the number of the redone change. After undo it is +--- one less than the number of the undone change. +--- Returns 0 if the undo list is empty. +--- +--- @return integer +function vim.fn.changenr() end + +--- Send data to channel {id}. For a job, it writes it to the +--- stdin of the process. For the stdio channel |channel-stdio|, +--- it writes to Nvim's stdout. Returns the number of bytes +--- written if the write succeeded, 0 otherwise. +--- See |channel-bytes| for more information. +--- +--- {data} may be a string, string convertible, |Blob|, or a list. +--- If {data} is a list, the items will be joined by newlines; any +--- newlines in an item will be sent as NUL. To send a final +--- newline, include a final empty string. Example: >vim +--- call chansend(id, ["abc", "123\n456", ""]) +--- <will send "abc<NL>123<NUL>456<NL>". +--- +--- chansend() writes raw data, not RPC messages. If the channel +--- was created with `"rpc":v:true` then the channel expects RPC +--- messages, use |rpcnotify()| and |rpcrequest()| instead. +--- +--- @param id any +--- @param data any +--- @return 0|1 +function vim.fn.chansend(id, data) end + +--- Return Number value of the first char in {string}. +--- Examples: >vim +--- echo char2nr(" ") " returns 32 +--- echo char2nr("ABC") " returns 65 +--- echo char2nr("á") " returns 225 +--- echo char2nr("á"[0]) " returns 195 +--- echo char2nr("\<M-x>") " returns 128 +--- <Non-ASCII characters are always treated as UTF-8 characters. +--- {utf8} is ignored, it exists only for backwards-compatibility. +--- A combining character is a separate character. +--- |nr2char()| does the opposite. +--- +--- Returns 0 if {string} is not a |String|. +--- +--- @param string string +--- @param utf8? any +--- @return 0|1 +function vim.fn.char2nr(string, utf8) end + +--- Return the character class of the first character in {string}. +--- The character class is one of: +--- 0 blank +--- 1 punctuation +--- 2 word character +--- 3 emoji +--- other specific Unicode class +--- The class is used in patterns and word motions. +--- Returns 0 if {string} is not a |String|. +--- +--- @param string string +--- @return 0|1|2|3|'other' +function vim.fn.charclass(string) end + +--- Same as |col()| but returns the character index of the column +--- position given with {expr} instead of the byte position. +--- +--- Example: +--- With the cursor on '세' in line 5 with text "여보세요": >vim +--- echo charcol('.') " returns 3 +--- echo col('.') " returns 7 +--- +--- @param expr any +--- @param winid? integer +--- @return integer +function vim.fn.charcol(expr, winid) end + +--- Return the character index of the byte at {idx} in {string}. +--- The index of the first character is zero. +--- If there are no multibyte characters the returned value is +--- equal to {idx}. +--- +--- When {countcc} is omitted or |FALSE|, then composing characters +--- are not counted separately, their byte length is added to the +--- preceding base character. +--- When {countcc} is |TRUE|, then composing characters are +--- counted as separate characters. +--- +--- When {utf16} is present and TRUE, {idx} is used as the UTF-16 +--- index in the String {expr} instead of as the byte index. +--- +--- Returns -1 if the arguments are invalid or if there are less +--- than {idx} bytes. If there are exactly {idx} bytes the length +--- of the string in characters is returned. +--- +--- An error is given and -1 is returned if the first argument is +--- not a string, the second argument is not a number or when the +--- third argument is present and is not zero or one. +--- +--- See |byteidx()| and |byteidxcomp()| for getting the byte index +--- from the character index and |utf16idx()| for getting the +--- UTF-16 index from the character index. +--- Refer to |string-offset-encoding| for more information. +--- Examples: >vim +--- echo charidx('áb́ć', 3) " returns 1 +--- echo charidx('áb́ć', 6, 1) " returns 4 +--- echo charidx('áb́ć', 16) " returns -1 +--- echo charidx('a😊😊', 4, 0, 1) " returns 2 +--- < +--- +--- @param string string +--- @param idx integer +--- @param countcc? any +--- @param utf16? any +--- @return integer +function vim.fn.charidx(string, idx, countcc, utf16) end + +--- Change the current working directory to {dir}. The scope of +--- the directory change depends on the directory of the current +--- window: +--- - If the current window has a window-local directory +--- (|:lcd|), then changes the window local directory. +--- - Otherwise, if the current tabpage has a local +--- directory (|:tcd|) then changes the tabpage local +--- directory. +--- - Otherwise, changes the global directory. +--- {dir} must be a String. +--- If successful, returns the previous working directory. Pass +--- this to another chdir() to restore the directory. +--- On failure, returns an empty string. +--- +--- Example: >vim +--- let save_dir = chdir(newdir) +--- if save_dir != "" +--- " ... do some work +--- call chdir(save_dir) +--- endif +--- +--- @param dir string +--- @return string +function vim.fn.chdir(dir) end + +--- Get the amount of indent for line {lnum} according the C +--- indenting rules, as with 'cindent'. +--- The indent is counted in spaces, the value of 'tabstop' is +--- relevant. {lnum} is used just like in |getline()|. +--- When {lnum} is invalid -1 is returned. +--- See |C-indenting|. +--- +--- @param lnum integer +--- @return integer +function vim.fn.cindent(lnum) end + +--- Clears all matches previously defined for the current window +--- by |matchadd()| and the |:match| commands. +--- If {win} is specified, use the window with this number or +--- window ID instead of the current window. +--- +--- @param win? any +function vim.fn.clearmatches(win) end + +--- The result is a Number, which is the byte index of the column +--- position given with {expr}. The accepted positions are: +--- . the cursor position +--- $ the end of the cursor line (the result is the +--- number of bytes in the cursor line plus one) +--- 'x position of mark x (if the mark is not set, 0 is +--- returned) +--- v In Visual mode: the start of the Visual area (the +--- cursor is the end). When not in Visual mode +--- returns the cursor position. Differs from |'<| in +--- that it's updated right away. +--- Additionally {expr} can be [lnum, col]: a |List| with the line +--- and column number. Most useful when the column is "$", to get +--- the last column of a specific line. When "lnum" or "col" is +--- out of range then col() returns zero. +--- With the optional {winid} argument the values are obtained for +--- that window instead of the current window. +--- To get the line number use |line()|. To get both use +--- |getpos()|. +--- For the screen column position use |virtcol()|. For the +--- character position use |charcol()|. +--- Note that only marks in the current file can be used. +--- Examples: >vim +--- echo col(".") " column of cursor +--- echo col("$") " length of cursor line plus one +--- echo col("'t") " column of mark t +--- echo col("'" .. markname) " column of mark markname +--- <The first column is 1. Returns 0 if {expr} is invalid or when +--- the window with ID {winid} is not found. +--- For an uppercase mark the column may actually be in another +--- buffer. +--- For the cursor position, when 'virtualedit' is active, the +--- column is one higher if the cursor is after the end of the +--- line. Also, when using a <Cmd> mapping the cursor isn't +--- moved, this can be used to obtain the column in Insert mode: >vim +--- imap <F2> <Cmd>echo col(".").."\n"<CR> +--- +--- @param expr any +--- @param winid? integer +--- @return integer +function vim.fn.col(expr, winid) end + +--- Set the matches for Insert mode completion. +--- Can only be used in Insert mode. You need to use a mapping +--- with CTRL-R = (see |i_CTRL-R|). It does not work after CTRL-O +--- or with an expression mapping. +--- {startcol} is the byte offset in the line where the completed +--- text start. The text up to the cursor is the original text +--- that will be replaced by the matches. Use col('.') for an +--- empty string. "col('.') - 1" will replace one character by a +--- match. +--- {matches} must be a |List|. Each |List| item is one match. +--- See |complete-items| for the kind of items that are possible. +--- "longest" in 'completeopt' is ignored. +--- Note that the after calling this function you need to avoid +--- inserting anything that would cause completion to stop. +--- The match can be selected with CTRL-N and CTRL-P as usual with +--- Insert mode completion. The popup menu will appear if +--- specified, see |ins-completion-menu|. +--- Example: >vim +--- inoremap <F5> <C-R>=ListMonths()<CR> +--- +--- func ListMonths() +--- call complete(col('.'), ['January', 'February', 'March', +--- \ 'April', 'May', 'June', 'July', 'August', 'September', +--- \ 'October', 'November', 'December']) +--- return '' +--- endfunc +--- <This isn't very useful, but it shows how it works. Note that +--- an empty string is returned to avoid a zero being inserted. +--- +--- @param startcol any +--- @param matches any +function vim.fn.complete(startcol, matches) end + +--- Add {expr} to the list of matches. Only to be used by the +--- function specified with the 'completefunc' option. +--- Returns 0 for failure (empty string or out of memory), +--- 1 when the match was added, 2 when the match was already in +--- the list. +--- See |complete-functions| for an explanation of {expr}. It is +--- the same as one item in the list that 'omnifunc' would return. +--- +--- @param expr any +--- @return 0|1|2 +function vim.fn.complete_add(expr) end + +--- Check for a key typed while looking for completion matches. +--- This is to be used when looking for matches takes some time. +--- Returns |TRUE| when searching for matches is to be aborted, +--- zero otherwise. +--- Only to be used by the function specified with the +--- 'completefunc' option. +--- +--- @return 0|1 +function vim.fn.complete_check() end + +--- Returns a |Dictionary| with information about Insert mode +--- completion. See |ins-completion|. +--- The items are: +--- mode Current completion mode name string. +--- See |complete_info_mode| for the values. +--- pum_visible |TRUE| if popup menu is visible. +--- See |pumvisible()|. +--- items List of completion matches. Each item is a +--- dictionary containing the entries "word", +--- "abbr", "menu", "kind", "info" and "user_data". +--- See |complete-items|. +--- selected Selected item index. First index is zero. +--- Index is -1 if no item is selected (showing +--- typed text only, or the last completion after +--- no item is selected when using the <Up> or +--- <Down> keys) +--- inserted Inserted string. [NOT IMPLEMENTED YET] +--- +--- *complete_info_mode* +--- mode values are: +--- "" Not in completion mode +--- "keyword" Keyword completion |i_CTRL-X_CTRL-N| +--- "ctrl_x" Just pressed CTRL-X |i_CTRL-X| +--- "scroll" Scrolling with |i_CTRL-X_CTRL-E| or +--- |i_CTRL-X_CTRL-Y| +--- "whole_line" Whole lines |i_CTRL-X_CTRL-L| +--- "files" File names |i_CTRL-X_CTRL-F| +--- "tags" Tags |i_CTRL-X_CTRL-]| +--- "path_defines" Definition completion |i_CTRL-X_CTRL-D| +--- "path_patterns" Include completion |i_CTRL-X_CTRL-I| +--- "dictionary" Dictionary |i_CTRL-X_CTRL-K| +--- "thesaurus" Thesaurus |i_CTRL-X_CTRL-T| +--- "cmdline" Vim Command line |i_CTRL-X_CTRL-V| +--- "function" User defined completion |i_CTRL-X_CTRL-U| +--- "omni" Omni completion |i_CTRL-X_CTRL-O| +--- "spell" Spelling suggestions |i_CTRL-X_s| +--- "eval" |complete()| completion +--- "unknown" Other internal modes +--- +--- If the optional {what} list argument is supplied, then only +--- the items listed in {what} are returned. Unsupported items in +--- {what} are silently ignored. +--- +--- To get the position and size of the popup menu, see +--- |pum_getpos()|. It's also available in |v:event| during the +--- |CompleteChanged| event. +--- +--- Returns an empty |Dictionary| on error. +--- +--- Examples: >vim +--- " Get all items +--- call complete_info() +--- " Get only 'mode' +--- call complete_info(['mode']) +--- " Get only 'mode' and 'pum_visible' +--- call complete_info(['mode', 'pum_visible']) +--- +--- @param what? any +--- @return table +function vim.fn.complete_info(what) end + +--- confirm() offers the user a dialog, from which a choice can be +--- made. It returns the number of the choice. For the first +--- choice this is 1. +--- +--- {msg} is displayed in a dialog with {choices} as the +--- alternatives. When {choices} is missing or empty, "&OK" is +--- used (and translated). +--- {msg} is a String, use '\n' to include a newline. Only on +--- some systems the string is wrapped when it doesn't fit. +--- +--- {choices} is a String, with the individual choices separated +--- by '\n', e.g. >vim +--- confirm("Save changes?", "&Yes\n&No\n&Cancel") +--- <The letter after the '&' is the shortcut key for that choice. +--- Thus you can type 'c' to select "Cancel". The shortcut does +--- not need to be the first letter: >vim +--- confirm("file has been modified", "&Save\nSave &All") +--- <For the console, the first letter of each choice is used as +--- the default shortcut key. Case is ignored. +--- +--- The optional {type} String argument gives the type of dialog. +--- It can be one of these values: "Error", "Question", "Info", +--- "Warning" or "Generic". Only the first character is relevant. +--- When {type} is omitted, "Generic" is used. +--- +--- The optional {type} argument gives the type of dialog. This +--- is only used for the icon of the Win32 GUI. It can be one of +--- these values: "Error", "Question", "Info", "Warning" or +--- "Generic". Only the first character is relevant. +--- When {type} is omitted, "Generic" is used. +--- +--- If the user aborts the dialog by pressing <Esc>, CTRL-C, +--- or another valid interrupt key, confirm() returns 0. +--- +--- An example: >vim +--- let choice = confirm("What do you want?", +--- \ "&Apples\n&Oranges\n&Bananas", 2) +--- if choice == 0 +--- echo "make up your mind!" +--- elseif choice == 3 +--- echo "tasteful" +--- else +--- echo "I prefer bananas myself." +--- endif +--- <In a GUI dialog, buttons are used. The layout of the buttons +--- depends on the 'v' flag in 'guioptions'. If it is included, +--- the buttons are always put vertically. Otherwise, confirm() +--- tries to put the buttons in one horizontal line. If they +--- don't fit, a vertical layout is used anyway. For some systems +--- the horizontal layout is always used. +--- +--- @param msg any +--- @param choices? any +--- @param default? any +--- @param type? any +--- @return integer +function vim.fn.confirm(msg, choices, default, type) end + +--- Make a copy of {expr}. For Numbers and Strings this isn't +--- different from using {expr} directly. +--- When {expr} is a |List| a shallow copy is created. This means +--- that the original |List| can be changed without changing the +--- copy, and vice versa. But the items are identical, thus +--- changing an item changes the contents of both |Lists|. +--- A |Dictionary| is copied in a similar way as a |List|. +--- Also see |deepcopy()|. +--- +--- @param expr any +--- @return any +function vim.fn.copy(expr) end + +--- Return the cosine of {expr}, measured in radians, as a |Float|. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo cos(100) +--- < 0.862319 >vim +--- echo cos(-4.01) +--- < -0.646043 +--- +--- @param expr any +--- @return number +function vim.fn.cos(expr) end + +--- Return the hyperbolic cosine of {expr} as a |Float| in the range +--- [1, inf]. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo cosh(0.5) +--- < 1.127626 >vim +--- echo cosh(-0.5) +--- < -1.127626 +--- +--- @param expr any +--- @return number +function vim.fn.cosh(expr) end + +--- Return the number of times an item with value {expr} appears +--- in |String|, |List| or |Dictionary| {comp}. +--- +--- If {start} is given then start with the item with this index. +--- {start} can only be used with a |List|. +--- +--- When {ic} is given and it's |TRUE| then case is ignored. +--- +--- When {comp} is a string then the number of not overlapping +--- occurrences of {expr} is returned. Zero is returned when +--- {expr} is an empty string. +--- +--- @param comp any +--- @param expr any +--- @param ic? any +--- @param start? any +--- @return integer +function vim.fn.count(comp, expr, ic, start) end + +--- Returns a |Dictionary| representing the |context| at {index} +--- from the top of the |context-stack| (see |context-dict|). +--- If {index} is not given, it is assumed to be 0 (i.e.: top). +--- +--- @param index? any +--- @return table +function vim.fn.ctxget(index) end + +--- Pops and restores the |context| at the top of the +--- |context-stack|. +--- +--- @return any +function vim.fn.ctxpop() end + +--- Pushes the current editor state (|context|) on the +--- |context-stack|. +--- If {types} is given and is a |List| of |String|s, it specifies +--- which |context-types| to include in the pushed context. +--- Otherwise, all context types are included. +--- +--- @param types? any +--- @return any +function vim.fn.ctxpush(types) end + +--- Sets the |context| at {index} from the top of the +--- |context-stack| to that represented by {context}. +--- {context} is a Dictionary with context data (|context-dict|). +--- If {index} is not given, it is assumed to be 0 (i.e.: top). +--- +--- @param context any +--- @param index? any +--- @return any +function vim.fn.ctxset(context, index) end + +--- Returns the size of the |context-stack|. +--- +--- @return any +function vim.fn.ctxsize() end + +--- @param lnum integer +--- @param col? integer +--- @param off? any +--- @return any +function vim.fn.cursor(lnum, col, off) end + +--- Positions the cursor at the column (byte count) {col} in the +--- line {lnum}. The first column is one. +--- +--- When there is one argument {list} this is used as a |List| +--- with two, three or four item: +--- [{lnum}, {col}] +--- [{lnum}, {col}, {off}] +--- [{lnum}, {col}, {off}, {curswant}] +--- This is like the return value of |getpos()| or |getcurpos()|, +--- but without the first item. +--- +--- To position the cursor using {col} as the character count, use +--- |setcursorcharpos()|. +--- +--- Does not change the jumplist. +--- {lnum} is used like with |getline()|, except that if {lnum} is +--- zero, the cursor will stay in the current line. +--- If {lnum} is greater than the number of lines in the buffer, +--- the cursor will be positioned at the last line in the buffer. +--- If {col} is greater than the number of bytes in the line, +--- the cursor will be positioned at the last character in the +--- line. +--- If {col} is zero, the cursor will stay in the current column. +--- If {curswant} is given it is used to set the preferred column +--- for vertical movement. Otherwise {col} is used. +--- +--- When 'virtualedit' is used {off} specifies the offset in +--- screen columns from the start of the character. E.g., a +--- position within a <Tab> or after the last character. +--- Returns 0 when the position could be set, -1 otherwise. +--- +--- @param list any +--- @return any +function vim.fn.cursor(list) end + +--- Specifically used to interrupt a program being debugged. It +--- will cause process {pid} to get a SIGTRAP. Behavior for other +--- processes is undefined. See |terminal-debug|. +--- (Sends a SIGINT to a process {pid} other than MS-Windows) +--- +--- Returns |TRUE| if successfully interrupted the program. +--- Otherwise returns |FALSE|. +--- +--- @param pid any +--- @return any +function vim.fn.debugbreak(pid) end + +--- Make a copy of {expr}. For Numbers and Strings this isn't +--- different from using {expr} directly. +--- When {expr} is a |List| a full copy is created. This means +--- that the original |List| can be changed without changing the +--- copy, and vice versa. When an item is a |List|, a copy for it +--- is made, recursively. Thus changing an item in the copy does +--- not change the contents of the original |List|. +--- +--- When {noref} is omitted or zero a contained |List| or +--- |Dictionary| is only copied once. All references point to +--- this single copy. With {noref} set to 1 every occurrence of a +--- |List| or |Dictionary| results in a new copy. This also means +--- that a cyclic reference causes deepcopy() to fail. +--- *E724* +--- Nesting is possible up to 100 levels. When there is an item +--- that refers back to a higher level making a deep copy with +--- {noref} set to 1 will fail. +--- Also see |copy()|. +--- +--- @param expr any +--- @param noref? any +--- @return any +function vim.fn.deepcopy(expr, noref) end + +--- Without {flags} or with {flags} empty: Deletes the file by the +--- name {fname}. +--- +--- This also works when {fname} is a symbolic link. The symbolic +--- link itself is deleted, not what it points to. +--- +--- When {flags} is "d": Deletes the directory by the name +--- {fname}. This fails when directory {fname} is not empty. +--- +--- When {flags} is "rf": Deletes the directory by the name +--- {fname} and everything in it, recursively. BE CAREFUL! +--- Note: on MS-Windows it is not possible to delete a directory +--- that is being used. +--- +--- The result is a Number, which is 0/false if the delete +--- operation was successful and -1/true when the deletion failed +--- or partly failed. +--- +--- @param fname string +--- @param flags? string +--- @return integer +function vim.fn.delete(fname, flags) end + +--- Delete lines {first} to {last} (inclusive) from buffer {buf}. +--- If {last} is omitted then delete line {first} only. +--- On success 0 is returned, on failure 1 is returned. +--- +--- This function works only for loaded buffers. First call +--- |bufload()| if needed. +--- +--- For the use of {buf}, see |bufname()| above. +--- +--- {first} and {last} are used like with |getline()|. Note that +--- when using |line()| this refers to the current buffer. Use "$" +--- to refer to the last line in buffer {buf}. +--- +--- @param buf any +--- @param first any +--- @param last? any +--- @return any +function vim.fn.deletebufline(buf, first, last) end + +--- Adds a watcher to a dictionary. A dictionary watcher is +--- identified by three components: +--- +--- - A dictionary({dict}); +--- - A key pattern({pattern}). +--- - A function({callback}). +--- +--- After this is called, every change on {dict} and on keys +--- matching {pattern} will result in {callback} being invoked. +--- +--- For example, to watch all global variables: >vim +--- silent! call dictwatcherdel(g:, '*', 'OnDictChanged') +--- function! OnDictChanged(d,k,z) +--- echomsg string(a:k) string(a:z) +--- endfunction +--- call dictwatcheradd(g:, '*', 'OnDictChanged') +--- < +--- For now {pattern} only accepts very simple patterns that can +--- contain a "*" at the end of the string, in which case it will +--- match every key that begins with the substring before the "*". +--- That means if "*" is not the last character of {pattern}, only +--- keys that are exactly equal as {pattern} will be matched. +--- +--- The {callback} receives three arguments: +--- +--- - The dictionary being watched. +--- - The key which changed. +--- - A dictionary containing the new and old values for the key. +--- +--- The type of change can be determined by examining the keys +--- present on the third argument: +--- +--- - If contains both `old` and `new`, the key was updated. +--- - If it contains only `new`, the key was added. +--- - If it contains only `old`, the key was deleted. +--- +--- This function can be used by plugins to implement options with +--- validation and parsing logic. +--- +--- @param dict any +--- @param pattern any +--- @param callback any +--- @return any +function vim.fn.dictwatcheradd(dict, pattern, callback) end + +--- Removes a watcher added with |dictwatcheradd()|. All three +--- arguments must match the ones passed to |dictwatcheradd()| in +--- order for the watcher to be successfully deleted. +--- +--- @param dict any +--- @param pattern any +--- @param callback any +--- @return any +function vim.fn.dictwatcherdel(dict, pattern, callback) end + +--- Returns |TRUE| when autocommands are being executed and the +--- FileType event has been triggered at least once. Can be used +--- to avoid triggering the FileType event again in the scripts +--- that detect the file type. |FileType| +--- Returns |FALSE| when `:setf FALLBACK` was used. +--- When editing another file, the counter is reset, thus this +--- really checks if the FileType event has been triggered for the +--- current buffer. This allows an autocommand that starts +--- editing another buffer to set 'filetype' and load a syntax +--- file. +--- +--- @return any +function vim.fn.did_filetype() end + +--- Returns the number of filler lines above line {lnum}. +--- These are the lines that were inserted at this point in +--- another diff'ed window. These filler lines are shown in the +--- display but don't exist in the buffer. +--- {lnum} is used like with |getline()|. Thus "." is the current +--- line, "'m" mark m, etc. +--- Returns 0 if the current window is not in diff mode. +--- +--- @param lnum integer +--- @return any +function vim.fn.diff_filler(lnum) end + +--- Returns the highlight ID for diff mode at line {lnum} column +--- {col} (byte index). When the current line does not have a +--- diff change zero is returned. +--- {lnum} is used like with |getline()|. Thus "." is the current +--- line, "'m" mark m, etc. +--- {col} is 1 for the leftmost column, {lnum} is 1 for the first +--- line. +--- The highlight ID can be used with |synIDattr()| to obtain +--- syntax information about the highlighting. +--- +--- @param lnum integer +--- @param col integer +--- @return any +function vim.fn.diff_hlID(lnum, col) end + +--- Return the digraph of {chars}. This should be a string with +--- exactly two characters. If {chars} are not just two +--- characters, or the digraph of {chars} does not exist, an error +--- is given and an empty string is returned. +--- +--- Also see |digraph_getlist()|. +--- +--- Examples: >vim +--- " Get a built-in digraph +--- echo digraph_get('00') " Returns '∞' +--- +--- " Get a user-defined digraph +--- call digraph_set('aa', 'あ') +--- echo digraph_get('aa') " Returns 'あ' +--- < +--- +--- @param chars any +--- @return any +function vim.fn.digraph_get(chars) end + +--- Return a list of digraphs. If the {listall} argument is given +--- and it is TRUE, return all digraphs, including the default +--- digraphs. Otherwise, return only user-defined digraphs. +--- +--- Also see |digraph_get()|. +--- +--- Examples: >vim +--- " Get user-defined digraphs +--- echo digraph_getlist() +--- +--- " Get all the digraphs, including default digraphs +--- echo digraph_getlist(1) +--- < +--- +--- @param listall? any +--- @return any +function vim.fn.digraph_getlist(listall) end + +--- Add digraph {chars} to the list. {chars} must be a string +--- with two characters. {digraph} is a string with one UTF-8 +--- encoded character. *E1215* +--- Be careful, composing characters are NOT ignored. This +--- function is similar to |:digraphs| command, but useful to add +--- digraphs start with a white space. +--- +--- The function result is v:true if |digraph| is registered. If +--- this fails an error message is given and v:false is returned. +--- +--- If you want to define multiple digraphs at once, you can use +--- |digraph_setlist()|. +--- +--- Example: >vim +--- call digraph_set(' ', 'あ') +--- < +--- Can be used as a |method|: >vim +--- GetString()->digraph_set('あ') +--- < +--- +--- @param chars any +--- @param digraph any +--- @return any +function vim.fn.digraph_set(chars, digraph) end + +--- Similar to |digraph_set()| but this function can add multiple +--- digraphs at once. {digraphlist} is a list composed of lists, +--- where each list contains two strings with {chars} and +--- {digraph} as in |digraph_set()|. *E1216* +--- Example: >vim +--- call digraph_setlist([['aa', 'あ'], ['ii', 'い']]) +--- < +--- It is similar to the following: >vim +--- for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']] +--- call digraph_set(chars, digraph) +--- endfor +--- <Except that the function returns after the first error, +--- following digraphs will not be added. +--- +--- Can be used as a |method|: >vim +--- GetList()->digraph_setlist() +--- < +--- +--- @param digraphlist any +--- @return any +function vim.fn.digraph_setlist(digraphlist) end + +--- Return the Number 1 if {expr} is empty, zero otherwise. +--- - A |List| or |Dictionary| is empty when it does not have any +--- items. +--- - A |String| is empty when its length is zero. +--- - A |Number| and |Float| are empty when their value is zero. +--- - |v:false| and |v:null| are empty, |v:true| is not. +--- - A |Blob| is empty when its length is zero. +--- +--- @param expr any +--- @return any +function vim.fn.empty(expr) end + +--- Return all of environment variables as dictionary. You can +--- check if an environment variable exists like this: >vim +--- echo has_key(environ(), 'HOME') +--- <Note that the variable name may be CamelCase; to ignore case +--- use this: >vim +--- echo index(keys(environ()), 'HOME', 0, 1) != -1 +--- < +--- +--- @return any +function vim.fn.environ() end + +--- Escape the characters in {chars} that occur in {string} with a +--- backslash. Example: >vim +--- echo escape('c:\program files\vim', ' \') +--- <results in: > +--- c:\\program\ files\\vim +--- <Also see |shellescape()| and |fnameescape()|. +--- +--- @param string string +--- @param chars any +--- @return any +function vim.fn.escape(string, chars) end + +--- Evaluate {string} and return the result. Especially useful to +--- turn the result of |string()| back into the original value. +--- This works for Numbers, Floats, Strings, Blobs and composites +--- of them. Also works for |Funcref|s that refer to existing +--- functions. +--- +--- @param string string +--- @return any +function vim.fn.eval(string) end + +--- Returns 1 when inside an event handler. That is that Vim got +--- interrupted while waiting for the user to type a character, +--- e.g., when dropping a file on Vim. This means interactive +--- commands cannot be used. Otherwise zero is returned. +--- +--- @return any +function vim.fn.eventhandler() end + +--- This function checks if an executable with the name {expr} +--- exists. {expr} must be the name of the program without any +--- arguments. +--- executable() uses the value of $PATH and/or the normal +--- searchpath for programs. *PATHEXT* +--- On MS-Windows the ".exe", ".bat", etc. can optionally be +--- included. Then the extensions in $PATHEXT are tried. Thus if +--- "foo.exe" does not exist, "foo.exe.bat" can be found. If +--- $PATHEXT is not set then ".exe;.com;.bat;.cmd" is used. A dot +--- by itself can be used in $PATHEXT to try using the name +--- without an extension. When 'shell' looks like a Unix shell, +--- then the name is also tried without adding an extension. +--- On MS-Windows it only checks if the file exists and is not a +--- directory, not if it's really executable. +--- On Windows an executable in the same directory as Vim is +--- always found (it is added to $PATH at |startup|). +--- The result is a Number: +--- 1 exists +--- 0 does not exist +--- -1 not implemented on this system +--- |exepath()| can be used to get the full path of an executable. +--- +--- @param expr any +--- @return 0|1|-1 +function vim.fn.executable(expr) end + +--- Execute {command} and capture its output. +--- If {command} is a |String|, returns {command} output. +--- If {command} is a |List|, returns concatenated outputs. +--- Line continuations in {command} are not recognized. +--- Examples: >vim +--- echo execute('echon "foo"') +--- < foo >vim +--- echo execute(['echon "foo"', 'echon "bar"']) +--- < foobar +--- +--- The optional {silent} argument can have these values: +--- "" no `:silent` used +--- "silent" `:silent` used +--- "silent!" `:silent!` used +--- The default is "silent". Note that with "silent!", unlike +--- `:redir`, error messages are dropped. +--- +--- To get a list of lines use `split()` on the result: >vim +--- execute('args')->split("\n") +--- +--- <This function is not available in the |sandbox|. +--- Note: If nested, an outer execute() will not observe output of +--- the inner calls. +--- Note: Text attributes (highlights) are not captured. +--- To execute a command in another window than the current one +--- use `win_execute()`. +--- +--- @param command string|string[] +--- @param silent? ''|'silent'|'silent!' +--- @return string +function vim.fn.execute(command, silent) end + +--- Returns the full path of {expr} if it is an executable and +--- given as a (partial or full) path or is found in $PATH. +--- Returns empty string otherwise. +--- If {expr} starts with "./" the |current-directory| is used. +--- +--- @param expr any +--- @return any +function vim.fn.exepath(expr) end + +--- The result is a Number, which is |TRUE| if {expr} is +--- defined, zero otherwise. +--- +--- For checking for a supported feature use |has()|. +--- For checking if a file exists use |filereadable()|. +--- +--- The {expr} argument is a string, which contains one of these: +--- varname internal variable (see +--- dict.key |internal-variables|). Also works +--- list[i] for |curly-braces-names|, |Dictionary| +--- entries, |List| items, etc. +--- Beware that evaluating an index may +--- cause an error message for an invalid +--- expression. E.g.: >vim +--- let l = [1, 2, 3] +--- echo exists("l[5]") +--- < 0 >vim +--- echo exists("l[xx]") +--- < E121: Undefined variable: xx +--- 0 +--- &option-name Vim option (only checks if it exists, +--- not if it really works) +--- +option-name Vim option that works. +--- $ENVNAME environment variable (could also be +--- done by comparing with an empty +--- string) +--- `*funcname` built-in function (see |functions|) +--- or user defined function (see +--- |user-function|). Also works for a +--- variable that is a Funcref. +--- :cmdname Ex command: built-in command, user +--- command or command modifier |:command|. +--- Returns: +--- 1 for match with start of a command +--- 2 full match with a command +--- 3 matches several user commands +--- To check for a supported command +--- always check the return value to be 2. +--- :2match The |:2match| command. +--- :3match The |:3match| command (but you +--- probably should not use it, it is +--- reserved for internal usage) +--- #event autocommand defined for this event +--- #event#pattern autocommand defined for this event and +--- pattern (the pattern is taken +--- literally and compared to the +--- autocommand patterns character by +--- character) +--- #group autocommand group exists +--- #group#event autocommand defined for this group and +--- event. +--- #group#event#pattern +--- autocommand defined for this group, +--- event and pattern. +--- ##event autocommand for this event is +--- supported. +--- +--- Examples: >vim +--- echo exists("&mouse") +--- echo exists("$HOSTNAME") +--- echo exists("*strftime") +--- echo exists("*s:MyFunc") +--- echo exists("*MyFunc") +--- echo exists("bufcount") +--- echo exists(":Make") +--- echo exists("#CursorHold") +--- echo exists("#BufReadPre#*.gz") +--- echo exists("#filetypeindent") +--- echo exists("#filetypeindent#FileType") +--- echo exists("#filetypeindent#FileType#*") +--- echo exists("##ColorScheme") +--- <There must be no space between the symbol (&/$/*/#) and the +--- name. +--- There must be no extra characters after the name, although in +--- a few cases this is ignored. That may become stricter in the +--- future, thus don't count on it! +--- Working example: >vim +--- echo exists(":make") +--- <NOT working example: >vim +--- echo exists(":make install") +--- +--- <Note that the argument must be a string, not the name of the +--- variable itself. For example: >vim +--- echo exists(bufcount) +--- <This doesn't check for existence of the "bufcount" variable, +--- but gets the value of "bufcount", and checks if that exists. +--- +--- @param expr any +--- @return 0|1 +function vim.fn.exists(expr) end + +--- Return the exponential of {expr} as a |Float| in the range +--- [0, inf]. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo exp(2) +--- < 7.389056 >vim +--- echo exp(-1) +--- < 0.367879 +--- +--- @param expr any +--- @return any +function vim.fn.exp(expr) end + +--- Expand wildcards and the following special keywords in +--- {string}. 'wildignorecase' applies. +--- +--- If {list} is given and it is |TRUE|, a List will be returned. +--- Otherwise the result is a String and when there are several +--- matches, they are separated by <NL> characters. +--- +--- If the expansion fails, the result is an empty string. A name +--- for a non-existing file is not included, unless {string} does +--- not start with '%', '#' or '<', see below. +--- +--- When {string} starts with '%', '#' or '<', the expansion is +--- done like for the |cmdline-special| variables with their +--- associated modifiers. Here is a short overview: +--- +--- % current file name +--- # alternate file name +--- #n alternate file name n +--- <cfile> file name under the cursor +--- <afile> autocmd file name +--- <abuf> autocmd buffer number (as a String!) +--- <amatch> autocmd matched name +--- <cexpr> C expression under the cursor +--- <sfile> sourced script file or function name +--- <slnum> sourced script line number or function +--- line number +--- <sflnum> script file line number, also when in +--- a function +--- <SID> "<SNR>123_" where "123" is the +--- current script ID |<SID>| +--- <script> sourced script file, or script file +--- where the current function was defined +--- <stack> call stack +--- <cword> word under the cursor +--- <cWORD> WORD under the cursor +--- <client> the {clientid} of the last received +--- message +--- Modifiers: +--- :p expand to full path +--- :h head (last path component removed) +--- :t tail (last path component only) +--- :r root (one extension removed) +--- :e extension only +--- +--- Example: >vim +--- let &tags = expand("%:p:h") .. "/tags" +--- <Note that when expanding a string that starts with '%', '#' or +--- '<', any following text is ignored. This does NOT work: >vim +--- let doesntwork = expand("%:h.bak") +--- <Use this: >vim +--- let doeswork = expand("%:h") .. ".bak" +--- <Also note that expanding "<cfile>" and others only returns the +--- referenced file name without further expansion. If "<cfile>" +--- is "~/.cshrc", you need to do another expand() to have the +--- "~/" expanded into the path of the home directory: >vim +--- echo expand(expand("<cfile>")) +--- < +--- There cannot be white space between the variables and the +--- following modifier. The |fnamemodify()| function can be used +--- to modify normal file names. +--- +--- When using '%' or '#', and the current or alternate file name +--- is not defined, an empty string is used. Using "%:p" in a +--- buffer with no name, results in the current directory, with a +--- '/' added. +--- When 'verbose' is set then expanding '%', '#' and <> items +--- will result in an error message if the argument cannot be +--- expanded. +--- +--- When {string} does not start with '%', '#' or '<', it is +--- expanded like a file name is expanded on the command line. +--- 'suffixes' and 'wildignore' are used, unless the optional +--- {nosuf} argument is given and it is |TRUE|. +--- Names for non-existing files are included. The "**" item can +--- be used to search in a directory tree. For example, to find +--- all "README" files in the current directory and below: >vim +--- echo expand("**/README") +--- < +--- expand() can also be used to expand variables and environment +--- variables that are only known in a shell. But this can be +--- slow, because a shell may be used to do the expansion. See +--- |expr-env-expand|. +--- The expanded variable is still handled like a list of file +--- names. When an environment variable cannot be expanded, it is +--- left unchanged. Thus ":echo expand('$FOOBAR')" results in +--- "$FOOBAR". +--- +--- See |glob()| for finding existing files. See |system()| for +--- getting the raw output of an external command. +--- +--- @param string string +--- @param nosuf? boolean +--- @param list? any +--- @return string|string[] +function vim.fn.expand(string, nosuf, list) end + +--- Expand special items in String {string} like what is done for +--- an Ex command such as `:edit`. This expands special keywords, +--- like with |expand()|, and environment variables, anywhere in +--- {string}. "~user" and "~/path" are only expanded at the +--- start. +--- +--- The following items are supported in the {options} Dict +--- argument: +--- errmsg If set to TRUE, error messages are displayed +--- if an error is encountered during expansion. +--- By default, error messages are not displayed. +--- +--- Returns the expanded string. If an error is encountered +--- during expansion, the unmodified {string} is returned. +--- +--- Example: >vim +--- echo expandcmd('make %<.o') +--- < > +--- make /path/runtime/doc/builtin.o +--- < >vim +--- echo expandcmd('make %<.o', {'errmsg': v:true}) +--- < +--- +--- @param string string +--- @param options? table +--- @return any +function vim.fn.expandcmd(string, options) end + +--- {expr1} and {expr2} must be both |Lists| or both +--- |Dictionaries|. +--- +--- If they are |Lists|: Append {expr2} to {expr1}. +--- If {expr3} is given insert the items of {expr2} before the +--- item with index {expr3} in {expr1}. When {expr3} is zero +--- insert before the first item. When {expr3} is equal to +--- len({expr1}) then {expr2} is appended. +--- Examples: >vim +--- echo sort(extend(mylist, [7, 5])) +--- call extend(mylist, [2, 3], 1) +--- <When {expr1} is the same List as {expr2} then the number of +--- items copied is equal to the original length of the List. +--- E.g., when {expr3} is 1 you get N new copies of the first item +--- (where N is the original length of the List). +--- Use |add()| to concatenate one item to a list. To concatenate +--- two lists into a new list use the + operator: >vim +--- let newlist = [1, 2, 3] + [4, 5] +--- < +--- If they are |Dictionaries|: +--- Add all entries from {expr2} to {expr1}. +--- If a key exists in both {expr1} and {expr2} then {expr3} is +--- used to decide what to do: +--- {expr3} = "keep": keep the value of {expr1} +--- {expr3} = "force": use the value of {expr2} +--- {expr3} = "error": give an error message *E737* +--- When {expr3} is omitted then "force" is assumed. +--- +--- {expr1} is changed when {expr2} is not empty. If necessary +--- make a copy of {expr1} first. +--- {expr2} remains unchanged. +--- When {expr1} is locked and {expr2} is not empty the operation +--- fails. +--- Returns {expr1}. Returns 0 on error. +--- +--- @param expr1 any +--- @param expr2 any +--- @param expr3? any +--- @return any +function vim.fn.extend(expr1, expr2, expr3) end + +--- Like |extend()| but instead of adding items to {expr1} a new +--- List or Dictionary is created and returned. {expr1} remains +--- unchanged. +--- +--- @param expr1 any +--- @param expr2 any +--- @param expr3? any +--- @return any +function vim.fn.extendnew(expr1, expr2, expr3) end + +--- Characters in {string} are queued for processing as if they +--- come from a mapping or were typed by the user. +--- +--- By default the string is added to the end of the typeahead +--- buffer, thus if a mapping is still being executed the +--- characters come after them. Use the 'i' flag to insert before +--- other characters, they will be executed next, before any +--- characters from a mapping. +--- +--- The function does not wait for processing of keys contained in +--- {string}. +--- +--- To include special keys into {string}, use double-quotes +--- and "\..." notation |expr-quote|. For example, +--- feedkeys("\<CR>") simulates pressing of the <Enter> key. But +--- feedkeys('\<CR>') pushes 5 characters. +--- The |<Ignore>| keycode may be used to exit the +--- wait-for-character without doing anything. +--- +--- {mode} is a String, which can contain these character flags: +--- 'm' Remap keys. This is default. If {mode} is absent, +--- keys are remapped. +--- 'n' Do not remap keys. +--- 't' Handle keys as if typed; otherwise they are handled as +--- if coming from a mapping. This matters for undo, +--- opening folds, etc. +--- 'i' Insert the string instead of appending (see above). +--- 'x' Execute commands until typeahead is empty. This is +--- similar to using ":normal!". You can call feedkeys() +--- several times without 'x' and then one time with 'x' +--- (possibly with an empty {string}) to execute all the +--- typeahead. Note that when Vim ends in Insert mode it +--- will behave as if <Esc> is typed, to avoid getting +--- stuck, waiting for a character to be typed before the +--- script continues. +--- Note that if you manage to call feedkeys() while +--- executing commands, thus calling it recursively, then +--- all typeahead will be consumed by the last call. +--- '!' When used with 'x' will not end Insert mode. Can be +--- used in a test when a timer is set to exit Insert mode +--- a little later. Useful for testing CursorHoldI. +--- +--- Return value is always 0. +--- +--- @param string string +--- @param mode? string +--- @return any +function vim.fn.feedkeys(string, mode) end + +--- @deprecated +--- Obsolete name for |filereadable()|. +--- +--- @param file string +--- @return any +function vim.fn.file_readable(file) end + +--- The result is a Number, which is |TRUE| when a file with the +--- name {file} exists, and can be read. If {file} doesn't exist, +--- or is a directory, the result is |FALSE|. {file} is any +--- expression, which is used as a String. +--- If you don't care about the file being readable you can use +--- |glob()|. +--- {file} is used as-is, you may want to expand wildcards first: >vim +--- echo filereadable('~/.vimrc') +--- < > +--- 0 +--- < >vim +--- echo filereadable(expand('~/.vimrc')) +--- < > +--- 1 +--- < +--- +--- @param file string +--- @return 0|1 +function vim.fn.filereadable(file) end + +--- The result is a Number, which is 1 when a file with the +--- name {file} exists, and can be written. If {file} doesn't +--- exist, or is not writable, the result is 0. If {file} is a +--- directory, and we can write to it, the result is 2. +--- +--- @param file string +--- @return 0|1 +function vim.fn.filewritable(file) end + +--- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. +--- For each item in {expr1} evaluate {expr2} and when the result +--- is zero or false remove the item from the |List| or +--- |Dictionary|. Similarly for each byte in a |Blob| and each +--- character in a |String|. +--- +--- {expr2} must be a |string| or |Funcref|. +--- +--- If {expr2} is a |string|, inside {expr2} |v:val| has the value +--- of the current item. For a |Dictionary| |v:key| has the key +--- of the current item and for a |List| |v:key| has the index of +--- the current item. For a |Blob| |v:key| has the index of the +--- current byte. For a |String| |v:key| has the index of the +--- current character. +--- Examples: >vim +--- call filter(mylist, 'v:val !~ "OLD"') +--- <Removes the items where "OLD" appears. >vim +--- call filter(mydict, 'v:key >= 8') +--- <Removes the items with a key below 8. >vim +--- call filter(var, 0) +--- <Removes all the items, thus clears the |List| or |Dictionary|. +--- +--- Note that {expr2} is the result of expression and is then +--- used as an expression again. Often it is good to use a +--- |literal-string| to avoid having to double backslashes. +--- +--- If {expr2} is a |Funcref| it must take two arguments: +--- 1. the key or the index of the current item. +--- 2. the value of the current item. +--- The function must return |TRUE| if the item should be kept. +--- Example that keeps the odd items of a list: >vim +--- func Odd(idx, val) +--- return a:idx % 2 == 1 +--- endfunc +--- call filter(mylist, function('Odd')) +--- <It is shorter when using a |lambda|: >vim +--- call filter(myList, {idx, val -> idx * val <= 42}) +--- <If you do not use "val" you can leave it out: >vim +--- call filter(myList, {idx -> idx % 2 == 1}) +--- < +--- For a |List| and a |Dictionary| the operation is done +--- in-place. If you want it to remain unmodified make a copy +--- first: >vim +--- let l = filter(copy(mylist), 'v:val =~ "KEEP"') +--- +--- <Returns {expr1}, the |List| or |Dictionary| that was filtered, +--- or a new |Blob| or |String|. +--- When an error is encountered while evaluating {expr2} no +--- further items in {expr1} are processed. +--- When {expr2} is a Funcref errors inside a function are ignored, +--- unless it was defined with the "abort" flag. +--- +--- @param expr1 any +--- @param expr2 any +--- @return any +function vim.fn.filter(expr1, expr2) end + +--- Find directory {name} in {path}. Supports both downwards and +--- upwards recursive directory searches. See |file-searching| +--- for the syntax of {path}. +--- +--- Returns the path of the first found match. When the found +--- directory is below the current directory a relative path is +--- returned. Otherwise a full path is returned. +--- If {path} is omitted or empty then 'path' is used. +--- +--- If the optional {count} is given, find {count}'s occurrence of +--- {name} in {path} instead of the first one. +--- When {count} is negative return all the matches in a |List|. +--- +--- Returns an empty string if the directory is not found. +--- +--- This is quite similar to the ex-command `:find`. +--- +--- @param name string +--- @param path? string +--- @param count? any +--- @return any +function vim.fn.finddir(name, path, count) end + +--- Just like |finddir()|, but find a file instead of a directory. +--- Uses 'suffixesadd'. +--- Example: >vim +--- echo findfile("tags.vim", ".;") +--- <Searches from the directory of the current file upwards until +--- it finds the file "tags.vim". +--- +--- @param name string +--- @param path? string +--- @param count? any +--- @return any +function vim.fn.findfile(name, path, count) end + +--- Flatten {list} up to {maxdepth} levels. Without {maxdepth} +--- the result is a |List| without nesting, as if {maxdepth} is +--- a very large number. +--- The {list} is changed in place, use |flattennew()| if you do +--- not want that. +--- *E900* +--- {maxdepth} means how deep in nested lists changes are made. +--- {list} is not modified when {maxdepth} is 0. +--- {maxdepth} must be positive number. +--- +--- If there is an error the number zero is returned. +--- +--- Example: >vim +--- echo flatten([1, [2, [3, 4]], 5]) +--- < [1, 2, 3, 4, 5] >vim +--- echo flatten([1, [2, [3, 4]], 5], 1) +--- < [1, 2, [3, 4], 5] +--- +--- @param list any +--- @param maxdepth? any +--- @return any[]|0 +function vim.fn.flatten(list, maxdepth) end + +--- Like |flatten()| but first make a copy of {list}. +--- +--- @param list any +--- @param maxdepth? any +--- @return any[]|0 +function vim.fn.flattennew(list, maxdepth) end + +--- Convert {expr} to a Number by omitting the part after the +--- decimal point. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0 if {expr} is not a |Float| or a |Number|. +--- When the value of {expr} is out of range for a |Number| the +--- result is truncated to 0x7fffffff or -0x7fffffff (or when +--- 64-bit Number support is enabled, 0x7fffffffffffffff or +--- -0x7fffffffffffffff). NaN results in -0x80000000 (or when +--- 64-bit Number support is enabled, -0x8000000000000000). +--- Examples: >vim +--- echo float2nr(3.95) +--- < 3 >vim +--- echo float2nr(-23.45) +--- < -23 >vim +--- echo float2nr(1.0e100) +--- < 2147483647 (or 9223372036854775807) >vim +--- echo float2nr(-1.0e150) +--- < -2147483647 (or -9223372036854775807) >vim +--- echo float2nr(1.0e-100) +--- < 0 +--- +--- @param expr any +--- @return any +function vim.fn.float2nr(expr) end + +--- Return the largest integral value less than or equal to +--- {expr} as a |Float| (round down). +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo floor(1.856) +--- < 1.0 >vim +--- echo floor(-5.456) +--- < -6.0 >vim +--- echo floor(4.0) +--- < 4.0 +--- +--- @param expr any +--- @return any +function vim.fn.floor(expr) end + +--- Return the remainder of {expr1} / {expr2}, even if the +--- division is not representable. Returns {expr1} - i * {expr2} +--- for some integer i such that if {expr2} is non-zero, the +--- result has the same sign as {expr1} and magnitude less than +--- the magnitude of {expr2}. If {expr2} is zero, the value +--- returned is zero. The value returned is a |Float|. +--- {expr1} and {expr2} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr1} or {expr2} is not a |Float| or a +--- |Number|. +--- Examples: >vim +--- echo fmod(12.33, 1.22) +--- < 0.13 >vim +--- echo fmod(-12.33, 1.22) +--- < -0.13 +--- +--- @param expr1 any +--- @param expr2 any +--- @return any +function vim.fn.fmod(expr1, expr2) end + +--- Escape {string} for use as file name command argument. All +--- characters that have a special meaning, such as `'%'` and `'|'` +--- are escaped with a backslash. +--- For most systems the characters escaped are +--- " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash +--- appears in a filename, it depends on the value of 'isfname'. +--- A leading '+' and '>' is also escaped (special after |:edit| +--- and |:write|). And a "-" by itself (special after |:cd|). +--- Returns an empty string on error. +--- Example: >vim +--- let fname = '+some str%nge|name' +--- exe "edit " .. fnameescape(fname) +--- <results in executing: >vim +--- edit \+some\ str\%nge\|name +--- < +--- +--- @param string string +--- @return string +function vim.fn.fnameescape(string) end + +--- Modify file name {fname} according to {mods}. {mods} is a +--- string of characters like it is used for file names on the +--- command line. See |filename-modifiers|. +--- Example: >vim +--- echo fnamemodify("main.c", ":p:h") +--- <results in: > +--- /home/user/vim/vim/src +--- <If {mods} is empty or an unsupported modifier is used then +--- {fname} is returned. +--- When {fname} is empty then with {mods} ":h" returns ".", so +--- that `:cd` can be used with it. This is different from +--- expand('%:h') without a buffer name, which returns an empty +--- string. +--- Note: Environment variables don't work in {fname}, use +--- |expand()| first then. +--- +--- @param fname string +--- @param mods string +--- @return string +function vim.fn.fnamemodify(fname, mods) end + +--- The result is a Number. If the line {lnum} is in a closed +--- fold, the result is the number of the first line in that fold. +--- If the line {lnum} is not in a closed fold, -1 is returned. +--- {lnum} is used like with |getline()|. Thus "." is the current +--- line, "'m" mark m, etc. +--- +--- @param lnum integer +--- @return integer +function vim.fn.foldclosed(lnum) end + +--- The result is a Number. If the line {lnum} is in a closed +--- fold, the result is the number of the last line in that fold. +--- If the line {lnum} is not in a closed fold, -1 is returned. +--- {lnum} is used like with |getline()|. Thus "." is the current +--- line, "'m" mark m, etc. +--- +--- @param lnum integer +--- @return integer +function vim.fn.foldclosedend(lnum) end + +--- The result is a Number, which is the foldlevel of line {lnum} +--- in the current buffer. For nested folds the deepest level is +--- returned. If there is no fold at line {lnum}, zero is +--- returned. It doesn't matter if the folds are open or closed. +--- When used while updating folds (from 'foldexpr') -1 is +--- returned for lines where folds are still to be updated and the +--- foldlevel is unknown. As a special case the level of the +--- previous line is usually available. +--- {lnum} is used like with |getline()|. Thus "." is the current +--- line, "'m" mark m, etc. +--- +--- @param lnum integer +--- @return integer +function vim.fn.foldlevel(lnum) end + +--- Returns a String, to be displayed for a closed fold. This is +--- the default function used for the 'foldtext' option and should +--- only be called from evaluating 'foldtext'. It uses the +--- |v:foldstart|, |v:foldend| and |v:folddashes| variables. +--- The returned string looks like this: > +--- +-- 45 lines: abcdef +--- <The number of leading dashes depends on the foldlevel. The +--- "45" is the number of lines in the fold. "abcdef" is the text +--- in the first non-blank line of the fold. Leading white space, +--- "//" or "/*" and the text from the 'foldmarker' and +--- 'commentstring' options is removed. +--- When used to draw the actual foldtext, the rest of the line +--- will be filled with the fold char from the 'fillchars' +--- setting. +--- Returns an empty string when there is no fold. +--- +--- @return string +function vim.fn.foldtext() end + +--- Returns the text that is displayed for the closed fold at line +--- {lnum}. Evaluates 'foldtext' in the appropriate context. +--- When there is no closed fold at {lnum} an empty string is +--- returned. +--- {lnum} is used like with |getline()|. Thus "." is the current +--- line, "'m" mark m, etc. +--- Useful when exporting folded text, e.g., to HTML. +--- +--- @param lnum integer +--- @return string +function vim.fn.foldtextresult(lnum) end + +--- Get the full command name from a short abbreviated command +--- name; see |20.2| for details on command abbreviations. +--- +--- The string argument {name} may start with a `:` and can +--- include a [range], these are skipped and not returned. +--- Returns an empty string if a command doesn't exist or if it's +--- ambiguous (for user-defined commands). +--- +--- For example `fullcommand('s')`, `fullcommand('sub')`, +--- `fullcommand(':%substitute')` all return "substitute". +--- +--- @param name string +--- @return string +function vim.fn.fullcommand(name) end + +--- Just like |function()|, but the returned Funcref will lookup +--- the function by reference, not by name. This matters when the +--- function {name} is redefined later. +--- +--- Unlike |function()|, {name} must be an existing user function. +--- It only works for an autoloaded function if it has already +--- been loaded (to avoid mistakenly loading the autoload script +--- when only intending to use the function name, use |function()| +--- instead). {name} cannot be a builtin function. +--- Returns 0 on error. +--- +--- @param name string +--- @param arglist? any +--- @param dict? any +--- @return any +function vim.fn.funcref(name, arglist, dict) end + +--- Return a |Funcref| variable that refers to function {name}. +--- {name} can be the name of a user defined function or an +--- internal function. +--- +--- {name} can also be a Funcref or a partial. When it is a +--- partial the dict stored in it will be used and the {dict} +--- argument is not allowed. E.g.: >vim +--- let FuncWithArg = function(dict.Func, [arg]) +--- let Broken = function(dict.Func, [arg], dict) +--- < +--- When using the Funcref the function will be found by {name}, +--- also when it was redefined later. Use |funcref()| to keep the +--- same function. +--- +--- When {arglist} or {dict} is present this creates a partial. +--- That means the argument list and/or the dictionary is stored in +--- the Funcref and will be used when the Funcref is called. +--- +--- The arguments are passed to the function in front of other +--- arguments, but after any argument from |method|. Example: >vim +--- func Callback(arg1, arg2, name) +--- "... +--- endfunc +--- let Partial = function('Callback', ['one', 'two']) +--- "... +--- call Partial('name') +--- <Invokes the function as with: >vim +--- call Callback('one', 'two', 'name') +--- +--- <With a |method|: >vim +--- func Callback(one, two, three) +--- "... +--- endfunc +--- let Partial = function('Callback', ['two']) +--- "... +--- eval 'one'->Partial('three') +--- <Invokes the function as with: >vim +--- call Callback('one', 'two', 'three') +--- +--- <The function() call can be nested to add more arguments to the +--- Funcref. The extra arguments are appended to the list of +--- arguments. Example: >vim +--- func Callback(arg1, arg2, name) +--- "... +--- endfunc +--- let Func = function('Callback', ['one']) +--- let Func2 = function(Func, ['two']) +--- "... +--- call Func2('name') +--- <Invokes the function as with: >vim +--- call Callback('one', 'two', 'name') +--- +--- <The Dictionary is only useful when calling a "dict" function. +--- In that case the {dict} is passed in as "self". Example: >vim +--- function Callback() dict +--- echo "called for " .. self.name +--- endfunction +--- "... +--- let context = {"name": "example"} +--- let Func = function('Callback', context) +--- "... +--- call Func() " will echo: called for example +--- <The use of function() is not needed when there are no extra +--- arguments, these two are equivalent, if Callback() is defined +--- as context.Callback(): >vim +--- let Func = function('Callback', context) +--- let Func = context.Callback +--- +--- <The argument list and the Dictionary can be combined: >vim +--- function Callback(arg1, count) dict +--- "... +--- endfunction +--- let context = {"name": "example"} +--- let Func = function('Callback', ['one'], context) +--- "... +--- call Func(500) +--- <Invokes the function as with: >vim +--- call context.Callback('one', 500) +--- < +--- Returns 0 on error. +--- +--- @param name string +--- @param arglist? any +--- @param dict? any +--- @return any +vim.fn['function'] = function(name, arglist, dict) end + +--- Cleanup unused |Lists| and |Dictionaries| that have circular +--- references. +--- +--- There is hardly ever a need to invoke this function, as it is +--- automatically done when Vim runs out of memory or is waiting +--- for the user to press a key after 'updatetime'. Items without +--- circular references are always freed when they become unused. +--- This is useful if you have deleted a very big |List| and/or +--- |Dictionary| with circular references in a script that runs +--- for a long time. +--- +--- When the optional {atexit} argument is one, garbage +--- collection will also be done when exiting Vim, if it wasn't +--- done before. This is useful when checking for memory leaks. +--- +--- The garbage collection is not done immediately but only when +--- it's safe to perform. This is when waiting for the user to +--- type a character. +--- +--- @param atexit? any +--- @return any +function vim.fn.garbagecollect(atexit) end + +--- Get item {idx} from |List| {list}. When this item is not +--- available return {default}. Return zero when {default} is +--- omitted. +--- +--- @param list any[] +--- @param idx integer +--- @param default? any +--- @return any +function vim.fn.get(list, idx, default) end + +--- Get byte {idx} from |Blob| {blob}. When this byte is not +--- available return {default}. Return -1 when {default} is +--- omitted. +--- +--- @param blob string +--- @param idx integer +--- @param default? any +--- @return any +function vim.fn.get(blob, idx, default) end + +--- Get item with key {key} from |Dictionary| {dict}. When this +--- item is not available return {default}. Return zero when +--- {default} is omitted. Useful example: >vim +--- let val = get(g:, 'var_name', 'default') +--- <This gets the value of g:var_name if it exists, and uses +--- "default" when it does not exist. +--- +--- @param dict table<string,any> +--- @param key string +--- @param default? any +--- @return any +function vim.fn.get(dict, key, default) end + +--- Get item {what} from Funcref {func}. Possible values for +--- {what} are: +--- "name" The function name +--- "func" The function +--- "dict" The dictionary +--- "args" The list with arguments +--- Returns zero on error. +--- +--- @param func function +--- @param what string +--- @return any +function vim.fn.get(func, what) end + +--- @param buf? integer|string +--- @return vim.fn.getbufinfo.ret.item[] +function vim.fn.getbufinfo(buf) end + +--- Get information about buffers as a List of Dictionaries. +--- +--- Without an argument information about all the buffers is +--- returned. +--- +--- When the argument is a |Dictionary| only the buffers matching +--- the specified criteria are returned. The following keys can +--- be specified in {dict}: +--- buflisted include only listed buffers. +--- bufloaded include only loaded buffers. +--- bufmodified include only modified buffers. +--- +--- Otherwise, {buf} specifies a particular buffer to return +--- information for. For the use of {buf}, see |bufname()| +--- above. If the buffer is found the returned List has one item. +--- Otherwise the result is an empty list. +--- +--- Each returned List item is a dictionary with the following +--- entries: +--- bufnr Buffer number. +--- changed TRUE if the buffer is modified. +--- changedtick Number of changes made to the buffer. +--- hidden TRUE if the buffer is hidden. +--- lastused Timestamp in seconds, like +--- |localtime()|, when the buffer was +--- last used. +--- listed TRUE if the buffer is listed. +--- lnum Line number used for the buffer when +--- opened in the current window. +--- Only valid if the buffer has been +--- displayed in the window in the past. +--- If you want the line number of the +--- last known cursor position in a given +--- window, use |line()|: >vim +--- echo line('.', {winid}) +--- < +--- linecount Number of lines in the buffer (only +--- valid when loaded) +--- loaded TRUE if the buffer is loaded. +--- name Full path to the file in the buffer. +--- signs List of signs placed in the buffer. +--- Each list item is a dictionary with +--- the following fields: +--- id sign identifier +--- lnum line number +--- name sign name +--- variables A reference to the dictionary with +--- buffer-local variables. +--- windows List of |window-ID|s that display this +--- buffer +--- +--- Examples: >vim +--- for buf in getbufinfo() +--- echo buf.name +--- endfor +--- for buf in getbufinfo({'buflisted':1}) +--- if buf.changed +--- " .... +--- endif +--- endfor +--- < +--- To get buffer-local options use: >vim +--- getbufvar({bufnr}, '&option_name') +--- < +--- +--- @param dict? vim.fn.getbufinfo.dict +--- @return vim.fn.getbufinfo.ret.item[] +function vim.fn.getbufinfo(dict) end + +--- Return a |List| with the lines starting from {lnum} to {end} +--- (inclusive) in the buffer {buf}. If {end} is omitted, a +--- |List| with only the line {lnum} is returned. See +--- `getbufoneline()` for only getting the line. +--- +--- For the use of {buf}, see |bufname()| above. +--- +--- For {lnum} and {end} "$" can be used for the last line of the +--- buffer. Otherwise a number must be used. +--- +--- When {lnum} is smaller than 1 or bigger than the number of +--- lines in the buffer, an empty |List| is returned. +--- +--- When {end} is greater than the number of lines in the buffer, +--- it is treated as {end} is set to the number of lines in the +--- buffer. When {end} is before {lnum} an empty |List| is +--- returned. +--- +--- This function works only for loaded buffers. For unloaded and +--- non-existing buffers, an empty |List| is returned. +--- +--- Example: >vim +--- let lines = getbufline(bufnr("myfile"), 1, "$") +--- +--- @param buf any +--- @param lnum integer +--- @param end_? integer +--- @return any +function vim.fn.getbufline(buf, lnum, end_) end + +--- Just like `getbufline()` but only get one line and return it +--- as a string. +--- +--- @param buf integer|string +--- @param lnum integer +--- @return string +function vim.fn.getbufoneline(buf, lnum) end + +--- The result is the value of option or local buffer variable +--- {varname} in buffer {buf}. Note that the name without "b:" +--- must be used. +--- The {varname} argument is a string. +--- When {varname} is empty returns a |Dictionary| with all the +--- buffer-local variables. +--- When {varname} is equal to "&" returns a |Dictionary| with all +--- the buffer-local options. +--- Otherwise, when {varname} starts with "&" returns the value of +--- a buffer-local option. +--- This also works for a global or buffer-local option, but it +--- doesn't work for a global variable, window-local variable or +--- window-local option. +--- For the use of {buf}, see |bufname()| above. +--- When the buffer or variable doesn't exist {def} or an empty +--- string is returned, there is no error message. +--- Examples: >vim +--- let bufmodified = getbufvar(1, "&mod") +--- echo "todo myvar = " .. getbufvar("todo", "myvar") +--- +--- @param buf any +--- @param varname string +--- @param def? any +--- @return any +function vim.fn.getbufvar(buf, varname, def) end + +--- Returns a |List| of cell widths of character ranges overridden +--- by |setcellwidths()|. The format is equal to the argument of +--- |setcellwidths()|. If no character ranges have their cell +--- widths overridden, an empty List is returned. +--- +--- @return any +function vim.fn.getcellwidths() end + +--- Returns the |changelist| for the buffer {buf}. For the use +--- of {buf}, see |bufname()| above. If buffer {buf} doesn't +--- exist, an empty list is returned. +--- +--- The returned list contains two entries: a list with the change +--- locations and the current position in the list. Each +--- entry in the change list is a dictionary with the following +--- entries: +--- col column number +--- coladd column offset for 'virtualedit' +--- lnum line number +--- If buffer {buf} is the current buffer, then the current +--- position refers to the position in the list. For other +--- buffers, it is set to the length of the list. +--- +--- @param buf? integer|string +--- @return table[] +function vim.fn.getchangelist(buf) end + +--- Get a single character from the user or input stream. +--- If [expr] is omitted, wait until a character is available. +--- If [expr] is 0, only get a character when one is available. +--- Return zero otherwise. +--- If [expr] is 1, only check if a character is available, it is +--- not consumed. Return zero if no character available. +--- If you prefer always getting a string use |getcharstr()|. +--- +--- Without [expr] and when [expr] is 0 a whole character or +--- special key is returned. If it is a single character, the +--- result is a Number. Use |nr2char()| to convert it to a String. +--- Otherwise a String is returned with the encoded character. +--- For a special key it's a String with a sequence of bytes +--- starting with 0x80 (decimal: 128). This is the same value as +--- the String "\<Key>", e.g., "\<Left>". The returned value is +--- also a String when a modifier (shift, control, alt) was used +--- that is not included in the character. +--- +--- When [expr] is 0 and Esc is typed, there will be a short delay +--- while Vim waits to see if this is the start of an escape +--- sequence. +--- +--- When [expr] is 1 only the first byte is returned. For a +--- one-byte character it is the character itself as a number. +--- Use nr2char() to convert it to a String. +--- +--- Use getcharmod() to obtain any additional modifiers. +--- +--- When the user clicks a mouse button, the mouse event will be +--- returned. The position can then be found in |v:mouse_col|, +--- |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|. +--- |getmousepos()| can also be used. Mouse move events will be +--- ignored. +--- This example positions the mouse as it would normally happen: >vim +--- let c = getchar() +--- if c == "\<LeftMouse>" && v:mouse_win > 0 +--- exe v:mouse_win .. "wincmd w" +--- exe v:mouse_lnum +--- exe "normal " .. v:mouse_col .. "|" +--- endif +--- < +--- There is no prompt, you will somehow have to make clear to the +--- user that a character has to be typed. The screen is not +--- redrawn, e.g. when resizing the window. +--- +--- There is no mapping for the character. +--- Key codes are replaced, thus when the user presses the <Del> +--- key you get the code for the <Del> key, not the raw character +--- sequence. Examples: >vim +--- getchar() == "\<Del>" +--- getchar() == "\<S-Left>" +--- <This example redefines "f" to ignore case: >vim +--- nmap f :call FindChar()<CR> +--- function FindChar() +--- let c = nr2char(getchar()) +--- while col('.') < col('$') - 1 +--- normal l +--- if getline('.')[col('.') - 1] ==? c +--- break +--- endif +--- endwhile +--- endfunction +--- < +--- +--- @return integer +function vim.fn.getchar() end + +--- The result is a Number which is the state of the modifiers for +--- the last obtained character with getchar() or in another way. +--- These values are added together: +--- 2 shift +--- 4 control +--- 8 alt (meta) +--- 16 meta (when it's different from ALT) +--- 32 mouse double click +--- 64 mouse triple click +--- 96 mouse quadruple click (== 32 + 64) +--- 128 command (Macintosh only) +--- Only the modifiers that have not been included in the +--- character itself are obtained. Thus Shift-a results in "A" +--- without a modifier. Returns 0 if no modifiers are used. +--- +--- @return integer +function vim.fn.getcharmod() end + +--- Get the position for String {expr}. Same as |getpos()| but the +--- column number in the returned List is a character index +--- instead of a byte index. +--- If |getpos()| returns a very large column number, equal to +--- |v:maxcol|, then getcharpos() will return the character index +--- of the last character. +--- +--- Example: +--- With the cursor on '세' in line 5 with text "여보세요": >vim +--- getcharpos('.') returns [0, 5, 3, 0] +--- getpos('.') returns [0, 5, 7, 0] +--- < +--- +--- @param expr any +--- @return integer[] +function vim.fn.getcharpos(expr) end + +--- Return the current character search information as a {dict} +--- with the following entries: +--- +--- char character previously used for a character +--- search (|t|, |f|, |T|, or |F|); empty string +--- if no character search has been performed +--- forward direction of character search; 1 for forward, +--- 0 for backward +--- until type of character search; 1 for a |t| or |T| +--- character search, 0 for an |f| or |F| +--- character search +--- +--- This can be useful to always have |;| and |,| search +--- forward/backward regardless of the direction of the previous +--- character search: >vim +--- nnoremap <expr> ; getcharsearch().forward ? ';' : ',' +--- nnoremap <expr> , getcharsearch().forward ? ',' : ';' +--- <Also see |setcharsearch()|. +--- +--- @return table[] +function vim.fn.getcharsearch() end + +--- Get a single character from the user or input stream as a +--- string. +--- If [expr] is omitted, wait until a character is available. +--- If [expr] is 0 or false, only get a character when one is +--- available. Return an empty string otherwise. +--- If [expr] is 1 or true, only check if a character is +--- available, it is not consumed. Return an empty string +--- if no character is available. +--- Otherwise this works like |getchar()|, except that a number +--- result is converted to a string. +--- +--- @return string +function vim.fn.getcharstr() end + +--- Return the type of the current command-line completion. +--- Only works when the command line is being edited, thus +--- requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. +--- See |:command-completion| for the return string. +--- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and +--- |setcmdline()|. +--- Returns an empty string when completion is not defined. +--- +--- @return string +function vim.fn.getcmdcompltype() end + +--- Return the current command-line. Only works when the command +--- line is being edited, thus requires use of |c_CTRL-\_e| or +--- |c_CTRL-R_=|. +--- Example: >vim +--- cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR> +--- <Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()| and +--- |setcmdline()|. +--- Returns an empty string when entering a password or using +--- |inputsecret()|. +--- +--- @return string +function vim.fn.getcmdline() end + +--- Return the position of the cursor in the command line as a +--- byte count. The first column is 1. +--- Only works when editing the command line, thus requires use of +--- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. +--- Returns 0 otherwise. +--- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and +--- |setcmdline()|. +--- +--- @return integer +function vim.fn.getcmdpos() end + +--- Return the screen position of the cursor in the command line +--- as a byte count. The first column is 1. +--- Instead of |getcmdpos()|, it adds the prompt position. +--- Only works when editing the command line, thus requires use of +--- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. +--- Returns 0 otherwise. +--- Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and +--- |setcmdline()|. +--- +--- @return any +function vim.fn.getcmdscreenpos() end + +--- Return the current command-line type. Possible return values +--- are: +--- : normal Ex command +--- > debug mode command |debug-mode| +--- / forward search command +--- ? backward search command +--- \@ |input()| command +--- `-` |:insert| or |:append| command +--- = |i_CTRL-R_=| +--- Only works when editing the command line, thus requires use of +--- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. +--- Returns an empty string otherwise. +--- Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|. +--- +--- @return ':'|'>'|'/'|'?'|'@'|'-'|'=' +function vim.fn.getcmdtype() end + +--- Return the current |command-line-window| type. Possible return +--- values are the same as |getcmdtype()|. Returns an empty string +--- when not in the command-line window. +--- +--- @return ':'|'>'|'/'|'?'|'@'|'-'|'=' +function vim.fn.getcmdwintype() end + +--- Return a list of command-line completion matches. The String +--- {type} argument specifies what for. The following completion +--- types are supported: +--- +--- arglist file names in argument list +--- augroup autocmd groups +--- buffer buffer names +--- breakpoint |:breakadd| and |:breakdel| suboptions +--- cmdline |cmdline-completion| result +--- color color schemes +--- command Ex command +--- compiler compilers +--- custom,{func} custom completion, defined via {func} +--- customlist,{func} custom completion, defined via {func} +--- diff_buffer |:diffget| and |:diffput| completion +--- dir directory names +--- environment environment variable names +--- event autocommand events +--- expression Vim expression +--- file file and directory names +--- file_in_path file and directory names in |'path'| +--- filetype filetype names |'filetype'| +--- function function name +--- help help subjects +--- highlight highlight groups +--- history |:history| suboptions +--- locale locale names (as output of locale -a) +--- mapclear buffer argument +--- mapping mapping name +--- menu menus +--- messages |:messages| suboptions +--- option options +--- packadd optional package |pack-add| names +--- runtime |:runtime| completion +--- scriptnames sourced script names |:scriptnames| +--- shellcmd Shell command +--- sign |:sign| suboptions +--- syntax syntax file names |'syntax'| +--- syntime |:syntime| suboptions +--- tag tags +--- tag_listfiles tags, file names +--- user user names +--- var user variables +--- +--- If {pat} is an empty string, then all the matches are +--- returned. Otherwise only items matching {pat} are returned. +--- See |wildcards| for the use of special characters in {pat}. +--- +--- If the optional {filtered} flag is set to 1, then 'wildignore' +--- is applied to filter the results. Otherwise all the matches +--- are returned. The 'wildignorecase' option always applies. +--- +--- If the 'wildoptions' option contains "fuzzy", then fuzzy +--- matching is used to get the completion matches. Otherwise +--- regular expression matching is used. Thus this function +--- follows the user preference, what happens on the command line. +--- If you do not want this you can make 'wildoptions' empty +--- before calling getcompletion() and restore it afterwards. +--- +--- If {type} is "cmdline", then the |cmdline-completion| result is +--- returned. For example, to complete the possible values after +--- a ":call" command: >vim +--- echo getcompletion('call ', 'cmdline') +--- < +--- If there are no matches, an empty list is returned. An +--- invalid value for {type} produces an error. +--- +--- @param pat any +--- @param type any +--- @param filtered? any +--- @return string[] +function vim.fn.getcompletion(pat, type, filtered) end + +--- Get the position of the cursor. This is like getpos('.'), but +--- includes an extra "curswant" item in the list: +--- [0, lnum, col, off, curswant] ~ +--- The "curswant" number is the preferred column when moving the +--- cursor vertically. After |$| command it will be a very large +--- number equal to |v:maxcol|. Also see |getcursorcharpos()| and +--- |getpos()|. +--- The first "bufnum" item is always zero. The byte position of +--- the cursor is returned in "col". To get the character +--- position, use |getcursorcharpos()|. +--- +--- The optional {winid} argument can specify the window. It can +--- be the window number or the |window-ID|. The last known +--- cursor position is returned, this may be invalid for the +--- current value of the buffer if it is not the current window. +--- If {winid} is invalid a list with zeroes is returned. +--- +--- This can be used to save and restore the cursor position: >vim +--- let save_cursor = getcurpos() +--- MoveTheCursorAround +--- call setpos('.', save_cursor) +--- <Note that this only works within the window. See +--- |winrestview()| for restoring more state. +--- +--- @param winid? integer +--- @return any +function vim.fn.getcurpos(winid) end + +--- Same as |getcurpos()| but the column number in the returned +--- List is a character index instead of a byte index. +--- +--- Example: +--- With the cursor on '보' in line 3 with text "여보세요": >vim +--- getcursorcharpos() " returns [0, 3, 2, 0, 3] +--- getcurpos() " returns [0, 3, 4, 0, 3] +--- < +--- +--- @param winid? integer +--- @return any +function vim.fn.getcursorcharpos(winid) end + +--- With no arguments, returns the name of the effective +--- |current-directory|. With {winnr} or {tabnr} the working +--- directory of that scope is returned, and 'autochdir' is +--- ignored. +--- Tabs and windows are identified by their respective numbers, +--- 0 means current tab or window. Missing tab number implies 0. +--- Thus the following are equivalent: >vim +--- getcwd(0) +--- getcwd(0, 0) +--- <If {winnr} is -1 it is ignored, only the tab is resolved. +--- {winnr} can be the window number or the |window-ID|. +--- If both {winnr} and {tabnr} are -1 the global working +--- directory is returned. +--- Throw error if the arguments are invalid. |E5000| |E5001| |E5002| +--- +--- @param winnr? integer +--- @param tabnr? integer +--- @return string +function vim.fn.getcwd(winnr, tabnr) end + +--- Return the value of environment variable {name}. The {name} +--- argument is a string, without a leading '$'. Example: >vim +--- myHome = getenv('HOME') +--- +--- <When the variable does not exist |v:null| is returned. That +--- is different from a variable set to an empty string. +--- See also |expr-env|. +--- +--- @param name string +--- @return string +function vim.fn.getenv(name) end + +--- Without an argument returns the name of the normal font being +--- used. Like what is used for the Normal highlight group +--- |hl-Normal|. +--- With an argument a check is done whether String {name} is a +--- valid font name. If not then an empty string is returned. +--- Otherwise the actual font name is returned, or {name} if the +--- GUI does not support obtaining the real name. +--- Only works when the GUI is running, thus not in your vimrc or +--- gvimrc file. Use the |GUIEnter| autocommand to use this +--- function just after the GUI has started. +--- +--- @param name? string +--- @return string +function vim.fn.getfontname(name) end + +--- The result is a String, which is the read, write, and execute +--- permissions of the given file {fname}. +--- If {fname} does not exist or its directory cannot be read, an +--- empty string is returned. +--- The result is of the form "rwxrwxrwx", where each group of +--- "rwx" flags represent, in turn, the permissions of the owner +--- of the file, the group the file belongs to, and other users. +--- If a user does not have a given permission the flag for this +--- is replaced with the string "-". Examples: >vim +--- echo getfperm("/etc/passwd") +--- echo getfperm(expand("~/.config/nvim/init.vim")) +--- <This will hopefully (from a security point of view) display +--- the string "rw-r--r--" or even "rw-------". +--- +--- For setting permissions use |setfperm()|. +--- +--- @param fname string +--- @return string +function vim.fn.getfperm(fname) end + +--- The result is a Number, which is the size in bytes of the +--- given file {fname}. +--- If {fname} is a directory, 0 is returned. +--- If the file {fname} can't be found, -1 is returned. +--- If the size of {fname} is too big to fit in a Number then -2 +--- is returned. +--- +--- @param fname string +--- @return integer +function vim.fn.getfsize(fname) end + +--- The result is a Number, which is the last modification time of +--- the given file {fname}. The value is measured as seconds +--- since 1st Jan 1970, and may be passed to strftime(). See also +--- |localtime()| and |strftime()|. +--- If the file {fname} can't be found -1 is returned. +--- +--- @param fname string +--- @return integer +function vim.fn.getftime(fname) end + +--- The result is a String, which is a description of the kind of +--- file of the given file {fname}. +--- If {fname} does not exist an empty string is returned. +--- Here is a table over different kinds of files and their +--- results: +--- Normal file "file" +--- Directory "dir" +--- Symbolic link "link" +--- Block device "bdev" +--- Character device "cdev" +--- Socket "socket" +--- FIFO "fifo" +--- All other "other" +--- Example: >vim +--- getftype("/home") +--- <Note that a type such as "link" will only be returned on +--- systems that support it. On some systems only "dir" and +--- "file" are returned. +--- +--- @param fname string +--- @return 'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other' +function vim.fn.getftype(fname) end + +--- Returns the |jumplist| for the specified window. +--- +--- Without arguments use the current window. +--- With {winnr} only use this window in the current tab page. +--- {winnr} can also be a |window-ID|. +--- With {winnr} and {tabnr} use the window in the specified tab +--- page. If {winnr} or {tabnr} is invalid, an empty list is +--- returned. +--- +--- The returned list contains two entries: a list with the jump +--- locations and the last used jump position number in the list. +--- Each entry in the jump location list is a dictionary with +--- the following entries: +--- bufnr buffer number +--- col column number +--- coladd column offset for 'virtualedit' +--- filename filename if available +--- lnum line number +--- +--- @param winnr? integer +--- @param tabnr? integer +--- @return vim.fn.getjumplist.ret +function vim.fn.getjumplist(winnr, tabnr) end + +--- Without {end} the result is a String, which is line {lnum} +--- from the current buffer. Example: >vim +--- getline(1) +--- <When {lnum} is a String that doesn't start with a +--- digit, |line()| is called to translate the String into a Number. +--- To get the line under the cursor: >vim +--- getline(".") +--- <When {lnum} is a number smaller than 1 or bigger than the +--- number of lines in the buffer, an empty string is returned. +--- +--- When {end} is given the result is a |List| where each item is +--- a line from the current buffer in the range {lnum} to {end}, +--- including line {end}. +--- {end} is used in the same way as {lnum}. +--- Non-existing lines are silently omitted. +--- When {end} is before {lnum} an empty |List| is returned. +--- Example: >vim +--- let start = line('.') +--- let end = search("^$") - 1 +--- let lines = getline(start, end) +--- +--- <To get lines from another buffer see |getbufline()| and +--- |getbufoneline()| +--- +--- @param lnum integer +--- @param end_? any +--- @return string|string[] +function vim.fn.getline(lnum, end_) end + +--- Returns a |List| with all the entries in the location list for +--- window {nr}. {nr} can be the window number or the |window-ID|. +--- When {nr} is zero the current window is used. +--- +--- For a location list window, the displayed location list is +--- returned. For an invalid window number {nr}, an empty list is +--- returned. Otherwise, same as |getqflist()|. +--- +--- If the optional {what} dictionary argument is supplied, then +--- returns the items listed in {what} as a dictionary. Refer to +--- |getqflist()| for the supported items in {what}. +--- +--- In addition to the items supported by |getqflist()| in {what}, +--- the following item is supported by |getloclist()|: +--- +--- filewinid id of the window used to display files +--- from the location list. This field is +--- applicable only when called from a +--- location list window. See +--- |location-list-file-window| for more +--- details. +--- +--- Returns a |Dictionary| with default values if there is no +--- location list for the window {nr}. +--- Returns an empty Dictionary if window {nr} does not exist. +--- +--- Examples (See also |getqflist-examples|): >vim +--- echo getloclist(3, {'all': 0}) +--- echo getloclist(5, {'filewinid': 0}) +--- < +--- +--- @param nr integer +--- @param what? any +--- @return any +function vim.fn.getloclist(nr, what) end + +--- Without the {buf} argument returns a |List| with information +--- about all the global marks. |mark| +--- +--- If the optional {buf} argument is specified, returns the +--- local marks defined in buffer {buf}. For the use of {buf}, +--- see |bufname()|. If {buf} is invalid, an empty list is +--- returned. +--- +--- Each item in the returned List is a |Dict| with the following: +--- mark name of the mark prefixed by "'" +--- pos a |List| with the position of the mark: +--- [bufnum, lnum, col, off] +--- Refer to |getpos()| for more information. +--- file file name +--- +--- Refer to |getpos()| for getting information about a specific +--- mark. +--- +--- @param buf? any +--- @return any +function vim.fn.getmarklist(buf) end + +--- Returns a |List| with all matches previously defined for the +--- current window by |matchadd()| and the |:match| commands. +--- |getmatches()| is useful in combination with |setmatches()|, +--- as |setmatches()| can restore a list of matches saved by +--- |getmatches()|. +--- If {win} is specified, use the window with this number or +--- window ID instead of the current window. If {win} is invalid, +--- an empty list is returned. +--- Example: >vim +--- echo getmatches() +--- < > +--- [{"group": "MyGroup1", "pattern": "TODO", +--- "priority": 10, "id": 1}, {"group": "MyGroup2", +--- "pattern": "FIXME", "priority": 10, "id": 2}] +--- < >vim +--- let m = getmatches() +--- call clearmatches() +--- echo getmatches() +--- < > +--- [] +--- < >vim +--- call setmatches(m) +--- echo getmatches() +--- < > +--- [{"group": "MyGroup1", "pattern": "TODO", +--- "priority": 10, "id": 1}, {"group": "MyGroup2", +--- "pattern": "FIXME", "priority": 10, "id": 2}] +--- < >vim +--- unlet m +--- < +--- +--- @param win? any +--- @return any +function vim.fn.getmatches(win) end + +--- Returns a |Dictionary| with the last known position of the +--- mouse. This can be used in a mapping for a mouse click. The +--- items are: +--- screenrow screen row +--- screencol screen column +--- winid Window ID of the click +--- winrow row inside "winid" +--- wincol column inside "winid" +--- line text line inside "winid" +--- column text column inside "winid" +--- coladd offset (in screen columns) from the +--- start of the clicked char +--- All numbers are 1-based. +--- +--- If not over a window, e.g. when in the command line, then only +--- "screenrow" and "screencol" are valid, the others are zero. +--- +--- When on the status line below a window or the vertical +--- separator right of a window, the "line" and "column" values +--- are zero. +--- +--- When the position is after the text then "column" is the +--- length of the text in bytes plus one. +--- +--- If the mouse is over a focusable floating window then that +--- window is used. +--- +--- When using |getchar()| the Vim variables |v:mouse_lnum|, +--- |v:mouse_col| and |v:mouse_winid| also provide these values. +--- +--- @return vim.fn.getmousepos.ret +function vim.fn.getmousepos() end + +--- Return a Number which is the process ID of the Vim process. +--- This is a unique number, until Vim exits. +--- +--- @return integer +function vim.fn.getpid() end + +--- Get the position for String {expr}. For possible values of +--- {expr} see |line()|. For getting the cursor position see +--- |getcurpos()|. +--- The result is a |List| with four numbers: +--- [bufnum, lnum, col, off] +--- "bufnum" is zero, unless a mark like '0 or 'A is used, then it +--- is the buffer number of the mark. +--- "lnum" and "col" are the position in the buffer. The first +--- column is 1. +--- The "off" number is zero, unless 'virtualedit' is used. Then +--- it is the offset in screen columns from the start of the +--- character. E.g., a position within a <Tab> or after the last +--- character. +--- Note that for '< and '> Visual mode matters: when it is "V" +--- (visual line mode) the column of '< is zero and the column of +--- '> is a large number equal to |v:maxcol|. +--- The column number in the returned List is the byte position +--- within the line. To get the character position in the line, +--- use |getcharpos()|. +--- A very large column number equal to |v:maxcol| can be returned, +--- in which case it means "after the end of the line". +--- If {expr} is invalid, returns a list with all zeros. +--- This can be used to save and restore the position of a mark: >vim +--- let save_a_mark = getpos("'a") +--- " ... +--- call setpos("'a", save_a_mark) +--- <Also see |getcharpos()|, |getcurpos()| and |setpos()|. +--- +--- @param expr string +--- @return integer[] +function vim.fn.getpos(expr) end + +--- Returns a |List| with all the current quickfix errors. Each +--- list item is a dictionary with these entries: +--- bufnr number of buffer that has the file name, use +--- bufname() to get the name +--- module module name +--- lnum line number in the buffer (first line is 1) +--- end_lnum +--- end of line number if the item is multiline +--- col column number (first column is 1) +--- end_col end of column number if the item has range +--- vcol |TRUE|: "col" is visual column +--- |FALSE|: "col" is byte index +--- nr error number +--- pattern search pattern used to locate the error +--- text description of the error +--- type type of the error, 'E', '1', etc. +--- valid |TRUE|: recognized error message +--- user_data +--- custom data associated with the item, can be +--- any type. +--- +--- When there is no error list or it's empty, an empty list is +--- returned. Quickfix list entries with a non-existing buffer +--- number are returned with "bufnr" set to zero (Note: some +--- functions accept buffer number zero for the alternate buffer, +--- you may need to explicitly check for zero). +--- +--- Useful application: Find pattern matches in multiple files and +--- do something with them: >vim +--- vimgrep /theword/jg *.c +--- for d in getqflist() +--- echo bufname(d.bufnr) ':' d.lnum '=' d.text +--- endfor +--- < +--- If the optional {what} dictionary argument is supplied, then +--- returns only the items listed in {what} as a dictionary. The +--- following string items are supported in {what}: +--- changedtick get the total number of changes made +--- to the list |quickfix-changedtick| +--- context get the |quickfix-context| +--- efm errorformat to use when parsing "lines". If +--- not present, then the 'errorformat' option +--- value is used. +--- id get information for the quickfix list with +--- |quickfix-ID|; zero means the id for the +--- current list or the list specified by "nr" +--- idx get information for the quickfix entry at this +--- index in the list specified by "id" or "nr". +--- If set to zero, then uses the current entry. +--- See |quickfix-index| +--- items quickfix list entries +--- lines parse a list of lines using 'efm' and return +--- the resulting entries. Only a |List| type is +--- accepted. The current quickfix list is not +--- modified. See |quickfix-parse|. +--- nr get information for this quickfix list; zero +--- means the current quickfix list and "$" means +--- the last quickfix list +--- qfbufnr number of the buffer displayed in the quickfix +--- window. Returns 0 if the quickfix buffer is +--- not present. See |quickfix-buffer|. +--- size number of entries in the quickfix list +--- title get the list title |quickfix-title| +--- winid get the quickfix |window-ID| +--- all all of the above quickfix properties +--- Non-string items in {what} are ignored. To get the value of a +--- particular item, set it to zero. +--- If "nr" is not present then the current quickfix list is used. +--- If both "nr" and a non-zero "id" are specified, then the list +--- specified by "id" is used. +--- To get the number of lists in the quickfix stack, set "nr" to +--- "$" in {what}. The "nr" value in the returned dictionary +--- contains the quickfix stack size. +--- When "lines" is specified, all the other items except "efm" +--- are ignored. The returned dictionary contains the entry +--- "items" with the list of entries. +--- +--- The returned dictionary contains the following entries: +--- changedtick total number of changes made to the +--- list |quickfix-changedtick| +--- context quickfix list context. See |quickfix-context| +--- If not present, set to "". +--- id quickfix list ID |quickfix-ID|. If not +--- present, set to 0. +--- idx index of the quickfix entry in the list. If not +--- present, set to 0. +--- items quickfix list entries. If not present, set to +--- an empty list. +--- nr quickfix list number. If not present, set to 0 +--- qfbufnr number of the buffer displayed in the quickfix +--- window. If not present, set to 0. +--- size number of entries in the quickfix list. If not +--- present, set to 0. +--- title quickfix list title text. If not present, set +--- to "". +--- winid quickfix |window-ID|. If not present, set to 0 +--- +--- Examples (See also |getqflist-examples|): >vim +--- echo getqflist({'all': 1}) +--- echo getqflist({'nr': 2, 'title': 1}) +--- echo getqflist({'lines' : ["F1:10:L10"]}) +--- < +--- +--- @param what? any +--- @return any +function vim.fn.getqflist(what) end + +--- The result is a String, which is the contents of register +--- {regname}. Example: >vim +--- let cliptext = getreg('*') +--- <When register {regname} was not set the result is an empty +--- string. +--- The {regname} argument must be a string. +--- +--- getreg('=') returns the last evaluated value of the expression +--- register. (For use in maps.) +--- getreg('=', 1) returns the expression itself, so that it can +--- be restored with |setreg()|. For other registers the extra +--- argument is ignored, thus you can always give it. +--- +--- If {list} is present and |TRUE|, the result type is changed +--- to |List|. Each list item is one text line. Use it if you care +--- about zero bytes possibly present inside register: without +--- third argument both NLs and zero bytes are represented as NLs +--- (see |NL-used-for-Nul|). +--- When the register was not set an empty list is returned. +--- +--- If {regname} is not specified, |v:register| is used. +--- +--- @param regname? string +--- @param list? any +--- @return string|string[] +function vim.fn.getreg(regname, list) end + +--- Returns detailed information about register {regname} as a +--- Dictionary with the following entries: +--- regcontents List of lines contained in register +--- {regname}, like +--- getreg({regname}, 1, 1). +--- regtype the type of register {regname}, as in +--- |getregtype()|. +--- isunnamed Boolean flag, v:true if this register +--- is currently pointed to by the unnamed +--- register. +--- points_to for the unnamed register, gives the +--- single letter name of the register +--- currently pointed to (see |quotequote|). +--- For example, after deleting a line +--- with `dd`, this field will be "1", +--- which is the register that got the +--- deleted text. +--- +--- The {regname} argument is a string. If {regname} is invalid +--- or not set, an empty Dictionary will be returned. +--- If {regname} is not specified, |v:register| is used. +--- The returned Dictionary can be passed to |setreg()|. +--- +--- @param regname? string +--- @return table +function vim.fn.getreginfo(regname) end + +--- The result is a String, which is type of register {regname}. +--- The value will be one of: +--- "v" for |charwise| text +--- "V" for |linewise| text +--- "<CTRL-V>{width}" for |blockwise-visual| text +--- "" for an empty or unknown register +--- <CTRL-V> is one character with value 0x16. +--- The {regname} argument is a string. If {regname} is not +--- specified, |v:register| is used. +--- +--- @param regname? string +--- @return string +function vim.fn.getregtype(regname) end + +--- Returns a |List| with information about all the sourced Vim +--- scripts in the order they were sourced, like what +--- `:scriptnames` shows. +--- +--- The optional Dict argument {opts} supports the following +--- optional items: +--- name Script name match pattern. If specified, +--- and "sid" is not specified, information about +--- scripts with a name that match the pattern +--- "name" are returned. +--- sid Script ID |<SID>|. If specified, only +--- information about the script with ID "sid" is +--- returned and "name" is ignored. +--- +--- Each item in the returned List is a |Dict| with the following +--- items: +--- autoload Always set to FALSE. +--- functions List of script-local function names defined in +--- the script. Present only when a particular +--- script is specified using the "sid" item in +--- {opts}. +--- name Vim script file name. +--- sid Script ID |<SID>|. +--- variables A dictionary with the script-local variables. +--- Present only when a particular script is +--- specified using the "sid" item in {opts}. +--- Note that this is a copy, the value of +--- script-local variables cannot be changed using +--- this dictionary. +--- version Vim script version, always 1 +--- +--- Examples: >vim +--- echo getscriptinfo({'name': 'myscript'}) +--- echo getscriptinfo({'sid': 15}).variables +--- < +--- +--- @param opts? table +--- @return any +function vim.fn.getscriptinfo(opts) end + +--- If {tabnr} is not specified, then information about all the +--- tab pages is returned as a |List|. Each List item is a +--- |Dictionary|. Otherwise, {tabnr} specifies the tab page +--- number and information about that one is returned. If the tab +--- page does not exist an empty List is returned. +--- +--- Each List item is a |Dictionary| with the following entries: +--- tabnr tab page number. +--- variables a reference to the dictionary with +--- tabpage-local variables +--- windows List of |window-ID|s in the tab page. +--- +--- @param tabnr? integer +--- @return any +function vim.fn.gettabinfo(tabnr) end + +--- Get the value of a tab-local variable {varname} in tab page +--- {tabnr}. |t:var| +--- Tabs are numbered starting with one. +--- The {varname} argument is a string. When {varname} is empty a +--- dictionary with all tab-local variables is returned. +--- Note that the name without "t:" must be used. +--- When the tab or variable doesn't exist {def} or an empty +--- string is returned, there is no error message. +--- +--- @param tabnr integer +--- @param varname string +--- @param def? any +--- @return any +function vim.fn.gettabvar(tabnr, varname, def) end + +--- Get the value of window-local variable {varname} in window +--- {winnr} in tab page {tabnr}. +--- The {varname} argument is a string. When {varname} is empty a +--- dictionary with all window-local variables is returned. +--- When {varname} is equal to "&" get the values of all +--- window-local options in a |Dictionary|. +--- Otherwise, when {varname} starts with "&" get the value of a +--- window-local option. +--- Note that {varname} must be the name without "w:". +--- Tabs are numbered starting with one. For the current tabpage +--- use |getwinvar()|. +--- {winnr} can be the window number or the |window-ID|. +--- When {winnr} is zero the current window is used. +--- This also works for a global option, buffer-local option and +--- window-local option, but it doesn't work for a global variable +--- or buffer-local variable. +--- When the tab, window or variable doesn't exist {def} or an +--- empty string is returned, there is no error message. +--- Examples: >vim +--- let list_is_on = gettabwinvar(1, 2, '&list') +--- echo "myvar = " .. gettabwinvar(3, 1, 'myvar') +--- < +--- To obtain all window-local variables use: >vim +--- gettabwinvar({tabnr}, {winnr}, '&') +--- < +--- +--- @param tabnr integer +--- @param winnr integer +--- @param varname string +--- @param def? any +--- @return any +function vim.fn.gettabwinvar(tabnr, winnr, varname, def) end + +--- The result is a Dict, which is the tag stack of window {winnr}. +--- {winnr} can be the window number or the |window-ID|. +--- When {winnr} is not specified, the current window is used. +--- When window {winnr} doesn't exist, an empty Dict is returned. +--- +--- The returned dictionary contains the following entries: +--- curidx Current index in the stack. When at +--- top of the stack, set to (length + 1). +--- Index of bottom of the stack is 1. +--- items List of items in the stack. Each item +--- is a dictionary containing the +--- entries described below. +--- length Number of entries in the stack. +--- +--- Each item in the stack is a dictionary with the following +--- entries: +--- bufnr buffer number of the current jump +--- from cursor position before the tag jump. +--- See |getpos()| for the format of the +--- returned list. +--- matchnr current matching tag number. Used when +--- multiple matching tags are found for a +--- name. +--- tagname name of the tag +--- +--- See |tagstack| for more information about the tag stack. +--- +--- @param winnr? integer +--- @return any +function vim.fn.gettagstack(winnr) end + +--- Translate String {text} if possible. +--- This is mainly for use in the distributed Vim scripts. When +--- generating message translations the {text} is extracted by +--- xgettext, the translator can add the translated message in the +--- .po file and Vim will lookup the translation when gettext() is +--- called. +--- For {text} double quoted strings are preferred, because +--- xgettext does not understand escaping in single quoted +--- strings. +--- +--- @param text any +--- @return any +function vim.fn.gettext(text) end + +--- Returns information about windows as a |List| with Dictionaries. +--- +--- If {winid} is given Information about the window with that ID +--- is returned, as a |List| with one item. If the window does not +--- exist the result is an empty list. +--- +--- Without {winid} information about all the windows in all the +--- tab pages is returned. +--- +--- Each List item is a |Dictionary| with the following entries: +--- botline last complete displayed buffer line +--- bufnr number of buffer in the window +--- height window height (excluding winbar) +--- loclist 1 if showing a location list +--- quickfix 1 if quickfix or location list window +--- terminal 1 if a terminal window +--- tabnr tab page number +--- topline first displayed buffer line +--- variables a reference to the dictionary with +--- window-local variables +--- width window width +--- winbar 1 if the window has a toolbar, 0 +--- otherwise +--- wincol leftmost screen column of the window; +--- "col" from |win_screenpos()| +--- textoff number of columns occupied by any +--- 'foldcolumn', 'signcolumn' and line +--- number in front of the text +--- winid |window-ID| +--- winnr window number +--- winrow topmost screen line of the window; +--- "row" from |win_screenpos()| +--- +--- @param winid? integer +--- @return vim.fn.getwininfo.ret.item[] +function vim.fn.getwininfo(winid) end + +--- The result is a |List| with two numbers, the result of +--- |getwinposx()| and |getwinposy()| combined: +--- [x-pos, y-pos] +--- {timeout} can be used to specify how long to wait in msec for +--- a response from the terminal. When omitted 100 msec is used. +--- +--- Use a longer time for a remote terminal. +--- When using a value less than 10 and no response is received +--- within that time, a previously reported position is returned, +--- if available. This can be used to poll for the position and +--- do some work in the meantime: >vim +--- while 1 +--- let res = getwinpos(1) +--- if res[0] >= 0 +--- break +--- endif +--- " Do some work here +--- endwhile +--- < +--- +--- @param timeout? integer +--- @return any +function vim.fn.getwinpos(timeout) end + +--- The result is a Number, which is the X coordinate in pixels of +--- the left hand side of the GUI Vim window. The result will be +--- -1 if the information is not available. +--- The value can be used with `:winpos`. +--- +--- @return integer +function vim.fn.getwinposx() end + +--- The result is a Number, which is the Y coordinate in pixels of +--- the top of the GUI Vim window. The result will be -1 if the +--- information is not available. +--- The value can be used with `:winpos`. +--- +--- @return integer +function vim.fn.getwinposy() end + +--- Like |gettabwinvar()| for the current tabpage. +--- Examples: >vim +--- let list_is_on = getwinvar(2, '&list') +--- echo "myvar = " .. getwinvar(1, 'myvar') +--- +--- @param winnr integer +--- @param varname string +--- @param def? any +--- @return any +function vim.fn.getwinvar(winnr, varname, def) end + +--- Expand the file wildcards in {expr}. See |wildcards| for the +--- use of special characters. +--- +--- Unless the optional {nosuf} argument is given and is |TRUE|, +--- the 'suffixes' and 'wildignore' options apply: Names matching +--- one of the patterns in 'wildignore' will be skipped and +--- 'suffixes' affect the ordering of matches. +--- 'wildignorecase' always applies. +--- +--- When {list} is present and it is |TRUE| the result is a |List| +--- with all matching files. The advantage of using a List is, +--- you also get filenames containing newlines correctly. +--- Otherwise the result is a String and when there are several +--- matches, they are separated by <NL> characters. +--- +--- If the expansion fails, the result is an empty String or List. +--- +--- You can also use |readdir()| if you need to do complicated +--- things, such as limiting the number of matches. +--- +--- A name for a non-existing file is not included. A symbolic +--- link is only included if it points to an existing file. +--- However, when the {alllinks} argument is present and it is +--- |TRUE| then all symbolic links are included. +--- +--- For most systems backticks can be used to get files names from +--- any external command. Example: >vim +--- let tagfiles = glob("`find . -name tags -print`") +--- let &tags = substitute(tagfiles, "\n", ",", "g") +--- <The result of the program inside the backticks should be one +--- item per line. Spaces inside an item are allowed. +--- +--- See |expand()| for expanding special Vim variables. See +--- |system()| for getting the raw output of an external command. +--- +--- @param expr any +--- @param nosuf? boolean +--- @param list? any +--- @param alllinks? any +--- @return any +function vim.fn.glob(expr, nosuf, list, alllinks) end + +--- Convert a file pattern, as used by glob(), into a search +--- pattern. The result can be used to match with a string that +--- is a file name. E.g. >vim +--- if filename =~ glob2regpat('Make*.mak') +--- " ... +--- endif +--- <This is equivalent to: >vim +--- if filename =~ '^Make.*\.mak$' +--- " ... +--- endif +--- <When {string} is an empty string the result is "^$", match an +--- empty string. +--- Note that the result depends on the system. On MS-Windows +--- a backslash usually means a path separator. +--- +--- @param string string +--- @return any +function vim.fn.glob2regpat(string) end + +--- Perform glob() for String {expr} on all directories in {path} +--- and concatenate the results. Example: >vim +--- echo globpath(&rtp, "syntax/c.vim") +--- < +--- {path} is a comma-separated list of directory names. Each +--- directory name is prepended to {expr} and expanded like with +--- |glob()|. A path separator is inserted when needed. +--- To add a comma inside a directory name escape it with a +--- backslash. Note that on MS-Windows a directory may have a +--- trailing backslash, remove it if you put a comma after it. +--- If the expansion fails for one of the directories, there is no +--- error message. +--- +--- Unless the optional {nosuf} argument is given and is |TRUE|, +--- the 'suffixes' and 'wildignore' options apply: Names matching +--- one of the patterns in 'wildignore' will be skipped and +--- 'suffixes' affect the ordering of matches. +--- +--- When {list} is present and it is |TRUE| the result is a |List| +--- with all matching files. The advantage of using a List is, you +--- also get filenames containing newlines correctly. Otherwise +--- the result is a String and when there are several matches, +--- they are separated by <NL> characters. Example: >vim +--- echo globpath(&rtp, "syntax/c.vim", 0, 1) +--- < +--- {allinks} is used as with |glob()|. +--- +--- The "**" item can be used to search in a directory tree. +--- For example, to find all "README.txt" files in the directories +--- in 'runtimepath' and below: >vim +--- echo globpath(&rtp, "**/README.txt") +--- <Upwards search and limiting the depth of "**" is not +--- supported, thus using 'path' will not always work properly. +--- +--- @param path string +--- @param expr any +--- @param nosuf? boolean +--- @param list? any +--- @param allinks? any +--- @return any +function vim.fn.globpath(path, expr, nosuf, list, allinks) end + +--- Returns 1 if {feature} is supported, 0 otherwise. The +--- {feature} argument is a feature name like "nvim-0.2.1" or +--- "win32", see below. See also |exists()|. +--- +--- To get the system name use |vim.uv|.os_uname() in Lua: >lua +--- print(vim.uv.os_uname().sysname) +--- +--- <If the code has a syntax error then Vimscript may skip the +--- rest of the line. Put |:if| and |:endif| on separate lines to +--- avoid the syntax error: >vim +--- if has('feature') +--- let x = this_breaks_without_the_feature() +--- endif +--- < +--- Vim's compile-time feature-names (prefixed with "+") are not +--- recognized because Nvim is always compiled with all possible +--- features. |feature-compile| +--- +--- Feature names can be: +--- 1. Nvim version. For example the "nvim-0.2.1" feature means +--- that Nvim is version 0.2.1 or later: >vim +--- if has("nvim-0.2.1") +--- " ... +--- endif +--- +--- <2. Runtime condition or other pseudo-feature. For example the +--- "win32" feature checks if the current system is Windows: >vim +--- if has("win32") +--- " ... +--- endif +--- < *feature-list* +--- List of supported pseudo-feature names: +--- acl |ACL| support. +--- bsd BSD system (not macOS, use "mac" for that). +--- clipboard |clipboard| provider is available. +--- fname_case Case in file names matters (for Darwin and MS-Windows +--- this is not present). +--- gui_running Nvim has a GUI. +--- iconv Can use |iconv()| for conversion. +--- linux Linux system. +--- mac MacOS system. +--- nvim This is Nvim. +--- python3 Legacy Vim |python3| interface. |has-python| +--- pythonx Legacy Vim |python_x| interface. |has-pythonx| +--- sun SunOS system. +--- ttyin input is a terminal (tty). +--- ttyout output is a terminal (tty). +--- unix Unix system. +--- *vim_starting* True during |startup|. +--- win32 Windows system (32 or 64 bit). +--- win64 Windows system (64 bit). +--- wsl WSL (Windows Subsystem for Linux) system. +--- +--- *has-patch* +--- 3. Vim patch. For example the "patch123" feature means that +--- Vim patch 123 at the current |v:version| was included: >vim +--- if v:version > 602 || v:version == 602 && has("patch148") +--- " ... +--- endif +--- +--- <4. Vim version. For example the "patch-7.4.237" feature means +--- that Nvim is Vim-compatible to version 7.4.237 or later. >vim +--- if has("patch-7.4.237") +--- " ... +--- endif +--- < +--- +--- @param feature any +--- @return 0|1 +function vim.fn.has(feature) end + +--- The result is a Number, which is TRUE if |Dictionary| {dict} +--- has an entry with key {key}. FALSE otherwise. The {key} +--- argument is a string. +--- +--- @param dict any +--- @param key any +--- @return 0|1 +function vim.fn.has_key(dict, key) end + +--- The result is a Number, which is 1 when the window has set a +--- local path via |:lcd| or when {winnr} is -1 and the tabpage +--- has set a local path via |:tcd|, otherwise 0. +--- +--- Tabs and windows are identified by their respective numbers, +--- 0 means current tab or window. Missing argument implies 0. +--- Thus the following are equivalent: >vim +--- echo haslocaldir() +--- echo haslocaldir(0) +--- echo haslocaldir(0, 0) +--- <With {winnr} use that window in the current tabpage. +--- With {winnr} and {tabnr} use the window in that tabpage. +--- {winnr} can be the window number or the |window-ID|. +--- If {winnr} is -1 it is ignored, only the tab is resolved. +--- Throw error if the arguments are invalid. |E5000| |E5001| |E5002| +--- +--- @param winnr? integer +--- @param tabnr? integer +--- @return 0|1 +function vim.fn.haslocaldir(winnr, tabnr) end + +--- The result is a Number, which is TRUE if there is a mapping +--- that contains {what} in somewhere in the rhs (what it is +--- mapped to) and this mapping exists in one of the modes +--- indicated by {mode}. +--- The arguments {what} and {mode} are strings. +--- When {abbr} is there and it is |TRUE| use abbreviations +--- instead of mappings. Don't forget to specify Insert and/or +--- Command-line mode. +--- Both the global mappings and the mappings local to the current +--- buffer are checked for a match. +--- If no matching mapping is found FALSE is returned. +--- The following characters are recognized in {mode}: +--- n Normal mode +--- v Visual and Select mode +--- x Visual mode +--- s Select mode +--- o Operator-pending mode +--- i Insert mode +--- l Language-Argument ("r", "f", "t", etc.) +--- c Command-line mode +--- When {mode} is omitted, "nvo" is used. +--- +--- This function is useful to check if a mapping already exists +--- to a function in a Vim script. Example: >vim +--- if !hasmapto('\ABCdoit') +--- map <Leader>d \ABCdoit +--- endif +--- <This installs the mapping to "\ABCdoit" only if there isn't +--- already a mapping to "\ABCdoit". +--- +--- @param what any +--- @param mode? string +--- @param abbr? any +--- @return 0|1 +function vim.fn.hasmapto(what, mode, abbr) end + +--- @deprecated +--- Obsolete name for |hlID()|. +--- +--- @param name string +--- @return any +function vim.fn.highlightID(name) end + +--- @deprecated +--- Obsolete name for |hlexists()|. +--- +--- @param name string +--- @return any +function vim.fn.highlight_exists(name) end + +--- Add the String {item} to the history {history} which can be +--- one of: *hist-names* +--- "cmd" or ":" command line history +--- "search" or "/" search pattern history +--- "expr" or "=" typed expression history +--- "input" or "\@" input line history +--- "debug" or ">" debug command history +--- empty the current or last used history +--- The {history} string does not need to be the whole name, one +--- character is sufficient. +--- If {item} does already exist in the history, it will be +--- shifted to become the newest entry. +--- The result is a Number: TRUE if the operation was successful, +--- otherwise FALSE is returned. +--- +--- Example: >vim +--- call histadd("input", strftime("%Y %b %d")) +--- let date=input("Enter date: ") +--- <This function is not available in the |sandbox|. +--- +--- @param history any +--- @param item any +--- @return 0|1 +function vim.fn.histadd(history, item) end + +--- Clear {history}, i.e. delete all its entries. See |hist-names| +--- for the possible values of {history}. +--- +--- If the parameter {item} evaluates to a String, it is used as a +--- regular expression. All entries matching that expression will +--- be removed from the history (if there are any). +--- Upper/lowercase must match, unless "\c" is used |/\c|. +--- If {item} evaluates to a Number, it will be interpreted as +--- an index, see |:history-indexing|. The respective entry will +--- be removed if it exists. +--- +--- The result is TRUE for a successful operation, otherwise FALSE +--- is returned. +--- +--- Examples: +--- Clear expression register history: >vim +--- call histdel("expr") +--- < +--- Remove all entries starting with "*" from the search history: >vim +--- call histdel("/", '^\*') +--- < +--- The following three are equivalent: >vim +--- call histdel("search", histnr("search")) +--- call histdel("search", -1) +--- call histdel("search", '^' .. histget("search", -1) .. '$') +--- < +--- To delete the last search pattern and use the last-but-one for +--- the "n" command and 'hlsearch': >vim +--- call histdel("search", -1) +--- let \@/ = histget("search", -1) +--- < +--- +--- @param history any +--- @param item? any +--- @return 0|1 +function vim.fn.histdel(history, item) end + +--- The result is a String, the entry with Number {index} from +--- {history}. See |hist-names| for the possible values of +--- {history}, and |:history-indexing| for {index}. If there is +--- no such entry, an empty String is returned. When {index} is +--- omitted, the most recent item from the history is used. +--- +--- Examples: +--- Redo the second last search from history. >vim +--- execute '/' .. histget("search", -2) +--- +--- <Define an Ex command ":H {num}" that supports re-execution of +--- the {num}th entry from the output of |:history|. >vim +--- command -nargs=1 H execute histget("cmd", 0+<args>) +--- < +--- +--- @param history any +--- @param index? any +--- @return string +function vim.fn.histget(history, index) end + +--- The result is the Number of the current entry in {history}. +--- See |hist-names| for the possible values of {history}. +--- If an error occurred, -1 is returned. +--- +--- Example: >vim +--- let inp_index = histnr("expr") +--- +--- @param history any +--- @return integer +function vim.fn.histnr(history) end + +--- The result is a Number, which is the ID of the highlight group +--- with name {name}. When the highlight group doesn't exist, +--- zero is returned. +--- This can be used to retrieve information about the highlight +--- group. For example, to get the background color of the +--- "Comment" group: >vim +--- echo synIDattr(synIDtrans(hlID("Comment")), "bg") +--- < +--- +--- @param name string +--- @return integer +function vim.fn.hlID(name) end + +--- The result is a Number, which is TRUE if a highlight group +--- called {name} exists. This is when the group has been +--- defined in some way. Not necessarily when highlighting has +--- been defined for it, it may also have been used for a syntax +--- item. +--- +--- @param name string +--- @return 0|1 +function vim.fn.hlexists(name) end + +--- The result is a String, which is the name of the machine on +--- which Vim is currently running. Machine names greater than +--- 256 characters long are truncated. +--- +--- @return string +function vim.fn.hostname() end + +--- The result is a String, which is the text {string} converted +--- from encoding {from} to encoding {to}. +--- When the conversion completely fails an empty string is +--- returned. When some characters could not be converted they +--- are replaced with "?". +--- The encoding names are whatever the iconv() library function +--- can accept, see ":!man 3 iconv". +--- Note that Vim uses UTF-8 for all Unicode encodings, conversion +--- from/to UCS-2 is automatically changed to use UTF-8. You +--- cannot use UCS-2 in a string anyway, because of the NUL bytes. +--- +--- @param string string +--- @param from any +--- @param to any +--- @return any +function vim.fn.iconv(string, from, to) end + +--- Returns a |String| which is a unique identifier of the +--- container type (|List|, |Dict|, |Blob| and |Partial|). It is +--- guaranteed that for the mentioned types `id(v1) ==# id(v2)` +--- returns true iff `type(v1) == type(v2) && v1 is v2`. +--- Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and +--- `v:_null_blob` have the same `id()` with different types +--- because they are internally represented as NULL pointers. +--- `id()` returns a hexadecimal representanion of the pointers to +--- the containers (i.e. like `0x994a40`), same as `printf("%p", +--- {expr})`, but it is advised against counting on the exact +--- format of the return value. +--- +--- It is not guaranteed that `id(no_longer_existing_container)` +--- will not be equal to some other `id()`: new containers may +--- reuse identifiers of the garbage-collected ones. +--- +--- @param expr any +--- @return any +function vim.fn.id(expr) end + +--- The result is a Number, which is indent of line {lnum} in the +--- current buffer. The indent is counted in spaces, the value +--- of 'tabstop' is relevant. {lnum} is used just like in +--- |getline()|. +--- When {lnum} is invalid -1 is returned. +--- +--- @param lnum integer +--- @return integer +function vim.fn.indent(lnum) end + +--- Find {expr} in {object} and return its index. See +--- |indexof()| for using a lambda to select the item. +--- +--- If {object} is a |List| return the lowest index where the item +--- has a value equal to {expr}. There is no automatic +--- conversion, so the String "4" is different from the Number 4. +--- And the Number 4 is different from the Float 4.0. The value +--- of 'ignorecase' is not used here, case matters as indicated by +--- the {ic} argument. +--- +--- If {object} is a |Blob| return the lowest index where the byte +--- value is equal to {expr}. +--- +--- If {start} is given then start looking at the item with index +--- {start} (may be negative for an item relative to the end). +--- +--- When {ic} is given and it is |TRUE|, ignore case. Otherwise +--- case must match. +--- +--- -1 is returned when {expr} is not found in {object}. +--- Example: >vim +--- let idx = index(words, "the") +--- if index(numbers, 123) >= 0 +--- " ... +--- endif +--- +--- @param object any +--- @param expr any +--- @param start? any +--- @param ic? any +--- @return any +function vim.fn.index(object, expr, start, ic) end + +--- Returns the index of an item in {object} where {expr} is +--- v:true. {object} must be a |List| or a |Blob|. +--- +--- If {object} is a |List|, evaluate {expr} for each item in the +--- List until the expression is v:true and return the index of +--- this item. +--- +--- If {object} is a |Blob| evaluate {expr} for each byte in the +--- Blob until the expression is v:true and return the index of +--- this byte. +--- +--- {expr} must be a |string| or |Funcref|. +--- +--- If {expr} is a |string|: If {object} is a |List|, inside +--- {expr} |v:key| has the index of the current List item and +--- |v:val| has the value of the item. If {object} is a |Blob|, +--- inside {expr} |v:key| has the index of the current byte and +--- |v:val| has the byte value. +--- +--- If {expr} is a |Funcref| it must take two arguments: +--- 1. the key or the index of the current item. +--- 2. the value of the current item. +--- The function must return |TRUE| if the item is found and the +--- search should stop. +--- +--- The optional argument {opts} is a Dict and supports the +--- following items: +--- startidx start evaluating {expr} at the item with this +--- index; may be negative for an item relative to +--- the end +--- Returns -1 when {expr} evaluates to v:false for all the items. +--- Example: >vim +--- let l = [#{n: 10}, #{n: 20}, #{n: 30}] +--- echo indexof(l, "v:val.n == 20") +--- echo indexof(l, {i, v -> v.n == 30}) +--- echo indexof(l, "v:val.n == 20", #{startidx: 1}) +--- +--- @param object any +--- @param expr any +--- @param opts? table +--- @return any +function vim.fn.indexof(object, expr, opts) end + +--- +--- @param prompt any +--- @param text? any +--- @param completion? any +--- @return any +function vim.fn.input(prompt, text, completion) end + +--- The result is a String, which is whatever the user typed on +--- the command-line. The {prompt} argument is either a prompt +--- string, or a blank string (for no prompt). A '\n' can be used +--- in the prompt to start a new line. +--- +--- In the second form it accepts a single dictionary with the +--- following keys, any of which may be omitted: +--- +--- Key Default Description ~ +--- prompt "" Same as {prompt} in the first form. +--- default "" Same as {text} in the first form. +--- completion nothing Same as {completion} in the first form. +--- cancelreturn "" The value returned when the dialog is +--- cancelled. +--- highlight nothing Highlight handler: |Funcref|. +--- +--- The highlighting set with |:echohl| is used for the prompt. +--- The input is entered just like a command-line, with the same +--- editing commands and mappings. There is a separate history +--- for lines typed for input(). +--- Example: >vim +--- if input("Coffee or beer? ") == "beer" +--- echo "Cheers!" +--- endif +--- < +--- If the optional {text} argument is present and not empty, this +--- is used for the default reply, as if the user typed this. +--- Example: >vim +--- let color = input("Color? ", "white") +--- +--- <The optional {completion} argument specifies the type of +--- completion supported for the input. Without it completion is +--- not performed. The supported completion types are the same as +--- that can be supplied to a user-defined command using the +--- "-complete=" argument. Refer to |:command-completion| for +--- more information. Example: >vim +--- let fname = input("File: ", "", "file") +--- +--- < *input()-highlight* *E5400* *E5402* +--- The optional `highlight` key allows specifying function which +--- will be used for highlighting user input. This function +--- receives user input as its only argument and must return +--- a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group] +--- where +--- hl_start_col is the first highlighted column, +--- hl_end_col is the last highlighted column (+ 1!), +--- hl_group is |:hi| group used for highlighting. +--- *E5403* *E5404* *E5405* *E5406* +--- Both hl_start_col and hl_end_col + 1 must point to the start +--- of the multibyte character (highlighting must not break +--- multibyte characters), hl_end_col + 1 may be equal to the +--- input length. Start column must be in range [0, len(input)), +--- end column must be in range (hl_start_col, len(input)], +--- sections must be ordered so that next hl_start_col is greater +--- then or equal to previous hl_end_col. +--- +--- Example (try some input with parentheses): >vim +--- highlight RBP1 guibg=Red ctermbg=red +--- highlight RBP2 guibg=Yellow ctermbg=yellow +--- highlight RBP3 guibg=Green ctermbg=green +--- highlight RBP4 guibg=Blue ctermbg=blue +--- let g:rainbow_levels = 4 +--- function! RainbowParens(cmdline) +--- let ret = [] +--- let i = 0 +--- let lvl = 0 +--- while i < len(a:cmdline) +--- if a:cmdline[i] is# '(' +--- call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) +--- let lvl += 1 +--- elseif a:cmdline[i] is# ')' +--- let lvl -= 1 +--- call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) +--- endif +--- let i += 1 +--- endwhile +--- return ret +--- endfunction +--- call input({'prompt':'>','highlight':'RainbowParens'}) +--- < +--- Highlight function is called at least once for each new +--- displayed input string, before command-line is redrawn. It is +--- expected that function is pure for the duration of one input() +--- call, i.e. it produces the same output for the same input, so +--- output may be memoized. Function is run like under |:silent| +--- modifier. If the function causes any errors, it will be +--- skipped for the duration of the current input() call. +--- +--- Highlighting is disabled if command-line contains arabic +--- characters. +--- +--- NOTE: This function must not be used in a startup file, for +--- the versions that only run in GUI mode (e.g., the Win32 GUI). +--- Note: When input() is called from within a mapping it will +--- consume remaining characters from that mapping, because a +--- mapping is handled like the characters were typed. +--- Use |inputsave()| before input() and |inputrestore()| +--- after input() to avoid that. Another solution is to avoid +--- that further characters follow in the mapping, e.g., by using +--- |:execute| or |:normal|. +--- +--- Example with a mapping: >vim +--- nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR> +--- function GetFoo() +--- call inputsave() +--- let g:Foo = input("enter search pattern: ") +--- call inputrestore() +--- endfunction +--- +--- @param opts table +--- @return any +function vim.fn.input(opts) end + +--- @deprecated +--- Use |input()| instead. +--- +--- @param ... any +--- @return any +function vim.fn.inputdialog(...) end + +--- {textlist} must be a |List| of strings. This |List| is +--- displayed, one string per line. The user will be prompted to +--- enter a number, which is returned. +--- The user can also select an item by clicking on it with the +--- mouse, if the mouse is enabled in the command line ('mouse' is +--- "a" or includes "c"). For the first string 0 is returned. +--- When clicking above the first item a negative number is +--- returned. When clicking on the prompt one more than the +--- length of {textlist} is returned. +--- Make sure {textlist} has less than 'lines' entries, otherwise +--- it won't work. It's a good idea to put the entry number at +--- the start of the string. And put a prompt in the first item. +--- Example: >vim +--- let color = inputlist(['Select color:', '1. red', +--- \ '2. green', '3. blue']) +--- +--- @param textlist any +--- @return any +function vim.fn.inputlist(textlist) end + +--- Restore typeahead that was saved with a previous |inputsave()|. +--- Should be called the same number of times inputsave() is +--- called. Calling it more often is harmless though. +--- Returns TRUE when there is nothing to restore, FALSE otherwise. +--- +--- @return any +function vim.fn.inputrestore() end + +--- Preserve typeahead (also from mappings) and clear it, so that +--- a following prompt gets input from the user. Should be +--- followed by a matching inputrestore() after the prompt. Can +--- be used several times, in which case there must be just as +--- many inputrestore() calls. +--- Returns TRUE when out of memory, FALSE otherwise. +--- +--- @return any +function vim.fn.inputsave() end + +--- This function acts much like the |input()| function with but +--- two exceptions: +--- a) the user's response will be displayed as a sequence of +--- asterisks ("*") thereby keeping the entry secret, and +--- b) the user's response will not be recorded on the input +--- |history| stack. +--- The result is a String, which is whatever the user actually +--- typed on the command-line in response to the issued prompt. +--- NOTE: Command-line completion is not supported. +--- +--- @param prompt any +--- @param text? any +--- @return any +function vim.fn.inputsecret(prompt, text) end + +--- When {object} is a |List| or a |Blob| insert {item} at the start +--- of it. +--- +--- If {idx} is specified insert {item} before the item with index +--- {idx}. If {idx} is zero it goes before the first item, just +--- like omitting {idx}. A negative {idx} is also possible, see +--- |list-index|. -1 inserts just before the last item. +--- +--- Returns the resulting |List| or |Blob|. Examples: >vim +--- let mylist = insert([2, 3, 5], 1) +--- call insert(mylist, 4, -1) +--- call insert(mylist, 6, len(mylist)) +--- <The last example can be done simpler with |add()|. +--- Note that when {item} is a |List| it is inserted as a single +--- item. Use |extend()| to concatenate |Lists|. +--- +--- @param object any +--- @param item any +--- @param idx? integer +--- @return any +function vim.fn.insert(object, item, idx) end + +--- Interrupt script execution. It works more or less like the +--- user typing CTRL-C, most commands won't execute and control +--- returns to the user. This is useful to abort execution +--- from lower down, e.g. in an autocommand. Example: >vim +--- function s:check_typoname(file) +--- if fnamemodify(a:file, ':t') == '[' +--- echomsg 'Maybe typo' +--- call interrupt() +--- endif +--- endfunction +--- au BufWritePre * call s:check_typoname(expand('<amatch>')) +--- < +--- +--- @return any +function vim.fn.interrupt() end + +--- Bitwise invert. The argument is converted to a number. A +--- List, Dict or Float argument causes an error. Example: >vim +--- let bits = invert(bits) +--- < +--- +--- @param expr any +--- @return any +function vim.fn.invert(expr) end + +--- The result is a Number, which is |TRUE| when a directory +--- with the name {directory} exists. If {directory} doesn't +--- exist, or isn't a directory, the result is |FALSE|. {directory} +--- is any expression, which is used as a String. +--- +--- @param directory any +--- @return 0|1 +function vim.fn.isdirectory(directory) end + +--- Return 1 if {expr} is a positive infinity, or -1 a negative +--- infinity, otherwise 0. >vim +--- echo isinf(1.0 / 0.0) +--- < 1 >vim +--- echo isinf(-1.0 / 0.0) +--- < -1 +--- +--- @param expr any +--- @return 1|0|-1 +function vim.fn.isinf(expr) end + +--- The result is a Number, which is |TRUE| when {expr} is the +--- name of a locked variable. +--- The string argument {expr} must be the name of a variable, +--- |List| item or |Dictionary| entry, not the variable itself! +--- Example: >vim +--- let alist = [0, ['a', 'b'], 2, 3] +--- lockvar 1 alist +--- echo islocked('alist') " 1 +--- echo islocked('alist[1]') " 0 +--- +--- <When {expr} is a variable that does not exist you get an error +--- message. Use |exists()| to check for existence. +--- +--- @param expr any +--- @return 0|1 +function vim.fn.islocked(expr) end + +--- Return |TRUE| if {expr} is a float with value NaN. >vim +--- echo isnan(0.0 / 0.0) +--- < 1 +--- +--- @param expr any +--- @return 0|1 +function vim.fn.isnan(expr) end + +--- Return a |List| with all the key-value pairs of {dict}. Each +--- |List| item is a list with two items: the key of a {dict} +--- entry and the value of this entry. The |List| is in arbitrary +--- order. Also see |keys()| and |values()|. +--- Example: >vim +--- for [key, value] in items(mydict) +--- echo key .. ': ' .. value +--- endfor +--- +--- @param dict any +--- @return any +function vim.fn.items(dict) end + +--- @deprecated +--- Obsolete name for |chanclose()| +--- +--- @param ... any +--- @return any +function vim.fn.jobclose(...) end + +--- Return the PID (process id) of |job-id| {job}. +--- +--- @param job any +--- @return integer +function vim.fn.jobpid(job) end + +--- Resize the pseudo terminal window of |job-id| {job} to {width} +--- columns and {height} rows. +--- Fails if the job was not started with `"pty":v:true`. +--- +--- @param job any +--- @param width integer +--- @param height integer +--- @return any +function vim.fn.jobresize(job, width, height) end + +--- @deprecated +--- Obsolete name for |chansend()| +--- +--- @param ... any +--- @return any +function vim.fn.jobsend(...) end + +--- Note: Prefer |vim.system()| in Lua (unless using the `pty` option). +--- +--- Spawns {cmd} as a job. +--- If {cmd} is a List it runs directly (no 'shell'). +--- If {cmd} is a String it runs in the 'shell', like this: >vim +--- call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) +--- <(See |shell-unquoting| for details.) +--- +--- Example: >vim +--- call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}}) +--- < +--- Returns |job-id| on success, 0 on invalid arguments (or job +--- table is full), -1 if {cmd}[0] or 'shell' is not executable. +--- The returned job-id is a valid |channel-id| representing the +--- job's stdio streams. Use |chansend()| (or |rpcnotify()| and +--- |rpcrequest()| if "rpc" was enabled) to send data to stdin and +--- |chanclose()| to close the streams without stopping the job. +--- +--- See |job-control| and |RPC|. +--- +--- NOTE: on Windows if {cmd} is a List: +--- - cmd[0] must be an executable (not a "built-in"). If it is +--- in $PATH it can be called by name, without an extension: >vim +--- call jobstart(['ping', 'neovim.io']) +--- < If it is a full or partial path, extension is required: >vim +--- call jobstart(['System32\ping.exe', 'neovim.io']) +--- < - {cmd} is collapsed to a string of quoted args as expected +--- by CommandLineToArgvW https://msdn.microsoft.com/bb776391 +--- unless cmd[0] is some form of "cmd.exe". +--- +--- *jobstart-env* +--- The job environment is initialized as follows: +--- $NVIM is set to |v:servername| of the parent Nvim +--- $NVIM_LISTEN_ADDRESS is unset +--- $NVIM_LOG_FILE is unset +--- $VIM is unset +--- $VIMRUNTIME is unset +--- You can set these with the `env` option. +--- +--- *jobstart-options* +--- {opts} is a dictionary with these keys: +--- clear_env: (boolean) `env` defines the job environment +--- exactly, instead of merging current environment. +--- cwd: (string, default=|current-directory|) Working +--- directory of the job. +--- detach: (boolean) Detach the job process: it will not be +--- killed when Nvim exits. If the process exits +--- before Nvim, `on_exit` will be invoked. +--- env: (dict) Map of environment variable name:value +--- pairs extending (or replace with "clear_env") +--- the current environment. |jobstart-env| +--- height: (number) Height of the `pty` terminal. +--- |on_exit|: (function) Callback invoked when the job exits. +--- |on_stdout|: (function) Callback invoked when the job emits +--- stdout data. +--- |on_stderr|: (function) Callback invoked when the job emits +--- stderr data. +--- overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the +--- stdio passed to the child process. Only on +--- MS-Windows; ignored on other platforms. +--- pty: (boolean) Connect the job to a new pseudo +--- terminal, and its streams to the master file +--- descriptor. `on_stdout` receives all output, +--- `on_stderr` is ignored. |terminal-start| +--- rpc: (boolean) Use |msgpack-rpc| to communicate with +--- the job over stdio. Then `on_stdout` is ignored, +--- but `on_stderr` can still be used. +--- stderr_buffered: (boolean) Collect data until EOF (stream closed) +--- before invoking `on_stderr`. |channel-buffered| +--- stdout_buffered: (boolean) Collect data until EOF (stream +--- closed) before invoking `on_stdout`. |channel-buffered| +--- stdin: (string) Either "pipe" (default) to connect the +--- job's stdin to a channel or "null" to disconnect +--- stdin. +--- width: (number) Width of the `pty` terminal. +--- +--- {opts} is passed as |self| dictionary to the callback; the +--- caller may set other keys to pass application-specific data. +--- +--- Returns: +--- - |channel-id| on success +--- - 0 on invalid arguments +--- - -1 if {cmd}[0] is not executable. +--- See also |job-control|, |channel|, |msgpack-rpc|. +--- +--- @param cmd any +--- @param opts? table +--- @return any +function vim.fn.jobstart(cmd, opts) end + +--- Stop |job-id| {id} by sending SIGTERM to the job process. If +--- the process does not terminate after a timeout then SIGKILL +--- will be sent. When the job terminates its |on_exit| handler +--- (if any) will be invoked. +--- See |job-control|. +--- +--- Returns 1 for valid job id, 0 for invalid id, including jobs have +--- exited or stopped. +--- +--- @param id any +--- @return any +function vim.fn.jobstop(id) end + +--- Waits for jobs and their |on_exit| handlers to complete. +--- +--- {jobs} is a List of |job-id|s to wait for. +--- {timeout} is the maximum waiting time in milliseconds. If +--- omitted or -1, wait forever. +--- +--- Timeout of 0 can be used to check the status of a job: >vim +--- let running = jobwait([{job-id}], 0)[0] == -1 +--- < +--- During jobwait() callbacks for jobs not in the {jobs} list may +--- be invoked. The screen will not redraw unless |:redraw| is +--- invoked by a callback. +--- +--- Returns a list of len({jobs}) integers, where each integer is +--- the status of the corresponding job: +--- Exit-code, if the job exited +--- -1 if the timeout was exceeded +--- -2 if the job was interrupted (by |CTRL-C|) +--- -3 if the job-id is invalid +--- +--- @param jobs any +--- @param timeout? integer +--- @return any +function vim.fn.jobwait(jobs, timeout) end + +--- Join the items in {list} together into one String. +--- When {sep} is specified it is put in between the items. If +--- {sep} is omitted a single space is used. +--- Note that {sep} is not added at the end. You might want to +--- add it there too: >vim +--- let lines = join(mylist, "\n") .. "\n" +--- <String items are used as-is. |Lists| and |Dictionaries| are +--- converted into a string like with |string()|. +--- The opposite function is |split()|. +--- +--- @param list any +--- @param sep? any +--- @return any +function vim.fn.join(list, sep) end + +--- Convert {expr} from JSON object. Accepts |readfile()|-style +--- list as the input, as well as regular string. May output any +--- Vim value. In the following cases it will output +--- |msgpack-special-dict|: +--- 1. Dictionary contains duplicate key. +--- 2. Dictionary contains empty key. +--- 3. String contains NUL byte. Two special dictionaries: for +--- dictionary and for string will be emitted in case string +--- with NUL byte was a dictionary key. +--- +--- Note: function treats its input as UTF-8 always. The JSON +--- standard allows only a few encodings, of which UTF-8 is +--- recommended and the only one required to be supported. +--- Non-UTF-8 characters are an error. +--- +--- @param expr any +--- @return any +function vim.fn.json_decode(expr) end + +--- Convert {expr} into a JSON string. Accepts +--- |msgpack-special-dict| as the input. Will not convert +--- |Funcref|s, mappings with non-string keys (can be created as +--- |msgpack-special-dict|), values with self-referencing +--- containers, strings which contain non-UTF-8 characters, +--- pseudo-UTF-8 strings which contain codepoints reserved for +--- surrogate pairs (such strings are not valid UTF-8 strings). +--- Non-printable characters are converted into "\u1234" escapes +--- or special escapes like "\t", other are dumped as-is. +--- |Blob|s are converted to arrays of the individual bytes. +--- +--- @param expr any +--- @return any +function vim.fn.json_encode(expr) end + +--- Return a |List| with all the keys of {dict}. The |List| is in +--- arbitrary order. Also see |items()| and |values()|. +--- +--- @param dict any +--- @return any +function vim.fn.keys(dict) end + +--- Turn the internal byte representation of keys into a form that +--- can be used for |:map|. E.g. >vim +--- let xx = "\<C-Home>" +--- echo keytrans(xx) +--- < <C-Home> +--- +--- @param string string +--- @return any +function vim.fn.keytrans(string) end + +--- @deprecated +--- Obsolete name for bufnr("$"). +--- +--- @return any +function vim.fn.last_buffer_nr() end + +--- The result is a Number, which is the length of the argument. +--- When {expr} is a String or a Number the length in bytes is +--- used, as with |strlen()|. +--- When {expr} is a |List| the number of items in the |List| is +--- returned. +--- When {expr} is a |Blob| the number of bytes is returned. +--- When {expr} is a |Dictionary| the number of entries in the +--- |Dictionary| is returned. +--- Otherwise an error is given and returns zero. +--- +--- @param expr any +--- @return any +function vim.fn.len(expr) end + +--- Call function {funcname} in the run-time library {libname} +--- with single argument {argument}. +--- This is useful to call functions in a library that you +--- especially made to be used with Vim. Since only one argument +--- is possible, calling standard library functions is rather +--- limited. +--- The result is the String returned by the function. If the +--- function returns NULL, this will appear as an empty string "" +--- to Vim. +--- If the function returns a number, use libcallnr()! +--- If {argument} is a number, it is passed to the function as an +--- int; if {argument} is a string, it is passed as a +--- null-terminated string. +--- +--- libcall() allows you to write your own 'plug-in' extensions to +--- Vim without having to recompile the program. It is NOT a +--- means to call system functions! If you try to do so Vim will +--- very probably crash. +--- +--- For Win32, the functions you write must be placed in a DLL +--- and use the normal C calling convention (NOT Pascal which is +--- used in Windows System DLLs). The function must take exactly +--- one parameter, either a character pointer or a long integer, +--- and must return a character pointer or NULL. The character +--- pointer returned must point to memory that will remain valid +--- after the function has returned (e.g. in static data in the +--- DLL). If it points to allocated memory, that memory will +--- leak away. Using a static buffer in the function should work, +--- it's then freed when the DLL is unloaded. +--- +--- WARNING: If the function returns a non-valid pointer, Vim may +--- crash! This also happens if the function returns a number, +--- because Vim thinks it's a pointer. +--- For Win32 systems, {libname} should be the filename of the DLL +--- without the ".DLL" suffix. A full path is only required if +--- the DLL is not in the usual places. +--- For Unix: When compiling your own plugins, remember that the +--- object code must be compiled as position-independent ('PIC'). +--- Examples: >vim +--- echo libcall("libc.so", "getenv", "HOME") +--- +--- @param libname string +--- @param funcname string +--- @param argument any +--- @return any +function vim.fn.libcall(libname, funcname, argument) end + +--- Just like |libcall()|, but used for a function that returns an +--- int instead of a string. +--- Examples: >vim +--- echo libcallnr("/usr/lib/libc.so", "getpid", "") +--- call libcallnr("libc.so", "printf", "Hello World!\n") +--- call libcallnr("libc.so", "sleep", 10) +--- < +--- +--- @param libname string +--- @param funcname string +--- @param argument any +--- @return any +function vim.fn.libcallnr(libname, funcname, argument) end + +--- The result is a Number, which is the line number of the file +--- position given with {expr}. The {expr} argument is a string. +--- The accepted positions are: +--- . the cursor position +--- $ the last line in the current buffer +--- 'x position of mark x (if the mark is not set, 0 is +--- returned) +--- w0 first line visible in current window (one if the +--- display isn't updated, e.g. in silent Ex mode) +--- w$ last line visible in current window (this is one +--- less than "w0" if no lines are visible) +--- v In Visual mode: the start of the Visual area (the +--- cursor is the end). When not in Visual mode +--- returns the cursor position. Differs from |'<| in +--- that it's updated right away. +--- Note that a mark in another file can be used. The line number +--- then applies to another buffer. +--- To get the column number use |col()|. To get both use +--- |getpos()|. +--- With the optional {winid} argument the values are obtained for +--- that window instead of the current window. +--- Returns 0 for invalid values of {expr} and {winid}. +--- Examples: >vim +--- echo line(".") " line number of the cursor +--- echo line(".", winid) " idem, in window "winid" +--- echo line("'t") " line number of mark t +--- echo line("'" .. marker) " line number of mark marker +--- < +--- To jump to the last known position when opening a file see +--- |last-position-jump|. +--- +--- @param expr any +--- @param winid? integer +--- @return integer +function vim.fn.line(expr, winid) end + +--- Return the byte count from the start of the buffer for line +--- {lnum}. This includes the end-of-line character, depending on +--- the 'fileformat' option for the current buffer. The first +--- line returns 1. UTF-8 encoding is used, 'fileencoding' is +--- ignored. This can also be used to get the byte count for the +--- line just below the last line: >vim +--- echo line2byte(line("$") + 1) +--- <This is the buffer size plus one. If 'fileencoding' is empty +--- it is the file size plus one. {lnum} is used like with +--- |getline()|. When {lnum} is invalid -1 is returned. +--- Also see |byte2line()|, |go| and |:goto|. +--- +--- @param lnum integer +--- @return integer +function vim.fn.line2byte(lnum) end + +--- Get the amount of indent for line {lnum} according the lisp +--- indenting rules, as with 'lisp'. +--- The indent is counted in spaces, the value of 'tabstop' is +--- relevant. {lnum} is used just like in |getline()|. +--- When {lnum} is invalid, -1 is returned. +--- +--- @param lnum integer +--- @return any +function vim.fn.lispindent(lnum) end + +--- Return a Blob concatenating all the number values in {list}. +--- Examples: >vim +--- echo list2blob([1, 2, 3, 4]) " returns 0z01020304 +--- echo list2blob([]) " returns 0z +--- <Returns an empty Blob on error. If one of the numbers is +--- negative or more than 255 error *E1239* is given. +--- +--- |blob2list()| does the opposite. +--- +--- @param list any +--- @return any +function vim.fn.list2blob(list) end + +--- Convert each number in {list} to a character string can +--- concatenate them all. Examples: >vim +--- echo list2str([32]) " returns " " +--- echo list2str([65, 66, 67]) " returns "ABC" +--- <The same can be done (slowly) with: >vim +--- echo join(map(list, {nr, val -> nr2char(val)}), '') +--- <|str2list()| does the opposite. +--- +--- UTF-8 encoding is always used, {utf8} option has no effect, +--- and exists only for backwards-compatibility. +--- With UTF-8 composing characters work as expected: >vim +--- echo list2str([97, 769]) " returns "á" +--- < +--- Returns an empty string on error. +--- +--- @param list any +--- @param utf8? any +--- @return any +function vim.fn.list2str(list, utf8) end + +--- Return the current time, measured as seconds since 1st Jan +--- 1970. See also |strftime()|, |strptime()| and |getftime()|. +--- +--- @return any +function vim.fn.localtime() end + +--- Return the natural logarithm (base e) of {expr} as a |Float|. +--- {expr} must evaluate to a |Float| or a |Number| in the range +--- (0, inf]. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo log(10) +--- < 2.302585 >vim +--- echo log(exp(5)) +--- < 5.0 +--- +--- @param expr any +--- @return any +function vim.fn.log(expr) end + +--- Return the logarithm of Float {expr} to base 10 as a |Float|. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo log10(1000) +--- < 3.0 >vim +--- echo log10(0.01) +--- < -2.0 +--- +--- @param expr any +--- @return any +function vim.fn.log10(expr) end + +--- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. +--- When {expr1} is a |List|| or |Dictionary|, replace each +--- item in {expr1} with the result of evaluating {expr2}. +--- For a |Blob| each byte is replaced. +--- For a |String|, each character, including composing +--- characters, is replaced. +--- If the item type changes you may want to use |mapnew()| to +--- create a new List or Dictionary. +--- +--- {expr2} must be a |String| or |Funcref|. +--- +--- If {expr2} is a |String|, inside {expr2} |v:val| has the value +--- of the current item. For a |Dictionary| |v:key| has the key +--- of the current item and for a |List| |v:key| has the index of +--- the current item. For a |Blob| |v:key| has the index of the +--- current byte. For a |String| |v:key| has the index of the +--- current character. +--- Example: >vim +--- call map(mylist, '"> " .. v:val .. " <"') +--- <This puts "> " before and " <" after each item in "mylist". +--- +--- Note that {expr2} is the result of an expression and is then +--- used as an expression again. Often it is good to use a +--- |literal-string| to avoid having to double backslashes. You +--- still have to double ' quotes +--- +--- If {expr2} is a |Funcref| it is called with two arguments: +--- 1. The key or the index of the current item. +--- 2. the value of the current item. +--- The function must return the new value of the item. Example +--- that changes each value by "key-value": >vim +--- func KeyValue(key, val) +--- return a:key .. '-' .. a:val +--- endfunc +--- call map(myDict, function('KeyValue')) +--- <It is shorter when using a |lambda|: >vim +--- call map(myDict, {key, val -> key .. '-' .. val}) +--- <If you do not use "val" you can leave it out: >vim +--- call map(myDict, {key -> 'item: ' .. key}) +--- <If you do not use "key" you can use a short name: >vim +--- call map(myDict, {_, val -> 'item: ' .. val}) +--- < +--- The operation is done in-place for a |List| and |Dictionary|. +--- If you want it to remain unmodified make a copy first: >vim +--- let tlist = map(copy(mylist), ' v:val .. "\t"') +--- +--- <Returns {expr1}, the |List| or |Dictionary| that was filtered, +--- or a new |Blob| or |String|. +--- When an error is encountered while evaluating {expr2} no +--- further items in {expr1} are processed. +--- When {expr2} is a Funcref errors inside a function are ignored, +--- unless it was defined with the "abort" flag. +--- +--- @param expr1 any +--- @param expr2 any +--- @return any +function vim.fn.map(expr1, expr2) end + +--- When {dict} is omitted or zero: Return the rhs of mapping +--- {name} in mode {mode}. The returned String has special +--- characters translated like in the output of the ":map" command +--- listing. When {dict} is TRUE a dictionary is returned, see +--- below. To get a list of all mappings see |maplist()|. +--- +--- When there is no mapping for {name}, an empty String is +--- returned if {dict} is FALSE, otherwise returns an empty Dict. +--- When the mapping for {name} is empty, then "<Nop>" is +--- returned. +--- +--- The {name} can have special key names, like in the ":map" +--- command. +--- +--- {mode} can be one of these strings: +--- "n" Normal +--- "v" Visual (including Select) +--- "o" Operator-pending +--- "i" Insert +--- "c" Cmd-line +--- "s" Select +--- "x" Visual +--- "l" langmap |language-mapping| +--- "t" Terminal +--- "" Normal, Visual and Operator-pending +--- When {mode} is omitted, the modes for "" are used. +--- +--- When {abbr} is there and it is |TRUE| use abbreviations +--- instead of mappings. +--- +--- When {dict} is there and it is |TRUE| return a dictionary +--- containing all the information of the mapping with the +--- following items: *mapping-dict* +--- "lhs" The {lhs} of the mapping as it would be typed +--- "lhsraw" The {lhs} of the mapping as raw bytes +--- "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate +--- form, only present when it differs from "lhsraw" +--- "rhs" The {rhs} of the mapping as typed. +--- "silent" 1 for a |:map-silent| mapping, else 0. +--- "noremap" 1 if the {rhs} of the mapping is not remappable. +--- "script" 1 if mapping was defined with <script>. +--- "expr" 1 for an expression mapping (|:map-<expr>|). +--- "buffer" 1 for a buffer local mapping (|:map-local|). +--- "mode" Modes for which the mapping is defined. In +--- addition to the modes mentioned above, these +--- characters will be used: +--- " " Normal, Visual and Operator-pending +--- "!" Insert and Commandline mode +--- (|mapmode-ic|) +--- "sid" The script local ID, used for <sid> mappings +--- (|<SID>|). Negative for special contexts. +--- "scriptversion" The version of the script, always 1. +--- "lnum" The line number in "sid", zero if unknown. +--- "nowait" Do not wait for other, longer mappings. +--- (|:map-<nowait>|). +--- "abbr" True if this is an |abbreviation|. +--- "mode_bits" Nvim's internal binary representation of "mode". +--- |mapset()| ignores this; only "mode" is used. +--- See |maplist()| for usage examples. The values +--- are from src/nvim/state_defs.h and may change in +--- the future. +--- +--- The dictionary can be used to restore a mapping with +--- |mapset()|. +--- +--- The mappings local to the current buffer are checked first, +--- then the global mappings. +--- This function can be used to map a key even when it's already +--- mapped, and have it do the original mapping too. Sketch: >vim +--- exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n') +--- +--- @param name string +--- @param mode? string +--- @param abbr? boolean +--- @param dict? boolean +--- @return string|table<string,any> +function vim.fn.maparg(name, mode, abbr, dict) end + +--- Check if there is a mapping that matches with {name} in mode +--- {mode}. See |maparg()| for {mode} and special names in +--- {name}. +--- When {abbr} is there and it is non-zero use abbreviations +--- instead of mappings. +--- A match happens with a mapping that starts with {name} and +--- with a mapping which is equal to the start of {name}. +--- +--- matches mapping "a" "ab" "abc" ~ +--- mapcheck("a") yes yes yes +--- mapcheck("abc") yes yes yes +--- mapcheck("ax") yes no no +--- mapcheck("b") no no no +--- +--- The difference with maparg() is that mapcheck() finds a +--- mapping that matches with {name}, while maparg() only finds a +--- mapping for {name} exactly. +--- When there is no mapping that starts with {name}, an empty +--- String is returned. If there is one, the RHS of that mapping +--- is returned. If there are several mappings that start with +--- {name}, the RHS of one of them is returned. This will be +--- "<Nop>" if the RHS is empty. +--- The mappings local to the current buffer are checked first, +--- then the global mappings. +--- This function can be used to check if a mapping can be added +--- without being ambiguous. Example: >vim +--- if mapcheck("_vv") == "" +--- map _vv :set guifont=7x13<CR> +--- endif +--- <This avoids adding the "_vv" mapping when there already is a +--- mapping for "_v" or for "_vvv". +--- +--- @param name string +--- @param mode? string +--- @param abbr? any +--- @return any +function vim.fn.mapcheck(name, mode, abbr) end + +--- Returns a |List| of all mappings. Each List item is a |Dict|, +--- the same as what is returned by |maparg()|, see +--- |mapping-dict|. When {abbr} is there and it is |TRUE| use +--- abbreviations instead of mappings. +--- +--- Example to show all mappings with "MultiMatch" in rhs: >vim +--- echo maplist()->filter({_, m -> +--- \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0 +--- \ }) +--- <It can be tricky to find mappings for particular |:map-modes|. +--- |mapping-dict|'s "mode_bits" can simplify this. For example, +--- the mode_bits for Normal, Insert or Command-line modes are +--- 0x19. To find all the mappings available in those modes you +--- can do: >vim +--- let saved_maps = [] +--- for m in maplist() +--- if and(m.mode_bits, 0x19) != 0 +--- eval saved_maps->add(m) +--- endif +--- endfor +--- echo saved_maps->mapnew({_, m -> m.lhs}) +--- <The values of the mode_bits are defined in Nvim's +--- src/nvim/state_defs.h file and they can be discovered at +--- runtime using |:map-commands| and "maplist()". Example: >vim +--- omap xyzzy <Nop> +--- let op_bit = maplist()->filter( +--- \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits +--- ounmap xyzzy +--- echo printf("Operator-pending mode bit: 0x%x", op_bit) +--- +--- @return any +function vim.fn.maplist() end + +--- Like |map()| but instead of replacing items in {expr1} a new +--- List or Dictionary is created and returned. {expr1} remains +--- unchanged. Items can still be changed by {expr2}, if you +--- don't want that use |deepcopy()| first. +--- +--- @param expr1 any +--- @param expr2 any +--- @return any +function vim.fn.mapnew(expr1, expr2) end + +--- Restore a mapping from a dictionary, possibly returned by +--- |maparg()| or |maplist()|. A buffer mapping, when dict.buffer +--- is true, is set on the current buffer; it is up to the caller +--- to ensure that the intended buffer is the current buffer. This +--- feature allows copying mappings from one buffer to another. +--- The dict.mode value may restore a single mapping that covers +--- more than one mode, like with mode values of '!', ' ', "nox", +--- or 'v'. *E1276* +--- +--- In the first form, {mode} and {abbr} should be the same as +--- for the call to |maparg()|. *E460* +--- {mode} is used to define the mode in which the mapping is set, +--- not the "mode" entry in {dict}. +--- Example for saving and restoring a mapping: >vim +--- let save_map = maparg('K', 'n', 0, 1) +--- nnoremap K somethingelse +--- " ... +--- call mapset('n', 0, save_map) +--- <Note that if you are going to replace a map in several modes, +--- e.g. with `:map!`, you need to save/restore the mapping for +--- all of them, when they might differ. +--- +--- In the second form, with {dict} as the only argument, mode +--- and abbr are taken from the dict. +--- Example: >vim +--- let save_maps = maplist()->filter( +--- \ {_, m -> m.lhs == 'K'}) +--- nnoremap K somethingelse +--- cnoremap K somethingelse2 +--- " ... +--- unmap K +--- for d in save_maps +--- call mapset(d) +--- endfor +--- +--- @param mode string +--- @param abbr? any +--- @param dict? any +--- @return any +function vim.fn.mapset(mode, abbr, dict) end + +--- When {expr} is a |List| then this returns the index of the +--- first item where {pat} matches. Each item is used as a +--- String, |Lists| and |Dictionaries| are used as echoed. +--- +--- Otherwise, {expr} is used as a String. The result is a +--- Number, which gives the index (byte offset) in {expr} where +--- {pat} matches. +--- +--- A match at the first character or |List| item returns zero. +--- If there is no match -1 is returned. +--- +--- For getting submatches see |matchlist()|. +--- Example: >vim +--- echo match("testing", "ing") " results in 4 +--- echo match([1, 'x'], '\a') " results in 1 +--- <See |string-match| for how {pat} is used. +--- *strpbrk()* +--- Vim doesn't have a strpbrk() function. But you can do: >vim +--- let sepidx = match(line, '[.,;: \t]') +--- < *strcasestr()* +--- Vim doesn't have a strcasestr() function. But you can add +--- "\c" to the pattern to ignore case: >vim +--- let idx = match(haystack, '\cneedle') +--- < +--- If {start} is given, the search starts from byte index +--- {start} in a String or item {start} in a |List|. +--- The result, however, is still the index counted from the +--- first character/item. Example: >vim +--- echo match("testing", "ing", 2) +--- <result is again "4". >vim +--- echo match("testing", "ing", 4) +--- <result is again "4". >vim +--- echo match("testing", "t", 2) +--- <result is "3". +--- For a String, if {start} > 0 then it is like the string starts +--- {start} bytes later, thus "^" will match at {start}. Except +--- when {count} is given, then it's like matches before the +--- {start} byte are ignored (this is a bit complicated to keep it +--- backwards compatible). +--- For a String, if {start} < 0, it will be set to 0. For a list +--- the index is counted from the end. +--- If {start} is out of range ({start} > strlen({expr}) for a +--- String or {start} > len({expr}) for a |List|) -1 is returned. +--- +--- When {count} is given use the {count}th match. When a match +--- is found in a String the search for the next one starts one +--- character further. Thus this example results in 1: >vim +--- echo match("testing", "..", 0, 2) +--- <In a |List| the search continues in the next item. +--- Note that when {count} is added the way {start} works changes, +--- see above. +--- +--- See |pattern| for the patterns that are accepted. +--- The 'ignorecase' option is used to set the ignore-caseness of +--- the pattern. 'smartcase' is NOT used. The matching is always +--- done like 'magic' is set and 'cpoptions' is empty. +--- Note that a match at the start is preferred, thus when the +--- pattern is using "*" (any number of matches) it tends to find +--- zero matches at the start instead of a number of matches +--- further down in the text. +--- +--- @param expr any +--- @param pat any +--- @param start? any +--- @param count? any +--- @return any +function vim.fn.match(expr, pat, start, count) end + +--- Defines a pattern to be highlighted in the current window (a +--- "match"). It will be highlighted with {group}. Returns an +--- identification number (ID), which can be used to delete the +--- match using |matchdelete()|. The ID is bound to the window. +--- Matching is case sensitive and magic, unless case sensitivity +--- or magicness are explicitly overridden in {pattern}. The +--- 'magic', 'smartcase' and 'ignorecase' options are not used. +--- The "Conceal" value is special, it causes the match to be +--- concealed. +--- +--- The optional {priority} argument assigns a priority to the +--- match. A match with a high priority will have its +--- highlighting overrule that of a match with a lower priority. +--- A priority is specified as an integer (negative numbers are no +--- exception). If the {priority} argument is not specified, the +--- default priority is 10. The priority of 'hlsearch' is zero, +--- hence all matches with a priority greater than zero will +--- overrule it. Syntax highlighting (see 'syntax') is a separate +--- mechanism, and regardless of the chosen priority a match will +--- always overrule syntax highlighting. +--- +--- The optional {id} argument allows the request for a specific +--- match ID. If a specified ID is already taken, an error +--- message will appear and the match will not be added. An ID +--- is specified as a positive integer (zero excluded). IDs 1, 2 +--- and 3 are reserved for |:match|, |:2match| and |:3match|, +--- respectively. 3 is reserved for use by the |matchparen| +--- plugin. +--- If the {id} argument is not specified or -1, |matchadd()| +--- automatically chooses a free ID, which is at least 1000. +--- +--- The optional {dict} argument allows for further custom +--- values. Currently this is used to specify a match specific +--- conceal character that will be shown for |hl-Conceal| +--- highlighted matches. The dict can have the following members: +--- +--- conceal Special character to show instead of the +--- match (only for |hl-Conceal| highlighted +--- matches, see |:syn-cchar|) +--- window Instead of the current window use the +--- window with this number or window ID. +--- +--- The number of matches is not limited, as it is the case with +--- the |:match| commands. +--- +--- Returns -1 on error. +--- +--- Example: >vim +--- highlight MyGroup ctermbg=green guibg=green +--- let m = matchadd("MyGroup", "TODO") +--- <Deletion of the pattern: >vim +--- call matchdelete(m) +--- +--- <A list of matches defined by |matchadd()| and |:match| are +--- available from |getmatches()|. All matches can be deleted in +--- one operation by |clearmatches()|. +--- +--- @param group any +--- @param pattern any +--- @param priority? any +--- @param id? any +--- @param dict? any +--- @return any +function vim.fn.matchadd(group, pattern, priority, id, dict) end + +--- Same as |matchadd()|, but requires a list of positions {pos} +--- instead of a pattern. This command is faster than |matchadd()| +--- because it does not require to handle regular expressions and +--- sets buffer line boundaries to redraw screen. It is supposed +--- to be used when fast match additions and deletions are +--- required, for example to highlight matching parentheses. +--- *E5030* *E5031* +--- {pos} is a list of positions. Each position can be one of +--- these: +--- - A number. This whole line will be highlighted. The first +--- line has number 1. +--- - A list with one number, e.g., [23]. The whole line with this +--- number will be highlighted. +--- - A list with two numbers, e.g., [23, 11]. The first number is +--- the line number, the second one is the column number (first +--- column is 1, the value must correspond to the byte index as +--- |col()| would return). The character at this position will +--- be highlighted. +--- - A list with three numbers, e.g., [23, 11, 3]. As above, but +--- the third number gives the length of the highlight in bytes. +--- +--- Entries with zero and negative line numbers are silently +--- ignored, as well as entries with negative column numbers and +--- lengths. +--- +--- Returns -1 on error. +--- +--- Example: >vim +--- highlight MyGroup ctermbg=green guibg=green +--- let m = matchaddpos("MyGroup", [[23, 24], 34]) +--- <Deletion of the pattern: >vim +--- call matchdelete(m) +--- +--- <Matches added by |matchaddpos()| are returned by +--- |getmatches()|. +--- +--- @param group any +--- @param pos any +--- @param priority? any +--- @param id? any +--- @param dict? any +--- @return any +function vim.fn.matchaddpos(group, pos, priority, id, dict) end + +--- Selects the {nr} match item, as set with a |:match|, +--- |:2match| or |:3match| command. +--- Return a |List| with two elements: +--- The name of the highlight group used +--- The pattern used. +--- When {nr} is not 1, 2 or 3 returns an empty |List|. +--- When there is no match item set returns ['', '']. +--- This is useful to save and restore a |:match|. +--- Highlighting matches using the |:match| commands are limited +--- to three matches. |matchadd()| does not have this limitation. +--- +--- @param nr integer +--- @return any +function vim.fn.matcharg(nr) end + +--- Deletes a match with ID {id} previously defined by |matchadd()| +--- or one of the |:match| commands. Returns 0 if successful, +--- otherwise -1. See example for |matchadd()|. All matches can +--- be deleted in one operation by |clearmatches()|. +--- If {win} is specified, use the window with this number or +--- window ID instead of the current window. +--- +--- @param id any +--- @param win? any +--- @return any +function vim.fn.matchdelete(id, win) end + +--- Same as |match()|, but return the index of first character +--- after the match. Example: >vim +--- echo matchend("testing", "ing") +--- <results in "7". +--- *strspn()* *strcspn()* +--- Vim doesn't have a strspn() or strcspn() function, but you can +--- do it with matchend(): >vim +--- let span = matchend(line, '[a-zA-Z]') +--- let span = matchend(line, '[^a-zA-Z]') +--- <Except that -1 is returned when there are no matches. +--- +--- The {start}, if given, has the same meaning as for |match()|. >vim +--- echo matchend("testing", "ing", 2) +--- <results in "7". >vim +--- echo matchend("testing", "ing", 5) +--- <result is "-1". +--- When {expr} is a |List| the result is equal to |match()|. +--- +--- @param expr any +--- @param pat any +--- @param start? any +--- @param count? any +--- @return any +function vim.fn.matchend(expr, pat, start, count) end + +--- If {list} is a list of strings, then returns a |List| with all +--- the strings in {list} that fuzzy match {str}. The strings in +--- the returned list are sorted based on the matching score. +--- +--- The optional {dict} argument always supports the following +--- items: +--- matchseq When this item is present return only matches +--- that contain the characters in {str} in the +--- given sequence. +--- limit Maximum number of matches in {list} to be +--- returned. Zero means no limit. +--- +--- If {list} is a list of dictionaries, then the optional {dict} +--- argument supports the following additional items: +--- key Key of the item which is fuzzy matched against +--- {str}. The value of this item should be a +--- string. +--- text_cb |Funcref| that will be called for every item +--- in {list} to get the text for fuzzy matching. +--- This should accept a dictionary item as the +--- argument and return the text for that item to +--- use for fuzzy matching. +--- +--- {str} is treated as a literal string and regular expression +--- matching is NOT supported. The maximum supported {str} length +--- is 256. +--- +--- When {str} has multiple words each separated by white space, +--- then the list of strings that have all the words is returned. +--- +--- If there are no matching strings or there is an error, then an +--- empty list is returned. If length of {str} is greater than +--- 256, then returns an empty list. +--- +--- When {limit} is given, matchfuzzy() will find up to this +--- number of matches in {list} and return them in sorted order. +--- +--- Refer to |fuzzy-matching| for more information about fuzzy +--- matching strings. +--- +--- Example: >vim +--- echo matchfuzzy(["clay", "crow"], "cay") +--- <results in ["clay"]. >vim +--- echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl") +--- <results in a list of buffer names fuzzy matching "ndl". >vim +--- echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'}) +--- <results in a list of buffer information dicts with buffer +--- names fuzzy matching "ndl". >vim +--- echo getbufinfo()->matchfuzzy("spl", +--- \ {'text_cb' : {v -> v.name}}) +--- <results in a list of buffer information dicts with buffer +--- names fuzzy matching "spl". >vim +--- echo v:oldfiles->matchfuzzy("test") +--- <results in a list of file names fuzzy matching "test". >vim +--- let l = readfile("buffer.c")->matchfuzzy("str") +--- <results in a list of lines in "buffer.c" fuzzy matching "str". >vim +--- echo ['one two', 'two one']->matchfuzzy('two one') +--- <results in `['two one', 'one two']` . >vim +--- echo ['one two', 'two one']->matchfuzzy('two one', +--- \ {'matchseq': 1}) +--- <results in `['two one']`. +--- +--- @param list any +--- @param str any +--- @param dict? any +--- @return any +function vim.fn.matchfuzzy(list, str, dict) end + +--- Same as |matchfuzzy()|, but returns the list of matched +--- strings, the list of character positions where characters +--- in {str} matches and a list of matching scores. You can +--- use |byteidx()| to convert a character position to a byte +--- position. +--- +--- If {str} matches multiple times in a string, then only the +--- positions for the best match is returned. +--- +--- If there are no matching strings or there is an error, then a +--- list with three empty list items is returned. +--- +--- Example: >vim +--- echo matchfuzzypos(['testing'], 'tsg') +--- <results in [["testing"], [[0, 2, 6]], [99]] >vim +--- echo matchfuzzypos(['clay', 'lacy'], 'la') +--- <results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim +--- echo [{'text': 'hello', 'id' : 10}] +--- \ ->matchfuzzypos('ll', {'key' : 'text'}) +--- <results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]` +--- +--- @param list any +--- @param str any +--- @param dict? any +--- @return any +function vim.fn.matchfuzzypos(list, str, dict) end + +--- Same as |match()|, but return a |List|. The first item in the +--- list is the matched string, same as what matchstr() would +--- return. Following items are submatches, like "\1", "\2", etc. +--- in |:substitute|. When an optional submatch didn't match an +--- empty string is used. Example: >vim +--- echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)') +--- <Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', ''] +--- When there is no match an empty list is returned. +--- +--- You can pass in a List, but that is not very useful. +--- +--- @param expr any +--- @param pat any +--- @param start? any +--- @param count? any +--- @return any +function vim.fn.matchlist(expr, pat, start, count) end + +--- Same as |match()|, but return the matched string. Example: >vim +--- echo matchstr("testing", "ing") +--- <results in "ing". +--- When there is no match "" is returned. +--- The {start}, if given, has the same meaning as for |match()|. >vim +--- echo matchstr("testing", "ing", 2) +--- <results in "ing". >vim +--- echo matchstr("testing", "ing", 5) +--- <result is "". +--- When {expr} is a |List| then the matching item is returned. +--- The type isn't changed, it's not necessarily a String. +--- +--- @param expr any +--- @param pat any +--- @param start? any +--- @param count? any +--- @return any +function vim.fn.matchstr(expr, pat, start, count) end + +--- Same as |matchstr()|, but return the matched string, the start +--- position and the end position of the match. Example: >vim +--- echo matchstrpos("testing", "ing") +--- <results in ["ing", 4, 7]. +--- When there is no match ["", -1, -1] is returned. +--- The {start}, if given, has the same meaning as for |match()|. >vim +--- echo matchstrpos("testing", "ing", 2) +--- <results in ["ing", 4, 7]. >vim +--- echo matchstrpos("testing", "ing", 5) +--- <result is ["", -1, -1]. +--- When {expr} is a |List| then the matching item, the index +--- of first item where {pat} matches, the start position and the +--- end position of the match are returned. >vim +--- echo matchstrpos([1, '__x'], '\a') +--- <result is ["x", 1, 2, 3]. +--- The type isn't changed, it's not necessarily a String. +--- +--- @param expr any +--- @param pat any +--- @param start? any +--- @param count? any +--- @return any +function vim.fn.matchstrpos(expr, pat, start, count) end + +--- Return the maximum value of all items in {expr}. Example: >vim +--- echo max([apples, pears, oranges]) +--- +--- <{expr} can be a |List| or a |Dictionary|. For a Dictionary, +--- it returns the maximum of all values in the Dictionary. +--- If {expr} is neither a List nor a Dictionary, or one of the +--- items in {expr} cannot be used as a Number this results in +--- an error. An empty |List| or |Dictionary| results in zero. +--- +--- @param expr any +--- @return any +function vim.fn.max(expr) end + +--- Returns a |List| of |Dictionaries| describing |menus| (defined +--- by |:menu|, |:amenu|, …), including |hidden-menus|. +--- +--- {path} matches a menu by name, or all menus if {path} is an +--- empty string. Example: >vim +--- echo menu_get('File','') +--- echo menu_get('') +--- < +--- {modes} is a string of zero or more modes (see |maparg()| or +--- |creating-menus| for the list of modes). "a" means "all". +--- +--- Example: >vim +--- nnoremenu &Test.Test inormal +--- inoremenu Test.Test insert +--- vnoremenu Test.Test x +--- echo menu_get("") +--- +--- <returns something like this: > +--- +--- [ { +--- "hidden": 0, +--- "name": "Test", +--- "priority": 500, +--- "shortcut": 84, +--- "submenus": [ { +--- "hidden": 0, +--- "mappings": { +--- i": { +--- "enabled": 1, +--- "noremap": 1, +--- "rhs": "insert", +--- "sid": 1, +--- "silent": 0 +--- }, +--- n": { ... }, +--- s": { ... }, +--- v": { ... } +--- }, +--- "name": "Test", +--- "priority": 500, +--- "shortcut": 0 +--- } ] +--- } ] +--- < +--- +--- @param path string +--- @param modes? any +--- @return any +function vim.fn.menu_get(path, modes) end + +--- Return information about the specified menu {name} in +--- mode {mode}. The menu name should be specified without the +--- shortcut character ('&'). If {name} is "", then the top-level +--- menu names are returned. +--- +--- {mode} can be one of these strings: +--- "n" Normal +--- "v" Visual (including Select) +--- "o" Operator-pending +--- "i" Insert +--- "c" Cmd-line +--- "s" Select +--- "x" Visual +--- "t" Terminal-Job +--- "" Normal, Visual and Operator-pending +--- "!" Insert and Cmd-line +--- When {mode} is omitted, the modes for "" are used. +--- +--- Returns a |Dictionary| containing the following items: +--- accel menu item accelerator text |menu-text| +--- display display name (name without '&') +--- enabled v:true if this menu item is enabled +--- Refer to |:menu-enable| +--- icon name of the icon file (for toolbar) +--- |toolbar-icon| +--- iconidx index of a built-in icon +--- modes modes for which the menu is defined. In +--- addition to the modes mentioned above, these +--- characters will be used: +--- " " Normal, Visual and Operator-pending +--- name menu item name. +--- noremenu v:true if the {rhs} of the menu item is not +--- remappable else v:false. +--- priority menu order priority |menu-priority| +--- rhs right-hand-side of the menu item. The returned +--- string has special characters translated like +--- in the output of the ":menu" command listing. +--- When the {rhs} of a menu item is empty, then +--- "<Nop>" is returned. +--- script v:true if script-local remapping of {rhs} is +--- allowed else v:false. See |:menu-script|. +--- shortcut shortcut key (character after '&' in +--- the menu name) |menu-shortcut| +--- silent v:true if the menu item is created +--- with <silent> argument |:menu-silent| +--- submenus |List| containing the names of +--- all the submenus. Present only if the menu +--- item has submenus. +--- +--- Returns an empty dictionary if the menu item is not found. +--- +--- Examples: >vim +--- echo menu_info('Edit.Cut') +--- echo menu_info('File.Save', 'n') +--- +--- " Display the entire menu hierarchy in a buffer +--- func ShowMenu(name, pfx) +--- let m = menu_info(a:name) +--- call append(line('$'), a:pfx .. m.display) +--- for child in m->get('submenus', []) +--- call ShowMenu(a:name .. '.' .. escape(child, '.'), +--- \ a:pfx .. ' ') +--- endfor +--- endfunc +--- new +--- for topmenu in menu_info('').submenus +--- call ShowMenu(topmenu, '') +--- endfor +--- < +--- +--- @param name string +--- @param mode? string +--- @return any +function vim.fn.menu_info(name, mode) end + +--- Return the minimum value of all items in {expr}. Example: >vim +--- echo min([apples, pears, oranges]) +--- +--- <{expr} can be a |List| or a |Dictionary|. For a Dictionary, +--- it returns the minimum of all values in the Dictionary. +--- If {expr} is neither a List nor a Dictionary, or one of the +--- items in {expr} cannot be used as a Number this results in +--- an error. An empty |List| or |Dictionary| results in zero. +--- +--- @param expr any +--- @return any +function vim.fn.min(expr) end + +--- Create directory {name}. +--- +--- When {flags} is present it must be a string. An empty string +--- has no effect. +--- +--- If {flags} contains "p" then intermediate directories are +--- created as necessary. +--- +--- If {flags} contains "D" then {name} is deleted at the end of +--- the current function, as with: >vim +--- defer delete({name}, 'd') +--- < +--- If {flags} contains "R" then {name} is deleted recursively at +--- the end of the current function, as with: >vim +--- defer delete({name}, 'rf') +--- <Note that when {name} has more than one part and "p" is used +--- some directories may already exist. Only the first one that +--- is created and what it contains is scheduled to be deleted. +--- E.g. when using: >vim +--- call mkdir('subdir/tmp/autoload', 'pR') +--- <and "subdir" already exists then "subdir/tmp" will be +--- scheduled for deletion, like with: >vim +--- defer delete('subdir/tmp', 'rf') +--- < +--- If {prot} is given it is used to set the protection bits of +--- the new directory. The default is 0o755 (rwxr-xr-x: r/w for +--- the user, readable for others). Use 0o700 to make it +--- unreadable for others. +--- +--- {prot} is applied for all parts of {name}. Thus if you create +--- /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim +--- call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700) +--- +--- <This function is not available in the |sandbox|. +--- +--- If you try to create an existing directory with {flags} set to +--- "p" mkdir() will silently exit. +--- +--- The function result is a Number, which is TRUE if the call was +--- successful or FALSE if the directory creation failed or partly +--- failed. +--- +--- @param name string +--- @param flags? string +--- @param prot? any +--- @return any +function vim.fn.mkdir(name, flags, prot) end + +--- Return a string that indicates the current mode. +--- If [expr] is supplied and it evaluates to a non-zero Number or +--- a non-empty String (|non-zero-arg|), then the full mode is +--- returned, otherwise only the first letter is returned. +--- Also see |state()|. +--- +--- n Normal +--- no Operator-pending +--- nov Operator-pending (forced charwise |o_v|) +--- noV Operator-pending (forced linewise |o_V|) +--- noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|) +--- CTRL-V is one character +--- niI Normal using |i_CTRL-O| in |Insert-mode| +--- niR Normal using |i_CTRL-O| in |Replace-mode| +--- niV Normal using |i_CTRL-O| in |Virtual-Replace-mode| +--- nt Normal in |terminal-emulator| (insert goes to +--- Terminal mode) +--- ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode| +--- v Visual by character +--- vs Visual by character using |v_CTRL-O| in Select mode +--- V Visual by line +--- Vs Visual by line using |v_CTRL-O| in Select mode +--- CTRL-V Visual blockwise +--- CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode +--- s Select by character +--- S Select by line +--- CTRL-S Select blockwise +--- i Insert +--- ic Insert mode completion |compl-generic| +--- ix Insert mode |i_CTRL-X| completion +--- R Replace |R| +--- Rc Replace mode completion |compl-generic| +--- Rx Replace mode |i_CTRL-X| completion +--- Rv Virtual Replace |gR| +--- Rvc Virtual Replace mode completion |compl-generic| +--- Rvx Virtual Replace mode |i_CTRL-X| completion +--- c Command-line editing +--- cr Command-line editing overstrike mode |c_<Insert>| +--- cv Vim Ex mode |gQ| +--- cvr Vim Ex mode while in overstrike mode |c_<Insert>| +--- r Hit-enter prompt +--- rm The -- more -- prompt +--- r? A |:confirm| query of some sort +--- ! Shell or external command is executing +--- t Terminal mode: keys go to the job +--- +--- This is useful in the 'statusline' option or RPC calls. In +--- most other places it always returns "c" or "n". +--- Note that in the future more modes and more specific modes may +--- be added. It's better not to compare the whole string but only +--- the leading character(s). +--- Also see |visualmode()|. +--- +--- @return any +function vim.fn.mode() end + +--- Convert a list of Vimscript objects to msgpack. Returned value is a +--- |readfile()|-style list. When {type} contains "B", a |Blob| is +--- returned instead. Example: >vim +--- call writefile(msgpackdump([{}]), 'fname.mpack', 'b') +--- <or, using a |Blob|: >vim +--- call writefile(msgpackdump([{}], 'B'), 'fname.mpack') +--- < +--- This will write the single 0x80 byte to a `fname.mpack` file +--- (dictionary with zero items is represented by 0x80 byte in +--- messagepack). +--- +--- Limitations: *E5004* *E5005* +--- 1. |Funcref|s cannot be dumped. +--- 2. Containers that reference themselves cannot be dumped. +--- 3. Dictionary keys are always dumped as STR strings. +--- 4. Other strings and |Blob|s are always dumped as BIN strings. +--- 5. Points 3. and 4. do not apply to |msgpack-special-dict|s. +--- +--- @param list any +--- @param type? any +--- @return any +function vim.fn.msgpackdump(list, type) end + +--- Convert a |readfile()|-style list or a |Blob| to a list of +--- Vimscript objects. +--- Example: >vim +--- let fname = expand('~/.config/nvim/shada/main.shada') +--- let mpack = readfile(fname, 'b') +--- let shada_objects = msgpackparse(mpack) +--- <This will read ~/.config/nvim/shada/main.shada file to +--- `shada_objects` list. +--- +--- Limitations: +--- 1. Mapping ordering is not preserved unless messagepack +--- mapping is dumped using generic mapping +--- (|msgpack-special-map|). +--- 2. Since the parser aims to preserve all data untouched +--- (except for 1.) some strings are parsed to +--- |msgpack-special-dict| format which is not convenient to +--- use. +--- *msgpack-special-dict* +--- Some messagepack strings may be parsed to special +--- dictionaries. Special dictionaries are dictionaries which +--- +--- 1. Contain exactly two keys: `_TYPE` and `_VAL`. +--- 2. `_TYPE` key is one of the types found in |v:msgpack_types| +--- variable. +--- 3. Value for `_VAL` has the following format (Key column +--- contains name of the key from |v:msgpack_types|): +--- +--- Key Value ~ +--- nil Zero, ignored when dumping. Not returned by +--- |msgpackparse()| since |v:null| was introduced. +--- boolean One or zero. When dumping it is only checked that +--- value is a |Number|. Not returned by |msgpackparse()| +--- since |v:true| and |v:false| were introduced. +--- integer |List| with four numbers: sign (-1 or 1), highest two +--- bits, number with bits from 62nd to 31st, lowest 31 +--- bits. I.e. to get actual number one will need to use +--- code like > +--- _VAL[0] * ((_VAL[1] << 62) +--- & (_VAL[2] << 31) +--- & _VAL[3]) +--- < Special dictionary with this type will appear in +--- |msgpackparse()| output under one of the following +--- circumstances: +--- 1. |Number| is 32-bit and value is either above +--- INT32_MAX or below INT32_MIN. +--- 2. |Number| is 64-bit and value is above INT64_MAX. It +--- cannot possibly be below INT64_MIN because msgpack +--- C parser does not support such values. +--- float |Float|. This value cannot possibly appear in +--- |msgpackparse()| output. +--- string |readfile()|-style list of strings. This value will +--- appear in |msgpackparse()| output if string contains +--- zero byte or if string is a mapping key and mapping is +--- being represented as special dictionary for other +--- reasons. +--- binary |String|, or |Blob| if binary string contains zero +--- byte. This value cannot appear in |msgpackparse()| +--- output since blobs were introduced. +--- array |List|. This value cannot appear in |msgpackparse()| +--- output. +--- *msgpack-special-map* +--- map |List| of |List|s with two items (key and value) each. +--- This value will appear in |msgpackparse()| output if +--- parsed mapping contains one of the following keys: +--- 1. Any key that is not a string (including keys which +--- are binary strings). +--- 2. String with NUL byte inside. +--- 3. Duplicate key. +--- 4. Empty key. +--- ext |List| with two values: first is a signed integer +--- representing extension type. Second is +--- |readfile()|-style list of strings. +--- +--- @param data any +--- @return any +function vim.fn.msgpackparse(data) end + +--- Return the line number of the first line at or below {lnum} +--- that is not blank. Example: >vim +--- if getline(nextnonblank(1)) =~ "Java" | endif +--- <When {lnum} is invalid or there is no non-blank line at or +--- below it, zero is returned. +--- {lnum} is used like with |getline()|. +--- See also |prevnonblank()|. +--- +--- @param lnum integer +--- @return any +function vim.fn.nextnonblank(lnum) end + +--- Return a string with a single character, which has the number +--- value {expr}. Examples: >vim +--- echo nr2char(64) " returns '\@' +--- echo nr2char(32) " returns ' ' +--- <Example for "utf-8": >vim +--- echo nr2char(300) " returns I with bow character +--- < +--- UTF-8 encoding is always used, {utf8} option has no effect, +--- and exists only for backwards-compatibility. +--- Note that a NUL character in the file is specified with +--- nr2char(10), because NULs are represented with newline +--- characters. nr2char(0) is a real NUL and terminates the +--- string, thus results in an empty string. +--- +--- @param expr any +--- @param utf8? any +--- @return any +function vim.fn.nr2char(expr, utf8) end + +--- Bitwise OR on the two arguments. The arguments are converted +--- to a number. A List, Dict or Float argument causes an error. +--- Also see `and()` and `xor()`. +--- Example: >vim +--- let bits = or(bits, 0x80) +--- +--- <Rationale: The reason this is a function and not using the "|" +--- character like many languages, is that Vi has always used "|" +--- to separate commands. In many places it would not be clear if +--- "|" is an operator or a command separator. +--- +--- @param expr any +--- @param expr1 any +--- @return any +vim.fn['or'] = function(expr, expr1) end + +--- Shorten directory names in the path {path} and return the +--- result. The tail, the file name, is kept as-is. The other +--- components in the path are reduced to {len} letters in length. +--- If {len} is omitted or smaller than 1 then 1 is used (single +--- letters). Leading '~' and '.' characters are kept. Examples: >vim +--- echo pathshorten('~/.config/nvim/autoload/file1.vim') +--- < ~/.c/n/a/file1.vim ~ +--- >vim +--- echo pathshorten('~/.config/nvim/autoload/file2.vim', 2) +--- < ~/.co/nv/au/file2.vim ~ +--- It doesn't matter if the path exists or not. +--- Returns an empty string on error. +--- +--- @param path string +--- @param len? any +--- @return any +function vim.fn.pathshorten(path, len) end + +--- Evaluate |perl| expression {expr} and return its result +--- converted to Vim data structures. +--- Numbers and strings are returned as they are (strings are +--- copied though). +--- Lists are represented as Vim |List| type. +--- Dictionaries are represented as Vim |Dictionary| type, +--- non-string keys result in error. +--- +--- Note: If you want an array or hash, {expr} must return a +--- reference to it. +--- Example: >vim +--- echo perleval('[1 .. 4]') +--- < [1, 2, 3, 4] +--- +--- @param expr any +--- @return any +function vim.fn.perleval(expr) end + +--- Return the power of {x} to the exponent {y} as a |Float|. +--- {x} and {y} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {x} or {y} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo pow(3, 3) +--- < 27.0 >vim +--- echo pow(2, 16) +--- < 65536.0 >vim +--- echo pow(32, 0.20) +--- < 2.0 +--- +--- @param x any +--- @param y any +--- @return any +function vim.fn.pow(x, y) end + +--- Return the line number of the first line at or above {lnum} +--- that is not blank. Example: >vim +--- let ind = indent(prevnonblank(v:lnum - 1)) +--- <When {lnum} is invalid or there is no non-blank line at or +--- above it, zero is returned. +--- {lnum} is used like with |getline()|. +--- Also see |nextnonblank()|. +--- +--- @param lnum integer +--- @return any +function vim.fn.prevnonblank(lnum) end + +--- Return a String with {fmt}, where "%" items are replaced by +--- the formatted form of their respective arguments. Example: >vim +--- echo printf("%4d: E%d %.30s", lnum, errno, msg) +--- <May result in: +--- " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~ +--- +--- When used as a |method| the base is passed as the second +--- argument: >vim +--- Compute()->printf("result: %d") +--- < +--- You can use `call()` to pass the items as a list. +--- +--- Often used items are: +--- %s string +--- %6S string right-aligned in 6 display cells +--- %6s string right-aligned in 6 bytes +--- %.9s string truncated to 9 bytes +--- %c single byte +--- %d decimal number +--- %5d decimal number padded with spaces to 5 characters +--- %b binary number +--- %08b binary number padded with zeros to at least 8 characters +--- %B binary number using upper case letters +--- %x hex number +--- %04x hex number padded with zeros to at least 4 characters +--- %X hex number using upper case letters +--- %o octal number +--- %f floating point number as 12.23, inf, -inf or nan +--- %F floating point number as 12.23, INF, -INF or NAN +--- %e floating point number as 1.23e3, inf, -inf or nan +--- %E floating point number as 1.23E3, INF, -INF or NAN +--- %g floating point number, as %f or %e depending on value +--- %G floating point number, as %F or %E depending on value +--- %% the % character itself +--- %p representation of the pointer to the container +--- +--- Conversion specifications start with '%' and end with the +--- conversion type. All other characters are copied unchanged to +--- the result. +--- +--- The "%" starts a conversion specification. The following +--- arguments appear in sequence: +--- +--- % [pos-argument] [flags] [field-width] [.precision] type +--- +--- pos-argument +--- At most one positional argument specifier. These +--- take the form {n$}, where n is >= 1. +--- +--- flags +--- Zero or more of the following flags: +--- +--- # The value should be converted to an "alternate +--- form". For c, d, and s conversions, this option +--- has no effect. For o conversions, the precision +--- of the number is increased to force the first +--- character of the output string to a zero (except +--- if a zero value is printed with an explicit +--- precision of zero). +--- For x and X conversions, a non-zero result has +--- the string "0x" (or "0X" for X conversions) +--- prepended to it. +--- +--- 0 (zero) Zero padding. For all conversions the converted +--- value is padded on the left with zeros rather +--- than blanks. If a precision is given with a +--- numeric conversion (d, o, x, and X), the 0 flag +--- is ignored. +--- +--- - A negative field width flag; the converted value +--- is to be left adjusted on the field boundary. +--- The converted value is padded on the right with +--- blanks, rather than on the left with blanks or +--- zeros. A - overrides a 0 if both are given. +--- +--- ' ' (space) A blank should be left before a positive +--- number produced by a signed conversion (d). +--- +--- + A sign must always be placed before a number +--- produced by a signed conversion. A + overrides +--- a space if both are used. +--- +--- field-width +--- An optional decimal digit string specifying a minimum +--- field width. If the converted value has fewer bytes +--- than the field width, it will be padded with spaces on +--- the left (or right, if the left-adjustment flag has +--- been given) to fill out the field width. For the S +--- conversion the count is in cells. +--- +--- .precision +--- An optional precision, in the form of a period '.' +--- followed by an optional digit string. If the digit +--- string is omitted, the precision is taken as zero. +--- This gives the minimum number of digits to appear for +--- d, o, x, and X conversions, the maximum number of +--- bytes to be printed from a string for s conversions, +--- or the maximum number of cells to be printed from a +--- string for S conversions. +--- For floating point it is the number of digits after +--- the decimal point. +--- +--- type +--- A character that specifies the type of conversion to +--- be applied, see below. +--- +--- A field width or precision, or both, may be indicated by an +--- asterisk "*" instead of a digit string. In this case, a +--- Number argument supplies the field width or precision. A +--- negative field width is treated as a left adjustment flag +--- followed by a positive field width; a negative precision is +--- treated as though it were missing. Example: >vim +--- echo printf("%d: %.*s", nr, width, line) +--- <This limits the length of the text used from "line" to +--- "width" bytes. +--- +--- If the argument to be formatted is specified using a posional +--- argument specifier, and a '*' is used to indicate that a +--- number argument is to be used to specify the width or +--- precision, the argument(s) to be used must also be specified +--- using a {n$} positional argument specifier. See |printf-$|. +--- +--- The conversion specifiers and their meanings are: +--- +--- *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X* +--- dbBoxX The Number argument is converted to signed decimal (d), +--- unsigned binary (b and B), unsigned octal (o), or +--- unsigned hexadecimal (x and X) notation. The letters +--- "abcdef" are used for x conversions; the letters +--- "ABCDEF" are used for X conversions. The precision, if +--- any, gives the minimum number of digits that must +--- appear; if the converted value requires fewer digits, it +--- is padded on the left with zeros. In no case does a +--- non-existent or small field width cause truncation of a +--- numeric field; if the result of a conversion is wider +--- than the field width, the field is expanded to contain +--- the conversion result. +--- The 'h' modifier indicates the argument is 16 bits. +--- The 'l' modifier indicates the argument is a long +--- integer. The size will be 32 bits or 64 bits +--- depending on your platform. +--- The "ll" modifier indicates the argument is 64 bits. +--- The b and B conversion specifiers never take a width +--- modifier and always assume their argument is a 64 bit +--- integer. +--- Generally, these modifiers are not useful. They are +--- ignored when type is known from the argument. +--- +--- i alias for d +--- D alias for ld +--- U alias for lu +--- O alias for lo +--- +--- *printf-c* +--- c The Number argument is converted to a byte, and the +--- resulting character is written. +--- +--- *printf-s* +--- s The text of the String argument is used. If a +--- precision is specified, no more bytes than the number +--- specified are used. +--- If the argument is not a String type, it is +--- automatically converted to text with the same format +--- as ":echo". +--- *printf-S* +--- S The text of the String argument is used. If a +--- precision is specified, no more display cells than the +--- number specified are used. +--- +--- *printf-f* *E807* +--- f F The Float argument is converted into a string of the +--- form 123.456. The precision specifies the number of +--- digits after the decimal point. When the precision is +--- zero the decimal point is omitted. When the precision +--- is not specified 6 is used. A really big number +--- (out of range or dividing by zero) results in "inf" +--- or "-inf" with %f (INF or -INF with %F). +--- "0.0 / 0.0" results in "nan" with %f (NAN with %F). +--- Example: >vim +--- echo printf("%.2f", 12.115) +--- < 12.12 +--- Note that roundoff depends on the system libraries. +--- Use |round()| when in doubt. +--- +--- *printf-e* *printf-E* +--- e E The Float argument is converted into a string of the +--- form 1.234e+03 or 1.234E+03 when using 'E'. The +--- precision specifies the number of digits after the +--- decimal point, like with 'f'. +--- +--- *printf-g* *printf-G* +--- g G The Float argument is converted like with 'f' if the +--- value is between 0.001 (inclusive) and 10000000.0 +--- (exclusive). Otherwise 'e' is used for 'g' and 'E' +--- for 'G'. When no precision is specified superfluous +--- zeroes and '+' signs are removed, except for the zero +--- immediately after the decimal point. Thus 10000000.0 +--- results in 1.0e7. +--- +--- *printf-%* +--- % A '%' is written. No argument is converted. The +--- complete conversion specification is "%%". +--- +--- When a Number argument is expected a String argument is also +--- accepted and automatically converted. +--- When a Float or String argument is expected a Number argument +--- is also accepted and automatically converted. +--- Any other argument type results in an error message. +--- +--- *E766* *E767* +--- The number of {exprN} arguments must exactly match the number +--- of "%" items. If there are not sufficient or too many +--- arguments an error is given. Up to 18 arguments can be used. +--- +--- *printf-$* +--- In certain languages, error and informative messages are +--- more readable when the order of words is different from the +--- corresponding message in English. To accommodate translations +--- having a different word order, positional arguments may be +--- used to indicate this. For instance: >vim +--- +--- #, c-format +--- msgid "%s returning %s" +--- msgstr "waarde %2$s komt terug van %1$s" +--- < +--- In this example, the sentence has its 2 string arguments +--- reversed in the output. >vim +--- +--- echo printf( +--- "In The Netherlands, vim's creator's name is: %1$s %2$s", +--- "Bram", "Moolenaar") +--- < In The Netherlands, vim's creator's name is: Bram Moolenaar >vim +--- +--- echo printf( +--- "In Belgium, vim's creator's name is: %2$s %1$s", +--- "Bram", "Moolenaar") +--- < In Belgium, vim's creator's name is: Moolenaar Bram +--- +--- Width (and precision) can be specified using the '*' specifier. +--- In this case, you must specify the field width position in the +--- argument list. >vim +--- +--- echo printf("%1$*2$.*3$d", 1, 2, 3) +--- < 001 >vim +--- echo printf("%2$*3$.*1$d", 1, 2, 3) +--- < 2 >vim +--- echo printf("%3$*1$.*2$d", 1, 2, 3) +--- < 03 >vim +--- echo printf("%1$*2$.*3$g", 1.4142, 2, 3) +--- < 1.414 +--- +--- You can mix specifying the width and/or precision directly +--- and via positional arguments: >vim +--- +--- echo printf("%1$4.*2$f", 1.4142135, 6) +--- < 1.414214 >vim +--- echo printf("%1$*2$.4f", 1.4142135, 6) +--- < 1.4142 >vim +--- echo printf("%1$*2$.*3$f", 1.4142135, 6, 2) +--- < 1.41 +--- +--- *E1500* +--- You cannot mix positional and non-positional arguments: >vim +--- echo printf("%s%1$s", "One", "Two") +--- < E1500: Cannot mix positional and non-positional arguments: +--- %s%1$s +--- +--- *E1501* +--- You cannot skip a positional argument in a format string: >vim +--- echo printf("%3$s%1$s", "One", "Two", "Three") +--- < E1501: format argument 2 unused in $-style format: +--- %3$s%1$s +--- +--- *E1502* +--- You can re-use a [field-width] (or [precision]) argument: >vim +--- echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2) +--- < 1 at width 2 is: 01 +--- +--- However, you can't use it as a different type: >vim +--- echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2) +--- < E1502: Positional argument 2 used as field width reused as +--- different type: long int/int +--- +--- *E1503* +--- When a positional argument is used, but not the correct number +--- or arguments is given, an error is raised: >vim +--- echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2) +--- < E1503: Positional argument 3 out of bounds: %1$d at width +--- %2$d is: %01$*2$.*3$d +--- +--- Only the first error is reported: >vim +--- echo printf("%01$*2$.*3$d %4$d", 1, 2) +--- < E1503: Positional argument 3 out of bounds: %01$*2$.*3$d +--- %4$d +--- +--- *E1504* +--- A positional argument can be used more than once: >vim +--- echo printf("%1$s %2$s %1$s", "One", "Two") +--- < One Two One +--- +--- However, you can't use a different type the second time: >vim +--- echo printf("%1$s %2$s %1$d", "One", "Two") +--- < E1504: Positional argument 1 type used inconsistently: +--- int/string +--- +--- *E1505* +--- Various other errors that lead to a format string being +--- wrongly formatted lead to: >vim +--- echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2) +--- < E1505: Invalid format specifier: %1$d at width %2$d is: +--- %01$*2$.3$d +--- +--- *E1507* +--- This internal error indicates that the logic to parse a +--- positional format argument ran into a problem that couldn't be +--- otherwise reported. Please file a bug against Vim if you run +--- into this, copying the exact format string and parameters that +--- were used. +--- +--- @param fmt any +--- @param expr1? any +--- @return any +function vim.fn.printf(fmt, expr1) end + +--- Returns the effective prompt text for buffer {buf}. {buf} can +--- be a buffer name or number. See |prompt-buffer|. +--- +--- If the buffer doesn't exist or isn't a prompt buffer, an empty +--- string is returned. +--- +--- @param buf any +--- @return any +function vim.fn.prompt_getprompt(buf) end + +--- Set prompt callback for buffer {buf} to {expr}. When {expr} +--- is an empty string the callback is removed. This has only +--- effect if {buf} has 'buftype' set to "prompt". +--- +--- The callback is invoked when pressing Enter. The current +--- buffer will always be the prompt buffer. A new line for a +--- prompt is added before invoking the callback, thus the prompt +--- for which the callback was invoked will be in the last but one +--- line. +--- If the callback wants to add text to the buffer, it must +--- insert it above the last line, since that is where the current +--- prompt is. This can also be done asynchronously. +--- The callback is invoked with one argument, which is the text +--- that was entered at the prompt. This can be an empty string +--- if the user only typed Enter. +--- Example: >vim +--- func s:TextEntered(text) +--- if a:text == 'exit' || a:text == 'quit' +--- stopinsert +--- " Reset 'modified' to allow the buffer to be closed. +--- " We assume there is nothing useful to be saved. +--- set nomodified +--- close +--- else +--- " Do something useful with "a:text". In this example +--- " we just repeat it. +--- call append(line('$') - 1, 'Entered: "' .. a:text .. '"') +--- endif +--- endfunc +--- call prompt_setcallback(bufnr(), function('s:TextEntered')) +--- +--- @param buf any +--- @param expr any +--- @return any +function vim.fn.prompt_setcallback(buf, expr) end + +--- Set a callback for buffer {buf} to {expr}. When {expr} is an +--- empty string the callback is removed. This has only effect if +--- {buf} has 'buftype' set to "prompt". +--- +--- This callback will be invoked when pressing CTRL-C in Insert +--- mode. Without setting a callback Vim will exit Insert mode, +--- as in any buffer. +--- +--- @param buf any +--- @param expr any +--- @return any +function vim.fn.prompt_setinterrupt(buf, expr) end + +--- Set prompt for buffer {buf} to {text}. You most likely want +--- {text} to end in a space. +--- The result is only visible if {buf} has 'buftype' set to +--- "prompt". Example: >vim +--- call prompt_setprompt(bufnr(''), 'command: ') +--- < +--- +--- @param buf any +--- @param text any +--- @return any +function vim.fn.prompt_setprompt(buf, text) end + +--- If the popup menu (see |ins-completion-menu|) is not visible, +--- returns an empty |Dictionary|, otherwise, returns a +--- |Dictionary| with the following keys: +--- height nr of items visible +--- width screen cells +--- row top screen row (0 first row) +--- col leftmost screen column (0 first col) +--- size total nr of items +--- scrollbar |TRUE| if scrollbar is visible +--- +--- The values are the same as in |v:event| during |CompleteChanged|. +--- +--- @return any +function vim.fn.pum_getpos() end + +--- Returns non-zero when the popup menu is visible, zero +--- otherwise. See |ins-completion-menu|. +--- This can be used to avoid some things that would remove the +--- popup menu. +--- +--- @return any +function vim.fn.pumvisible() end + +--- Evaluate Python expression {expr} and return its result +--- converted to Vim data structures. +--- Numbers and strings are returned as they are (strings are +--- copied though, Unicode strings are additionally converted to +--- UTF-8). +--- Lists are represented as Vim |List| type. +--- Dictionaries are represented as Vim |Dictionary| type with +--- keys converted to strings. +--- +--- @param expr any +--- @return any +function vim.fn.py3eval(expr) end + +--- Evaluate Python expression {expr} and return its result +--- converted to Vim data structures. +--- Numbers and strings are returned as they are (strings are +--- copied though). +--- Lists are represented as Vim |List| type. +--- Dictionaries are represented as Vim |Dictionary| type, +--- non-string keys result in error. +--- +--- @param expr any +--- @return any +function vim.fn.pyeval(expr) end + +--- Evaluate Python expression {expr} and return its result +--- converted to Vim data structures. +--- Uses Python 2 or 3, see |python_x| and 'pyxversion'. +--- See also: |pyeval()|, |py3eval()| +--- +--- @param expr any +--- @return any +function vim.fn.pyxeval(expr) end + +--- Return a pseudo-random Number generated with an xoshiro128** +--- algorithm using seed {expr}. The returned number is 32 bits, +--- also on 64 bits systems, for consistency. +--- {expr} can be initialized by |srand()| and will be updated by +--- rand(). If {expr} is omitted, an internal seed value is used +--- and updated. +--- Returns -1 if {expr} is invalid. +--- +--- Examples: >vim +--- echo rand() +--- let seed = srand() +--- echo rand(seed) +--- echo rand(seed) % 16 " random number 0 - 15 +--- < +--- +--- @param expr? any +--- @return any +function vim.fn.rand(expr) end + +--- Returns a |List| with Numbers: +--- - If only {expr} is specified: [0, 1, ..., {expr} - 1] +--- - If {max} is specified: [{expr}, {expr} + 1, ..., {max}] +--- - If {stride} is specified: [{expr}, {expr} + {stride}, ..., +--- {max}] (increasing {expr} with {stride} each time, not +--- producing a value past {max}). +--- When the maximum is one before the start the result is an +--- empty list. When the maximum is more than one before the +--- start this is an error. +--- Examples: >vim +--- echo range(4) " [0, 1, 2, 3] +--- echo range(2, 4) " [2, 3, 4] +--- echo range(2, 9, 3) " [2, 5, 8] +--- echo range(2, -2, -1) " [2, 1, 0, -1, -2] +--- echo range(0) " [] +--- echo range(2, 0) " error! +--- < +--- +--- @param expr any +--- @param max? any +--- @param stride? any +--- @return any +function vim.fn.range(expr, max, stride) end + +--- Read file {fname} in binary mode and return a |Blob|. +--- If {offset} is specified, read the file from the specified +--- offset. If it is a negative value, it is used as an offset +--- from the end of the file. E.g., to read the last 12 bytes: >vim +--- echo readblob('file.bin', -12) +--- <If {size} is specified, only the specified size will be read. +--- E.g. to read the first 100 bytes of a file: >vim +--- echo readblob('file.bin', 0, 100) +--- <If {size} is -1 or omitted, the whole data starting from +--- {offset} will be read. +--- This can be also used to read the data from a character device +--- on Unix when {size} is explicitly set. Only if the device +--- supports seeking {offset} can be used. Otherwise it should be +--- zero. E.g. to read 10 bytes from a serial console: >vim +--- echo readblob('/dev/ttyS0', 0, 10) +--- <When the file can't be opened an error message is given and +--- the result is an empty |Blob|. +--- When the offset is beyond the end of the file the result is an +--- empty blob. +--- When trying to read more bytes than are available the result +--- is truncated. +--- Also see |readfile()| and |writefile()|. +--- +--- @param fname string +--- @param offset? any +--- @param size? any +--- @return any +function vim.fn.readblob(fname, offset, size) end + +--- Return a list with file and directory names in {directory}. +--- You can also use |glob()| if you don't need to do complicated +--- things, such as limiting the number of matches. +--- +--- When {expr} is omitted all entries are included. +--- When {expr} is given, it is evaluated to check what to do: +--- If {expr} results in -1 then no further entries will +--- be handled. +--- If {expr} results in 0 then this entry will not be +--- added to the list. +--- If {expr} results in 1 then this entry will be added +--- to the list. +--- Each time {expr} is evaluated |v:val| is set to the entry name. +--- When {expr} is a function the name is passed as the argument. +--- For example, to get a list of files ending in ".txt": >vim +--- echo readdir(dirname, {n -> n =~ '.txt$'}) +--- <To skip hidden and backup files: >vim +--- echo readdir(dirname, {n -> n !~ '^\.\|\~$'}) +--- +--- <If you want to get a directory tree: >vim +--- function! s:tree(dir) +--- return {a:dir : map(readdir(a:dir), +--- \ {_, x -> isdirectory(x) ? +--- \ {x : s:tree(a:dir .. '/' .. x)} : x})} +--- endfunction +--- echo s:tree(".") +--- < +--- Returns an empty List on error. +--- +--- @param directory any +--- @param expr? any +--- @return any +function vim.fn.readdir(directory, expr) end + +--- Read file {fname} and return a |List|, each line of the file +--- as an item. Lines are broken at NL characters. Macintosh +--- files separated with CR will result in a single long line +--- (unless a NL appears somewhere). +--- All NUL characters are replaced with a NL character. +--- When {type} contains "b" binary mode is used: +--- - When the last line ends in a NL an extra empty list item is +--- added. +--- - No CR characters are removed. +--- Otherwise: +--- - CR characters that appear before a NL are removed. +--- - Whether the last line ends in a NL or not does not matter. +--- - Any UTF-8 byte order mark is removed from the text. +--- When {max} is given this specifies the maximum number of lines +--- to be read. Useful if you only want to check the first ten +--- lines of a file: >vim +--- for line in readfile(fname, '', 10) +--- if line =~ 'Date' | echo line | endif +--- endfor +--- <When {max} is negative -{max} lines from the end of the file +--- are returned, or as many as there are. +--- When {max} is zero the result is an empty list. +--- Note that without {max} the whole file is read into memory. +--- Also note that there is no recognition of encoding. Read a +--- file into a buffer if you need to. +--- Deprecated (use |readblob()| instead): When {type} contains +--- "B" a |Blob| is returned with the binary data of the file +--- unmodified. +--- When the file can't be opened an error message is given and +--- the result is an empty list. +--- Also see |writefile()|. +--- +--- @param fname string +--- @param type? any +--- @param max? any +--- @return any +function vim.fn.readfile(fname, type, max) end + +--- {func} is called for every item in {object}, which can be a +--- |String|, |List| or a |Blob|. {func} is called with two +--- arguments: the result so far and current item. After +--- processing all items the result is returned. +--- +--- {initial} is the initial result. When omitted, the first item +--- in {object} is used and {func} is first called for the second +--- item. If {initial} is not given and {object} is empty no +--- result can be computed, an E998 error is given. +--- +--- Examples: >vim +--- echo reduce([1, 3, 5], { acc, val -> acc + val }) +--- echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a') +--- echo reduce(0z1122, { acc, val -> 2 * acc + val }) +--- echo reduce('xyz', { acc, val -> acc .. ',' .. val }) +--- < +--- +--- @param object any +--- @param func any +--- @param initial? any +--- @return any +function vim.fn.reduce(object, func, initial) end + +--- Returns the single letter name of the register being executed. +--- Returns an empty string when no register is being executed. +--- See |\@|. +--- +--- @return any +function vim.fn.reg_executing() end + +--- Returns the single letter name of the last recorded register. +--- Returns an empty string when nothing was recorded yet. +--- See |q| and |Q|. +--- +--- @return any +function vim.fn.reg_recorded() end + +--- Returns the single letter name of the register being recorded. +--- Returns an empty string when not recording. See |q|. +--- +--- @return any +function vim.fn.reg_recording() end + +--- @return any +function vim.fn.reltime() end + +--- @param start? any +--- @return any +function vim.fn.reltime(start) end + +--- Return an item that represents a time value. The item is a +--- list with items that depend on the system. +--- The item can be passed to |reltimestr()| to convert it to a +--- string or |reltimefloat()| to convert to a Float. +--- +--- Without an argument it returns the current "relative time", an +--- implementation-defined value meaningful only when used as an +--- argument to |reltime()|, |reltimestr()| and |reltimefloat()|. +--- +--- With one argument it returns the time passed since the time +--- specified in the argument. +--- With two arguments it returns the time passed between {start} +--- and {end}. +--- +--- The {start} and {end} arguments must be values returned by +--- reltime(). Returns zero on error. +--- +--- Note: |localtime()| returns the current (non-relative) time. +--- +--- @param start? any +--- @param end_? any +--- @return any +function vim.fn.reltime(start, end_) end + +--- Return a Float that represents the time value of {time}. +--- Unit of time is seconds. +--- Example: +--- let start = reltime() +--- call MyFunction() +--- let seconds = reltimefloat(reltime(start)) +--- See the note of reltimestr() about overhead. +--- Also see |profiling|. +--- If there is an error an empty string is returned +--- +--- @param time any +--- @return any +function vim.fn.reltimefloat(time) end + +--- Return a String that represents the time value of {time}. +--- This is the number of seconds, a dot and the number of +--- microseconds. Example: >vim +--- let start = reltime() +--- call MyFunction() +--- echo reltimestr(reltime(start)) +--- <Note that overhead for the commands will be added to the time. +--- Leading spaces are used to make the string align nicely. You +--- can use split() to remove it. >vim +--- echo split(reltimestr(reltime(start)))[0] +--- <Also see |profiling|. +--- If there is an error an empty string is returned +--- +--- @param time any +--- @return any +function vim.fn.reltimestr(time) end + +--- @param list any +--- @param idx integer +--- @return any +function vim.fn.remove(list, idx) end + +--- Without {end}: Remove the item at {idx} from |List| {list} and +--- return the item. +--- With {end}: Remove items from {idx} to {end} (inclusive) and +--- return a |List| with these items. When {idx} points to the same +--- item as {end} a list with one item is returned. When {end} +--- points to an item before {idx} this is an error. +--- See |list-index| for possible values of {idx} and {end}. +--- Returns zero on error. +--- Example: >vim +--- echo "last item: " .. remove(mylist, -1) +--- call remove(mylist, 0, 9) +--- < +--- Use |delete()| to remove a file. +--- +--- @param list any +--- @param idx integer +--- @param end_? any +--- @return any +function vim.fn.remove(list, idx, end_) end + +--- @param blob any +--- @param idx integer +--- @return any +function vim.fn.remove(blob, idx) end + +--- Without {end}: Remove the byte at {idx} from |Blob| {blob} and +--- return the byte. +--- With {end}: Remove bytes from {idx} to {end} (inclusive) and +--- return a |Blob| with these bytes. When {idx} points to the same +--- byte as {end} a |Blob| with one byte is returned. When {end} +--- points to a byte before {idx} this is an error. +--- Returns zero on error. +--- Example: >vim +--- echo "last byte: " .. remove(myblob, -1) +--- call remove(mylist, 0, 9) +--- < +--- +--- @param blob any +--- @param idx integer +--- @param end_? any +--- @return any +function vim.fn.remove(blob, idx, end_) end + +--- Remove the entry from {dict} with key {key} and return it. +--- Example: >vim +--- echo "removed " .. remove(dict, "one") +--- <If there is no {key} in {dict} this is an error. +--- Returns zero on error. +--- +--- @param dict any +--- @param key any +--- @return any +function vim.fn.remove(dict, key) end + +--- Rename the file by the name {from} to the name {to}. This +--- should also work to move files across file systems. The +--- result is a Number, which is 0 if the file was renamed +--- successfully, and non-zero when the renaming failed. +--- NOTE: If {to} exists it is overwritten without warning. +--- This function is not available in the |sandbox|. +--- +--- @param from any +--- @param to any +--- @return any +function vim.fn.rename(from, to) end + +--- Repeat {expr} {count} times and return the concatenated +--- result. Example: >vim +--- let separator = repeat('-', 80) +--- <When {count} is zero or negative the result is empty. +--- When {expr} is a |List| or a |Blob| the result is {expr} +--- concatenated {count} times. Example: >vim +--- let longlist = repeat(['a', 'b'], 3) +--- <Results in ['a', 'b', 'a', 'b', 'a', 'b']. +--- +--- @param expr any +--- @param count any +--- @return any +vim.fn['repeat'] = function(expr, count) end + +--- On MS-Windows, when {filename} is a shortcut (a .lnk file), +--- returns the path the shortcut points to in a simplified form. +--- On Unix, repeat resolving symbolic links in all path +--- components of {filename} and return the simplified result. +--- To cope with link cycles, resolving of symbolic links is +--- stopped after 100 iterations. +--- On other systems, return the simplified {filename}. +--- The simplification step is done as by |simplify()|. +--- resolve() keeps a leading path component specifying the +--- current directory (provided the result is still a relative +--- path name) and also keeps a trailing path separator. +--- +--- @param filename any +--- @return any +function vim.fn.resolve(filename) end + +--- Reverse the order of items in {object}. {object} can be a +--- |List|, a |Blob| or a |String|. For a List and a Blob the +--- items are reversed in-place and {object} is returned. +--- For a String a new String is returned. +--- Returns zero if {object} is not a List, Blob or a String. +--- If you want a List or Blob to remain unmodified make a copy +--- first: >vim +--- let revlist = reverse(copy(mylist)) +--- < +--- +--- @param object any +--- @return any +function vim.fn.reverse(object) end + +--- Round off {expr} to the nearest integral value and return it +--- as a |Float|. If {expr} lies halfway between two integral +--- values, then use the larger one (away from zero). +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo round(0.456) +--- < 0.0 >vim +--- echo round(4.5) +--- < 5.0 >vim +--- echo round(-4.5) +--- < -5.0 +--- +--- @param expr any +--- @return any +function vim.fn.round(expr) end + +--- Sends {event} to {channel} via |RPC| and returns immediately. +--- If {channel} is 0, the event is broadcast to all channels. +--- Example: >vim +--- au VimLeave call rpcnotify(0, "leaving") +--- < +--- +--- @param channel any +--- @param event any +--- @param args? any +--- @return any +function vim.fn.rpcnotify(channel, event, args) end + +--- Sends a request to {channel} to invoke {method} via +--- |RPC| and blocks until a response is received. +--- Example: >vim +--- let result = rpcrequest(rpc_chan, "func", 1, 2, 3) +--- < +--- +--- @param channel any +--- @param method any +--- @param args? any +--- @return any +function vim.fn.rpcrequest(channel, method, args) end + +--- Deprecated. Replace >vim +--- let id = rpcstart('prog', ['arg1', 'arg2']) +--- <with >vim +--- let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true}) +--- < +--- +--- @param prog any +--- @param argv? any +--- @return any +function vim.fn.rpcstart(prog, argv) end + +--- @deprecated +--- Use |jobstop()| instead to stop any job, or +--- `chanclose(id, "rpc")` to close RPC communication +--- without stopping the job. Use chanclose(id) to close +--- any socket. +--- +--- @param ... any +--- @return any +function vim.fn.rpcstop(...) end + +--- Evaluate Ruby expression {expr} and return its result +--- converted to Vim data structures. +--- Numbers, floats and strings are returned as they are (strings +--- are copied though). +--- Arrays are represented as Vim |List| type. +--- Hashes are represented as Vim |Dictionary| type. +--- Other objects are represented as strings resulted from their +--- "Object#to_s" method. +--- +--- @param expr any +--- @return any +function vim.fn.rubyeval(expr) end + +--- Like |screenchar()|, but return the attribute. This is a rather +--- arbitrary number that can only be used to compare to the +--- attribute at other positions. +--- Returns -1 when row or col is out of range. +--- +--- @param row any +--- @param col integer +--- @return any +function vim.fn.screenattr(row, col) end + +--- The result is a Number, which is the character at position +--- [row, col] on the screen. This works for every possible +--- screen position, also status lines, window separators and the +--- command line. The top left position is row one, column one +--- The character excludes composing characters. For double-byte +--- encodings it may only be the first byte. +--- This is mainly to be used for testing. +--- Returns -1 when row or col is out of range. +--- +--- @param row any +--- @param col integer +--- @return any +function vim.fn.screenchar(row, col) end + +--- The result is a |List| of Numbers. The first number is the same +--- as what |screenchar()| returns. Further numbers are +--- composing characters on top of the base character. +--- This is mainly to be used for testing. +--- Returns an empty List when row or col is out of range. +--- +--- @param row any +--- @param col integer +--- @return any +function vim.fn.screenchars(row, col) end + +--- The result is a Number, which is the current screen column of +--- the cursor. The leftmost column has number 1. +--- This function is mainly used for testing. +--- +--- Note: Always returns the current screen column, thus if used +--- in a command (e.g. ":echo screencol()") it will return the +--- column inside the command line, which is 1 when the command is +--- executed. To get the cursor position in the file use one of +--- the following mappings: >vim +--- nnoremap <expr> GG ":echom " .. screencol() .. "\n" +--- nnoremap <silent> GG :echom screencol()<CR> +--- noremap GG <Cmd>echom screencol()<Cr> +--- < +--- +--- @return any +function vim.fn.screencol() end + +--- The result is a Dict with the screen position of the text +--- character in window {winid} at buffer line {lnum} and column +--- {col}. {col} is a one-based byte index. +--- The Dict has these members: +--- row screen row +--- col first screen column +--- endcol last screen column +--- curscol cursor screen column +--- If the specified position is not visible, all values are zero. +--- The "endcol" value differs from "col" when the character +--- occupies more than one screen cell. E.g. for a Tab "col" can +--- be 1 and "endcol" can be 8. +--- The "curscol" value is where the cursor would be placed. For +--- a Tab it would be the same as "endcol", while for a double +--- width character it would be the same as "col". +--- The |conceal| feature is ignored here, the column numbers are +--- as if 'conceallevel' is zero. You can set the cursor to the +--- right position and use |screencol()| to get the value with +--- |conceal| taken into account. +--- If the position is in a closed fold the screen position of the +--- first character is returned, {col} is not used. +--- Returns an empty Dict if {winid} is invalid. +--- +--- @param winid integer +--- @param lnum integer +--- @param col integer +--- @return any +function vim.fn.screenpos(winid, lnum, col) end + +--- The result is a Number, which is the current screen row of the +--- cursor. The top line has number one. +--- This function is mainly used for testing. +--- Alternatively you can use |winline()|. +--- +--- Note: Same restrictions as with |screencol()|. +--- +--- @return any +function vim.fn.screenrow() end + +--- The result is a String that contains the base character and +--- any composing characters at position [row, col] on the screen. +--- This is like |screenchars()| but returning a String with the +--- characters. +--- This is mainly to be used for testing. +--- Returns an empty String when row or col is out of range. +--- +--- @param row any +--- @param col integer +--- @return any +function vim.fn.screenstring(row, col) end + +--- Search for regexp pattern {pattern}. The search starts at the +--- cursor position (you can use |cursor()| to set it). +--- +--- When a match has been found its line number is returned. +--- If there is no match a 0 is returned and the cursor doesn't +--- move. No error message is given. +--- +--- {flags} is a String, which can contain these character flags: +--- 'b' search Backward instead of forward +--- 'c' accept a match at the Cursor position +--- 'e' move to the End of the match +--- 'n' do Not move the cursor +--- 'p' return number of matching sub-Pattern (see below) +--- 's' Set the ' mark at the previous location of the cursor +--- 'w' Wrap around the end of the file +--- 'W' don't Wrap around the end of the file +--- 'z' start searching at the cursor column instead of Zero +--- If neither 'w' or 'W' is given, the 'wrapscan' option applies. +--- +--- If the 's' flag is supplied, the ' mark is set, only if the +--- cursor is moved. The 's' flag cannot be combined with the 'n' +--- flag. +--- +--- 'ignorecase', 'smartcase' and 'magic' are used. +--- +--- When the 'z' flag is not given, forward searching always +--- starts in column zero and then matches before the cursor are +--- skipped. When the 'c' flag is present in 'cpo' the next +--- search starts after the match. Without the 'c' flag the next +--- search starts one column after the start of the match. This +--- matters for overlapping matches. See |cpo-c|. You can also +--- insert "\ze" to change where the match ends, see |/\ze|. +--- +--- When searching backwards and the 'z' flag is given then the +--- search starts in column zero, thus no match in the current +--- line will be found (unless wrapping around the end of the +--- file). +--- +--- When the {stopline} argument is given then the search stops +--- after searching this line. This is useful to restrict the +--- search to a range of lines. Examples: >vim +--- let match = search('(', 'b', line("w0")) +--- let end = search('END', '', line("w$")) +--- <When {stopline} is used and it is not zero this also implies +--- that the search does not wrap around the end of the file. +--- A zero value is equal to not giving the argument. +--- +--- When the {timeout} argument is given the search stops when +--- more than this many milliseconds have passed. Thus when +--- {timeout} is 500 the search stops after half a second. +--- The value must not be negative. A zero value is like not +--- giving the argument. +--- +--- If the {skip} expression is given it is evaluated with the +--- cursor positioned on the start of a match. If it evaluates to +--- non-zero this match is skipped. This can be used, for +--- example, to skip a match in a comment or a string. +--- {skip} can be a string, which is evaluated as an expression, a +--- function reference or a lambda. +--- When {skip} is omitted or empty, every match is accepted. +--- When evaluating {skip} causes an error the search is aborted +--- and -1 returned. +--- *search()-sub-match* +--- With the 'p' flag the returned value is one more than the +--- first sub-match in \(\). One if none of them matched but the +--- whole pattern did match. +--- To get the column number too use |searchpos()|. +--- +--- The cursor will be positioned at the match, unless the 'n' +--- flag is used. +--- +--- Example (goes over all files in the argument list): >vim +--- let n = 1 +--- while n <= argc() " loop over all files in arglist +--- exe "argument " .. n +--- " start at the last char in the file and wrap for the +--- " first search to find match at start of file +--- normal G$ +--- let flags = "w" +--- while search("foo", flags) > 0 +--- s/foo/bar/g +--- let flags = "W" +--- endwhile +--- update " write the file if modified +--- let n = n + 1 +--- endwhile +--- < +--- Example for using some flags: >vim +--- echo search('\<if\|\(else\)\|\(endif\)', 'ncpe') +--- <This will search for the keywords "if", "else", and "endif" +--- under or after the cursor. Because of the 'p' flag, it +--- returns 1, 2, or 3 depending on which keyword is found, or 0 +--- if the search fails. With the cursor on the first word of the +--- line: +--- if (foo == 0) | let foo = foo + 1 | endif ~ +--- the function returns 1. Without the 'c' flag, the function +--- finds the "endif" and returns 3. The same thing happens +--- without the 'e' flag if the cursor is on the "f" of "if". +--- The 'n' flag tells the function not to move the cursor. +--- +--- @param pattern any +--- @param flags? string +--- @param stopline? any +--- @param timeout? integer +--- @param skip? any +--- @return any +function vim.fn.search(pattern, flags, stopline, timeout, skip) end + +--- Get or update the last search count, like what is displayed +--- without the "S" flag in 'shortmess'. This works even if +--- 'shortmess' does contain the "S" flag. +--- +--- This returns a |Dictionary|. The dictionary is empty if the +--- previous pattern was not set and "pattern" was not specified. +--- +--- key type meaning ~ +--- current |Number| current position of match; +--- 0 if the cursor position is +--- before the first match +--- exact_match |Boolean| 1 if "current" is matched on +--- "pos", otherwise 0 +--- total |Number| total count of matches found +--- incomplete |Number| 0: search was fully completed +--- 1: recomputing was timed out +--- 2: max count exceeded +--- +--- For {options} see further down. +--- +--- To get the last search count when |n| or |N| was pressed, call +--- this function with `recompute: 0` . This sometimes returns +--- wrong information because |n| and |N|'s maximum count is 99. +--- If it exceeded 99 the result must be max count + 1 (100). If +--- you want to get correct information, specify `recompute: 1`: >vim +--- +--- " result == maxcount + 1 (100) when many matches +--- let result = searchcount(#{recompute: 0}) +--- +--- " Below returns correct result (recompute defaults +--- " to 1) +--- let result = searchcount() +--- < +--- The function is useful to add the count to 'statusline': >vim +--- function! LastSearchCount() abort +--- let result = searchcount(#{recompute: 0}) +--- if empty(result) +--- return '' +--- endif +--- if result.incomplete ==# 1 " timed out +--- return printf(' /%s [?/??]', \@/) +--- elseif result.incomplete ==# 2 " max count exceeded +--- if result.total > result.maxcount && +--- \ result.current > result.maxcount +--- return printf(' /%s [>%d/>%d]', \@/, +--- \ result.current, result.total) +--- elseif result.total > result.maxcount +--- return printf(' /%s [%d/>%d]', \@/, +--- \ result.current, result.total) +--- endif +--- endif +--- return printf(' /%s [%d/%d]', \@/, +--- \ result.current, result.total) +--- endfunction +--- let &statusline ..= '%{LastSearchCount()}' +--- +--- " Or if you want to show the count only when +--- " 'hlsearch' was on +--- " let &statusline ..= +--- " \ '%{v:hlsearch ? LastSearchCount() : ""}' +--- < +--- You can also update the search count, which can be useful in a +--- |CursorMoved| or |CursorMovedI| autocommand: >vim +--- +--- autocmd CursorMoved,CursorMovedI * +--- \ let s:searchcount_timer = timer_start( +--- \ 200, function('s:update_searchcount')) +--- function! s:update_searchcount(timer) abort +--- if a:timer ==# s:searchcount_timer +--- call searchcount(#{ +--- \ recompute: 1, maxcount: 0, timeout: 100}) +--- redrawstatus +--- endif +--- endfunction +--- < +--- This can also be used to count matched texts with specified +--- pattern in the current buffer using "pattern": >vim +--- +--- " Count '\<foo\>' in this buffer +--- " (Note that it also updates search count) +--- let result = searchcount(#{pattern: '\<foo\>'}) +--- +--- " To restore old search count by old pattern, +--- " search again +--- call searchcount() +--- < +--- {options} must be a |Dictionary|. It can contain: +--- key type meaning ~ +--- recompute |Boolean| if |TRUE|, recompute the count +--- like |n| or |N| was executed. +--- otherwise returns the last +--- computed result (when |n| or +--- |N| was used when "S" is not +--- in 'shortmess', or this +--- function was called). +--- (default: |TRUE|) +--- pattern |String| recompute if this was given +--- and different with |\@/|. +--- this works as same as the +--- below command is executed +--- before calling this function >vim +--- let \@/ = pattern +--- < (default: |\@/|) +--- timeout |Number| 0 or negative number is no +--- timeout. timeout milliseconds +--- for recomputing the result +--- (default: 0) +--- maxcount |Number| 0 or negative number is no +--- limit. max count of matched +--- text while recomputing the +--- result. if search exceeded +--- total count, "total" value +--- becomes `maxcount + 1` +--- (default: 0) +--- pos |List| `[lnum, col, off]` value +--- when recomputing the result. +--- this changes "current" result +--- value. see |cursor()|, |getpos()| +--- (default: cursor's position) +--- +--- @param options? table +--- @return any +function vim.fn.searchcount(options) end + +--- Search for the declaration of {name}. +--- +--- With a non-zero {global} argument it works like |gD|, find +--- first match in the file. Otherwise it works like |gd|, find +--- first match in the function. +--- +--- With a non-zero {thisblock} argument matches in a {} block +--- that ends before the cursor position are ignored. Avoids +--- finding variable declarations only valid in another scope. +--- +--- Moves the cursor to the found match. +--- Returns zero for success, non-zero for failure. +--- Example: >vim +--- if searchdecl('myvar') == 0 +--- echo getline('.') +--- endif +--- < +--- +--- @param name string +--- @param global? any +--- @param thisblock? any +--- @return any +function vim.fn.searchdecl(name, global, thisblock) end + +--- Search for the match of a nested start-end pair. This can be +--- used to find the "endif" that matches an "if", while other +--- if/endif pairs in between are ignored. +--- The search starts at the cursor. The default is to search +--- forward, include 'b' in {flags} to search backward. +--- If a match is found, the cursor is positioned at it and the +--- line number is returned. If no match is found 0 or -1 is +--- returned and the cursor doesn't move. No error message is +--- given. +--- +--- {start}, {middle} and {end} are patterns, see |pattern|. They +--- must not contain \( \) pairs. Use of \%( \) is allowed. When +--- {middle} is not empty, it is found when searching from either +--- direction, but only when not in a nested start-end pair. A +--- typical use is: >vim +--- echo searchpair('\<if\>', '\<else\>', '\<endif\>') +--- <By leaving {middle} empty the "else" is skipped. +--- +--- {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with +--- |search()|. Additionally: +--- 'r' Repeat until no more matches found; will find the +--- outer pair. Implies the 'W' flag. +--- 'm' Return number of matches instead of line number with +--- the match; will be > 1 when 'r' is used. +--- Note: it's nearly always a good idea to use the 'W' flag, to +--- avoid wrapping around the end of the file. +--- +--- When a match for {start}, {middle} or {end} is found, the +--- {skip} expression is evaluated with the cursor positioned on +--- the start of the match. It should return non-zero if this +--- match is to be skipped. E.g., because it is inside a comment +--- or a string. +--- When {skip} is omitted or empty, every match is accepted. +--- When evaluating {skip} causes an error the search is aborted +--- and -1 returned. +--- {skip} can be a string, a lambda, a funcref or a partial. +--- Anything else makes the function fail. +--- +--- For {stopline} and {timeout} see |search()|. +--- +--- The value of 'ignorecase' is used. 'magic' is ignored, the +--- patterns are used like it's on. +--- +--- The search starts exactly at the cursor. A match with +--- {start}, {middle} or {end} at the next character, in the +--- direction of searching, is the first one found. Example: >vim +--- if 1 +--- if 2 +--- endif 2 +--- endif 1 +--- <When starting at the "if 2", with the cursor on the "i", and +--- searching forwards, the "endif 2" is found. When starting on +--- the character just before the "if 2", the "endif 1" will be +--- found. That's because the "if 2" will be found first, and +--- then this is considered to be a nested if/endif from "if 2" to +--- "endif 2". +--- When searching backwards and {end} is more than one character, +--- it may be useful to put "\zs" at the end of the pattern, so +--- that when the cursor is inside a match with the end it finds +--- the matching start. +--- +--- Example, to find the "endif" command in a Vim script: >vim +--- +--- echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W', +--- \ 'getline(".") =~ "^\\s*\""') +--- +--- <The cursor must be at or after the "if" for which a match is +--- to be found. Note that single-quote strings are used to avoid +--- having to double the backslashes. The skip expression only +--- catches comments at the start of a line, not after a command. +--- Also, a word "en" or "if" halfway through a line is considered +--- a match. +--- Another example, to search for the matching "{" of a "}": >vim +--- +--- echo searchpair('{', '', '}', 'bW') +--- +--- <This works when the cursor is at or before the "}" for which a +--- match is to be found. To reject matches that syntax +--- highlighting recognized as strings: >vim +--- +--- echo searchpair('{', '', '}', 'bW', +--- \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"') +--- < +--- +--- @return any +function vim.fn.searchpair() end + +--- Same as |searchpair()|, but returns a |List| with the line and +--- column position of the match. The first element of the |List| +--- is the line number and the second element is the byte index of +--- the column position of the match. If no match is found, +--- returns [0, 0]. >vim +--- +--- let [lnum,col] = searchpairpos('{', '', '}', 'n') +--- < +--- See |match-parens| for a bigger and more useful example. +--- +--- @return any +function vim.fn.searchpairpos() end + +--- Same as |search()|, but returns a |List| with the line and +--- column position of the match. The first element of the |List| +--- is the line number and the second element is the byte index of +--- the column position of the match. If no match is found, +--- returns [0, 0]. +--- Example: >vim +--- let [lnum, col] = searchpos('mypattern', 'n') +--- +--- <When the 'p' flag is given then there is an extra item with +--- the sub-pattern match number |search()-sub-match|. Example: >vim +--- let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np') +--- <In this example "submatch" is 2 when a lowercase letter is +--- found |/\l|, 3 when an uppercase letter is found |/\u|. +--- +--- @param pattern any +--- @param flags? string +--- @param stopline? any +--- @param timeout? integer +--- @param skip? any +--- @return any +function vim.fn.searchpos(pattern, flags, stopline, timeout, skip) end + +--- Returns a list of server addresses, or empty if all servers +--- were stopped. |serverstart()| |serverstop()| +--- Example: >vim +--- echo serverlist() +--- < +--- +--- @return any +function vim.fn.serverlist() end + +--- Opens a socket or named pipe at {address} and listens for +--- |RPC| messages. Clients can send |API| commands to the +--- returned address to control Nvim. +--- +--- Returns the address string (which may differ from the +--- {address} argument, see below). +--- +--- - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address +--- where the last ":" separates host and port (empty or zero +--- assigns a random port). +--- - Else {address} is the path to a named pipe (except on Windows). +--- - If {address} has no slashes ("/") it is treated as the +--- "name" part of a generated path in this format: >vim +--- stdpath("run").."/{name}.{pid}.{counter}" +--- < - If {address} is omitted the name is "nvim". >vim +--- echo serverstart() +--- < > +--- => /tmp/nvim.bram/oknANW/nvim.15430.5 +--- < +--- Example bash command to list all Nvim servers: >bash +--- ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0 +--- +--- <Example named pipe: >vim +--- if has('win32') +--- echo serverstart('\\.\pipe\nvim-pipe-1234') +--- else +--- echo serverstart('nvim.sock') +--- endif +--- < +--- Example TCP/IP address: >vim +--- echo serverstart('::1:12345') +--- < +--- +--- @param address? any +--- @return any +function vim.fn.serverstart(address) end + +--- Closes the pipe or socket at {address}. +--- Returns TRUE if {address} is valid, else FALSE. +--- If |v:servername| is stopped it is set to the next available +--- address in |serverlist()|. +--- +--- @param address any +--- @return any +function vim.fn.serverstop(address) end + +--- Set line {lnum} to {text} in buffer {buf}. This works like +--- |setline()| for the specified buffer. +--- +--- This function works only for loaded buffers. First call +--- |bufload()| if needed. +--- +--- To insert lines use |appendbufline()|. +--- +--- {text} can be a string to set one line, or a List of strings +--- to set multiple lines. If the List extends below the last +--- line then those lines are added. If the List is empty then +--- nothing is changed and zero is returned. +--- +--- For the use of {buf}, see |bufname()| above. +--- +--- {lnum} is used like with |setline()|. +--- Use "$" to refer to the last line in buffer {buf}. +--- When {lnum} is just below the last line the {text} will be +--- added below the last line. +--- On success 0 is returned, on failure 1 is returned. +--- +--- If {buf} is not a valid buffer or {lnum} is not valid, an +--- error message is given. +--- +--- @param buf any +--- @param lnum integer +--- @param text any +--- @return any +function vim.fn.setbufline(buf, lnum, text) end + +--- Set option or local variable {varname} in buffer {buf} to +--- {val}. +--- This also works for a global or local window option, but it +--- doesn't work for a global or local window variable. +--- For a local window option the global value is unchanged. +--- For the use of {buf}, see |bufname()| above. +--- The {varname} argument is a string. +--- Note that the variable name without "b:" must be used. +--- Examples: >vim +--- call setbufvar(1, "&mod", 1) +--- call setbufvar("todo", "myvar", "foobar") +--- <This function is not available in the |sandbox|. +--- +--- @param buf any +--- @param varname string +--- @param val any +--- @return any +function vim.fn.setbufvar(buf, varname, val) end + +--- Specify overrides for cell widths of character ranges. This +--- tells Vim how wide characters are when displayed in the +--- terminal, counted in screen cells. The values override +--- 'ambiwidth'. Example: >vim +--- call setcellwidths([ +--- \ [0x111, 0x111, 1], +--- \ [0x2194, 0x2199, 2], +--- \ ]) +--- +--- <The {list} argument is a List of Lists with each three +--- numbers: [{low}, {high}, {width}]. *E1109* *E1110* +--- {low} and {high} can be the same, in which case this refers to +--- one character. Otherwise it is the range of characters from +--- {low} to {high} (inclusive). *E1111* *E1114* +--- Only characters with value 0x80 and higher can be used. +--- +--- {width} must be either 1 or 2, indicating the character width +--- in screen cells. *E1112* +--- An error is given if the argument is invalid, also when a +--- range overlaps with another. *E1113* +--- +--- If the new value causes 'fillchars' or 'listchars' to become +--- invalid it is rejected and an error is given. +--- +--- To clear the overrides pass an empty {list}: >vim +--- call setcellwidths([]) +--- +--- <You can use the script $VIMRUNTIME/tools/emoji_list.vim to see +--- the effect for known emoji characters. Move the cursor +--- through the text to check if the cell widths of your terminal +--- match with what Vim knows about each emoji. If it doesn't +--- look right you need to adjust the {list} argument. +--- +--- @param list any +--- @return any +function vim.fn.setcellwidths(list) end + +--- Same as |setpos()| but uses the specified column number as the +--- character index instead of the byte index in the line. +--- +--- Example: +--- With the text "여보세요" in line 8: >vim +--- call setcharpos('.', [0, 8, 4, 0]) +--- <positions the cursor on the fourth character '요'. >vim +--- call setpos('.', [0, 8, 4, 0]) +--- <positions the cursor on the second character '보'. +--- +--- @param expr any +--- @param list any +--- @return any +function vim.fn.setcharpos(expr, list) end + +--- Set the current character search information to {dict}, +--- which contains one or more of the following entries: +--- +--- char character which will be used for a subsequent +--- |,| or |;| command; an empty string clears the +--- character search +--- forward direction of character search; 1 for forward, +--- 0 for backward +--- until type of character search; 1 for a |t| or |T| +--- character search, 0 for an |f| or |F| +--- character search +--- +--- This can be useful to save/restore a user's character search +--- from a script: >vim +--- let prevsearch = getcharsearch() +--- " Perform a command which clobbers user's search +--- call setcharsearch(prevsearch) +--- <Also see |getcharsearch()|. +--- +--- @param dict any +--- @return any +function vim.fn.setcharsearch(dict) end + +--- Set the command line to {str} and set the cursor position to +--- {pos}. +--- If {pos} is omitted, the cursor is positioned after the text. +--- Returns 0 when successful, 1 when not editing the command +--- line. +--- +--- @param str any +--- @param pos? any +--- @return any +function vim.fn.setcmdline(str, pos) end + +--- Set the cursor position in the command line to byte position +--- {pos}. The first position is 1. +--- Use |getcmdpos()| to obtain the current position. +--- Only works while editing the command line, thus you must use +--- |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For +--- |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is +--- set after the command line is set to the expression. For +--- |c_CTRL-R_=| it is set after evaluating the expression but +--- before inserting the resulting text. +--- When the number is too big the cursor is put at the end of the +--- line. A number smaller than one has undefined results. +--- Returns 0 when successful, 1 when not editing the command +--- line. +--- +--- @param pos any +--- @return any +function vim.fn.setcmdpos(pos) end + +--- @param lnum integer +--- @param col? integer +--- @param off? any +--- @return any +function vim.fn.setcursorcharpos(lnum, col, off) end + +--- Same as |cursor()| but uses the specified column number as the +--- character index instead of the byte index in the line. +--- +--- Example: +--- With the text "여보세요" in line 4: >vim +--- call setcursorcharpos(4, 3) +--- <positions the cursor on the third character '세'. >vim +--- call cursor(4, 3) +--- <positions the cursor on the first character '여'. +--- +--- @param list any +--- @return any +function vim.fn.setcursorcharpos(list) end + +--- Set environment variable {name} to {val}. Example: >vim +--- call setenv('HOME', '/home/myhome') +--- +--- <When {val} is |v:null| the environment variable is deleted. +--- See also |expr-env|. +--- +--- @param name string +--- @param val any +--- @return any +function vim.fn.setenv(name, val) end + +--- Set the file permissions for {fname} to {mode}. +--- {mode} must be a string with 9 characters. It is of the form +--- "rwxrwxrwx", where each group of "rwx" flags represent, in +--- turn, the permissions of the owner of the file, the group the +--- file belongs to, and other users. A '-' character means the +--- permission is off, any other character means on. Multi-byte +--- characters are not supported. +--- +--- For example "rw-r-----" means read-write for the user, +--- readable by the group, not accessible by others. "xx-x-----" +--- would do the same thing. +--- +--- Returns non-zero for success, zero for failure. +--- +--- To read permissions see |getfperm()|. +--- +--- @param fname string +--- @param mode string +--- @return any +function vim.fn.setfperm(fname, mode) end + +--- Set line {lnum} of the current buffer to {text}. To insert +--- lines use |append()|. To set lines in another buffer use +--- |setbufline()|. +--- +--- {lnum} is used like with |getline()|. +--- When {lnum} is just below the last line the {text} will be +--- added below the last line. +--- {text} can be any type or a List of any type, each item is +--- converted to a String. When {text} is an empty List then +--- nothing is changed and FALSE is returned. +--- +--- If this succeeds, FALSE is returned. If this fails (most likely +--- because {lnum} is invalid) TRUE is returned. +--- +--- Example: >vim +--- call setline(5, strftime("%c")) +--- +--- <When {text} is a |List| then line {lnum} and following lines +--- will be set to the items in the list. Example: >vim +--- call setline(5, ['aaa', 'bbb', 'ccc']) +--- <This is equivalent to: >vim +--- for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']] +--- call setline(n, l) +--- endfor +--- +--- <Note: The '[ and '] marks are not set. +--- +--- @param lnum integer +--- @param text any +--- @return any +function vim.fn.setline(lnum, text) end + +--- Create or replace or add to the location list for window {nr}. +--- {nr} can be the window number or the |window-ID|. +--- When {nr} is zero the current window is used. +--- +--- For a location list window, the displayed location list is +--- modified. For an invalid window number {nr}, -1 is returned. +--- Otherwise, same as |setqflist()|. +--- Also see |location-list|. +--- +--- For {action} see |setqflist-action|. +--- +--- If the optional {what} dictionary argument is supplied, then +--- only the items listed in {what} are set. Refer to |setqflist()| +--- for the list of supported keys in {what}. +--- +--- @param nr integer +--- @param list any +--- @param action? any +--- @param what? any +--- @return any +function vim.fn.setloclist(nr, list, action, what) end + +--- Restores a list of matches saved by |getmatches()| for the +--- current window. Returns 0 if successful, otherwise -1. All +--- current matches are cleared before the list is restored. See +--- example for |getmatches()|. +--- If {win} is specified, use the window with this number or +--- window ID instead of the current window. +--- +--- @param list any +--- @param win? any +--- @return any +function vim.fn.setmatches(list, win) end + +--- Set the position for String {expr}. Possible values: +--- . the cursor +--- 'x mark x +--- +--- {list} must be a |List| with four or five numbers: +--- [bufnum, lnum, col, off] +--- [bufnum, lnum, col, off, curswant] +--- +--- "bufnum" is the buffer number. Zero can be used for the +--- current buffer. When setting an uppercase mark "bufnum" is +--- used for the mark position. For other marks it specifies the +--- buffer to set the mark in. You can use the |bufnr()| function +--- to turn a file name into a buffer number. +--- For setting the cursor and the ' mark "bufnum" is ignored, +--- since these are associated with a window, not a buffer. +--- Does not change the jumplist. +--- +--- "lnum" and "col" are the position in the buffer. The first +--- column is 1. Use a zero "lnum" to delete a mark. If "col" is +--- smaller than 1 then 1 is used. To use the character count +--- instead of the byte count, use |setcharpos()|. +--- +--- The "off" number is only used when 'virtualedit' is set. Then +--- it is the offset in screen columns from the start of the +--- character. E.g., a position within a <Tab> or after the last +--- character. +--- +--- The "curswant" number is only used when setting the cursor +--- position. It sets the preferred column for when moving the +--- cursor vertically. When the "curswant" number is missing the +--- preferred column is not set. When it is present and setting a +--- mark position it is not used. +--- +--- Note that for '< and '> changing the line number may result in +--- the marks to be effectively be swapped, so that '< is always +--- before '>. +--- +--- Returns 0 when the position could be set, -1 otherwise. +--- An error message is given if {expr} is invalid. +--- +--- Also see |setcharpos()|, |getpos()| and |getcurpos()|. +--- +--- This does not restore the preferred column for moving +--- vertically; if you set the cursor position with this, |j| and +--- |k| motions will jump to previous columns! Use |cursor()| to +--- also set the preferred column. Also see the "curswant" key in +--- |winrestview()|. +--- +--- @param expr any +--- @param list any +--- @return any +function vim.fn.setpos(expr, list) end + +--- Create or replace or add to the quickfix list. +--- +--- If the optional {what} dictionary argument is supplied, then +--- only the items listed in {what} are set. The first {list} +--- argument is ignored. See below for the supported items in +--- {what}. +--- *setqflist-what* +--- When {what} is not present, the items in {list} are used. Each +--- item must be a dictionary. Non-dictionary items in {list} are +--- ignored. Each dictionary item can contain the following +--- entries: +--- +--- bufnr buffer number; must be the number of a valid +--- buffer +--- filename name of a file; only used when "bufnr" is not +--- present or it is invalid. +--- module name of a module; if given it will be used in +--- quickfix error window instead of the filename. +--- lnum line number in the file +--- end_lnum end of lines, if the item spans multiple lines +--- pattern search pattern used to locate the error +--- col column number +--- vcol when non-zero: "col" is visual column +--- when zero: "col" is byte index +--- end_col end column, if the item spans multiple columns +--- nr error number +--- text description of the error +--- type single-character error type, 'E', 'W', etc. +--- valid recognized error message +--- user_data +--- custom data associated with the item, can be +--- any type. +--- +--- The "col", "vcol", "nr", "type" and "text" entries are +--- optional. Either "lnum" or "pattern" entry can be used to +--- locate a matching error line. +--- If the "filename" and "bufnr" entries are not present or +--- neither the "lnum" or "pattern" entries are present, then the +--- item will not be handled as an error line. +--- If both "pattern" and "lnum" are present then "pattern" will +--- be used. +--- If the "valid" entry is not supplied, then the valid flag is +--- set when "bufnr" is a valid buffer or "filename" exists. +--- If you supply an empty {list}, the quickfix list will be +--- cleared. +--- Note that the list is not exactly the same as what +--- |getqflist()| returns. +--- +--- {action} values: *setqflist-action* *E927* +--- 'a' The items from {list} are added to the existing +--- quickfix list. If there is no existing list, then a +--- new list is created. +--- +--- 'r' The items from the current quickfix list are replaced +--- with the items from {list}. This can also be used to +--- clear the list: >vim +--- call setqflist([], 'r') +--- < +--- 'f' All the quickfix lists in the quickfix stack are +--- freed. +--- +--- If {action} is not present or is set to ' ', then a new list +--- is created. The new quickfix list is added after the current +--- quickfix list in the stack and all the following lists are +--- freed. To add a new quickfix list at the end of the stack, +--- set "nr" in {what} to "$". +--- +--- The following items can be specified in dictionary {what}: +--- context quickfix list context. See |quickfix-context| +--- efm errorformat to use when parsing text from +--- "lines". If this is not present, then the +--- 'errorformat' option value is used. +--- See |quickfix-parse| +--- id quickfix list identifier |quickfix-ID| +--- idx index of the current entry in the quickfix +--- list specified by "id" or "nr". If set to '$', +--- then the last entry in the list is set as the +--- current entry. See |quickfix-index| +--- items list of quickfix entries. Same as the {list} +--- argument. +--- lines use 'errorformat' to parse a list of lines and +--- add the resulting entries to the quickfix list +--- {nr} or {id}. Only a |List| value is supported. +--- See |quickfix-parse| +--- nr list number in the quickfix stack; zero +--- means the current quickfix list and "$" means +--- the last quickfix list. +--- quickfixtextfunc +--- function to get the text to display in the +--- quickfix window. The value can be the name of +--- a function or a funcref or a lambda. Refer to +--- |quickfix-window-function| for an explanation +--- of how to write the function and an example. +--- title quickfix list title text. See |quickfix-title| +--- Unsupported keys in {what} are ignored. +--- If the "nr" item is not present, then the current quickfix list +--- is modified. When creating a new quickfix list, "nr" can be +--- set to a value one greater than the quickfix stack size. +--- When modifying a quickfix list, to guarantee that the correct +--- list is modified, "id" should be used instead of "nr" to +--- specify the list. +--- +--- Examples (See also |setqflist-examples|): >vim +--- call setqflist([], 'r', {'title': 'My search'}) +--- call setqflist([], 'r', {'nr': 2, 'title': 'Errors'}) +--- call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]}) +--- < +--- Returns zero for success, -1 for failure. +--- +--- This function can be used to create a quickfix list +--- independent of the 'errorformat' setting. Use a command like +--- `:cc 1` to jump to the first position. +--- +--- @param list any +--- @param action? any +--- @param what? any +--- @return any +function vim.fn.setqflist(list, action, what) end + +--- Set the register {regname} to {value}. +--- If {regname} is "" or "\@", the unnamed register '"' is used. +--- The {regname} argument is a string. +--- +--- {value} may be any value returned by |getreg()| or +--- |getreginfo()|, including a |List| or |Dict|. +--- If {options} contains "a" or {regname} is upper case, +--- then the value is appended. +--- +--- {options} can also contain a register type specification: +--- "c" or "v" |charwise| mode +--- "l" or "V" |linewise| mode +--- "b" or "<CTRL-V>" |blockwise-visual| mode +--- If a number immediately follows "b" or "<CTRL-V>" then this is +--- used as the width of the selection - if it is not specified +--- then the width of the block is set to the number of characters +--- in the longest line (counting a <Tab> as 1 character). +--- If {options} contains "u" or '"', then the unnamed register is +--- set to point to register {regname}. +--- +--- If {options} contains no register settings, then the default +--- is to use character mode unless {value} ends in a <NL> for +--- string {value} and linewise mode for list {value}. Blockwise +--- mode is never selected automatically. +--- Returns zero for success, non-zero for failure. +--- +--- *E883* +--- Note: you may not use |List| containing more than one item to +--- set search and expression registers. Lists containing no +--- items act like empty strings. +--- +--- Examples: >vim +--- call setreg(v:register, \@*) +--- call setreg('*', \@%, 'ac') +--- call setreg('a', "1\n2\n3", 'b5') +--- call setreg('"', { 'points_to': 'a'}) +--- +--- <This example shows using the functions to save and restore a +--- register: >vim +--- let var_a = getreginfo() +--- call setreg('a', var_a) +--- <or: >vim +--- let var_a = getreg('a', 1, 1) +--- let var_amode = getregtype('a') +--- " .... +--- call setreg('a', var_a, var_amode) +--- <Note: you may not reliably restore register value +--- without using the third argument to |getreg()| as without it +--- newlines are represented as newlines AND Nul bytes are +--- represented as newlines as well, see |NL-used-for-Nul|. +--- +--- You can also change the type of a register by appending +--- nothing: >vim +--- call setreg('a', '', 'al') +--- +--- @param regname string +--- @param value any +--- @param options? table +--- @return any +function vim.fn.setreg(regname, value, options) end + +--- Set tab-local variable {varname} to {val} in tab page {tabnr}. +--- |t:var| +--- The {varname} argument is a string. +--- Note that the variable name without "t:" must be used. +--- Tabs are numbered starting with one. +--- This function is not available in the |sandbox|. +--- +--- @param tabnr integer +--- @param varname string +--- @param val any +--- @return any +function vim.fn.settabvar(tabnr, varname, val) end + +--- Set option or local variable {varname} in window {winnr} to +--- {val}. +--- Tabs are numbered starting with one. For the current tabpage +--- use |setwinvar()|. +--- {winnr} can be the window number or the |window-ID|. +--- When {winnr} is zero the current window is used. +--- This also works for a global or local buffer option, but it +--- doesn't work for a global or local buffer variable. +--- For a local buffer option the global value is unchanged. +--- Note that the variable name without "w:" must be used. +--- Examples: >vim +--- call settabwinvar(1, 1, "&list", 0) +--- call settabwinvar(3, 2, "myvar", "foobar") +--- <This function is not available in the |sandbox|. +--- +--- @param tabnr integer +--- @param winnr integer +--- @param varname string +--- @param val any +--- @return any +function vim.fn.settabwinvar(tabnr, winnr, varname, val) end + +--- Modify the tag stack of the window {nr} using {dict}. +--- {nr} can be the window number or the |window-ID|. +--- +--- For a list of supported items in {dict}, refer to +--- |gettagstack()|. "curidx" takes effect before changing the tag +--- stack. +--- *E962* +--- How the tag stack is modified depends on the {action} +--- argument: +--- - If {action} is not present or is set to 'r', then the tag +--- stack is replaced. +--- - If {action} is set to 'a', then new entries from {dict} are +--- pushed (added) onto the tag stack. +--- - If {action} is set to 't', then all the entries from the +--- current entry in the tag stack or "curidx" in {dict} are +--- removed and then new entries are pushed to the stack. +--- +--- The current index is set to one after the length of the tag +--- stack after the modification. +--- +--- Returns zero for success, -1 for failure. +--- +--- Examples (for more examples see |tagstack-examples|): +--- Empty the tag stack of window 3: >vim +--- call settagstack(3, {'items' : []}) +--- +--- < Save and restore the tag stack: >vim +--- let stack = gettagstack(1003) +--- " do something else +--- call settagstack(1003, stack) +--- unlet stack +--- < +--- +--- @param nr integer +--- @param dict any +--- @param action? any +--- @return any +function vim.fn.settagstack(nr, dict, action) end + +--- Like |settabwinvar()| for the current tab page. +--- Examples: >vim +--- call setwinvar(1, "&list", 0) +--- call setwinvar(2, "myvar", "foobar") +--- +--- @param nr integer +--- @param varname string +--- @param val any +--- @return any +function vim.fn.setwinvar(nr, varname, val) end + +--- Returns a String with 64 hex characters, which is the SHA256 +--- checksum of {string}. +--- +--- @param string string +--- @return any +function vim.fn.sha256(string) end + +--- Escape {string} for use as a shell command argument. +--- +--- On Windows when 'shellslash' is not set, encloses {string} in +--- double-quotes and doubles all double-quotes within {string}. +--- Otherwise encloses {string} in single-quotes and replaces all +--- "'" with "'\''". +--- +--- If {special} is a |non-zero-arg|: +--- - Special items such as "!", "%", "#" and "<cword>" will be +--- preceded by a backslash. The backslash will be removed again +--- by the |:!| command. +--- - The <NL> character is escaped. +--- +--- If 'shell' contains "csh" in the tail: +--- - The "!" character will be escaped. This is because csh and +--- tcsh use "!" for history replacement even in single-quotes. +--- - The <NL> character is escaped (twice if {special} is +--- a |non-zero-arg|). +--- +--- If 'shell' contains "fish" in the tail, the "\" character will +--- be escaped because in fish it is used as an escape character +--- inside single quotes. +--- +--- Example of use with a |:!| command: >vim +--- exe '!dir ' .. shellescape(expand('<cfile>'), 1) +--- <This results in a directory listing for the file under the +--- cursor. Example of use with |system()|: >vim +--- call system("chmod +w -- " .. shellescape(expand("%"))) +--- <See also |::S|. +--- +--- @param string string +--- @param special? any +--- @return any +function vim.fn.shellescape(string, special) end + +--- Returns the effective value of 'shiftwidth'. This is the +--- 'shiftwidth' value unless it is zero, in which case it is the +--- 'tabstop' value. To be backwards compatible in indent +--- plugins, use this: >vim +--- if exists('*shiftwidth') +--- func s:sw() +--- return shiftwidth() +--- endfunc +--- else +--- func s:sw() +--- return &sw +--- endfunc +--- endif +--- <And then use s:sw() instead of &sw. +--- +--- When there is one argument {col} this is used as column number +--- for which to return the 'shiftwidth' value. This matters for the +--- 'vartabstop' feature. If no {col} argument is given, column 1 +--- will be assumed. +--- +--- @param col? integer +--- @return integer +function vim.fn.shiftwidth(col) end + +--- @param name string +--- @param dict? vim.fn.sign_define.dict +--- @return 0|-1 +function vim.fn.sign_define(name, dict) end + +--- Define a new sign named {name} or modify the attributes of an +--- existing sign. This is similar to the |:sign-define| command. +--- +--- Prefix {name} with a unique text to avoid name collisions. +--- There is no {group} like with placing signs. +--- +--- The {name} can be a String or a Number. The optional {dict} +--- argument specifies the sign attributes. The following values +--- are supported: +--- icon full path to the bitmap file for the sign. +--- linehl highlight group used for the whole line the +--- sign is placed in. +--- numhl highlight group used for the line number where +--- the sign is placed. +--- text text that is displayed when there is no icon +--- or the GUI is not being used. +--- texthl highlight group used for the text item +--- culhl highlight group used for the text item when +--- the cursor is on the same line as the sign and +--- 'cursorline' is enabled. +--- +--- If the sign named {name} already exists, then the attributes +--- of the sign are updated. +--- +--- The one argument {list} can be used to define a list of signs. +--- Each list item is a dictionary with the above items in {dict} +--- and a "name" item for the sign name. +--- +--- Returns 0 on success and -1 on failure. When the one argument +--- {list} is used, then returns a List of values one for each +--- defined sign. +--- +--- Examples: >vim +--- call sign_define("mySign", { +--- \ "text" : "=>", +--- \ "texthl" : "Error", +--- \ "linehl" : "Search"}) +--- call sign_define([ +--- \ {'name' : 'sign1', +--- \ 'text' : '=>'}, +--- \ {'name' : 'sign2', +--- \ 'text' : '!!'} +--- \ ]) +--- < +--- +--- @param list vim.fn.sign_define.dict[] +--- @return (0|-1)[] +function vim.fn.sign_define(list) end + +--- Get a list of defined signs and their attributes. +--- This is similar to the |:sign-list| command. +--- +--- If the {name} is not supplied, then a list of all the defined +--- signs is returned. Otherwise the attribute of the specified +--- sign is returned. +--- +--- Each list item in the returned value is a dictionary with the +--- following entries: +--- icon full path to the bitmap file of the sign +--- linehl highlight group used for the whole line the +--- sign is placed in; not present if not set. +--- name name of the sign +--- numhl highlight group used for the line number where +--- the sign is placed; not present if not set. +--- text text that is displayed when there is no icon +--- or the GUI is not being used. +--- texthl highlight group used for the text item; not +--- present if not set. +--- culhl highlight group used for the text item when +--- the cursor is on the same line as the sign and +--- 'cursorline' is enabled; not present if not +--- set. +--- +--- Returns an empty List if there are no signs and when {name} is +--- not found. +--- +--- Examples: >vim +--- " Get a list of all the defined signs +--- echo sign_getdefined() +--- +--- " Get the attribute of the sign named mySign +--- echo sign_getdefined("mySign") +--- < +--- +--- @param name? string +--- @return vim.fn.sign_getdefined.ret.item[] +function vim.fn.sign_getdefined(name) end + +--- Return a list of signs placed in a buffer or all the buffers. +--- This is similar to the |:sign-place-list| command. +--- +--- If the optional buffer name {buf} is specified, then only the +--- list of signs placed in that buffer is returned. For the use +--- of {buf}, see |bufname()|. The optional {dict} can contain +--- the following entries: +--- group select only signs in this group +--- id select sign with this identifier +--- lnum select signs placed in this line. For the use +--- of {lnum}, see |line()|. +--- If {group} is "*", then signs in all the groups including the +--- global group are returned. If {group} is not supplied or is an +--- empty string, then only signs in the global group are +--- returned. If no arguments are supplied, then signs in the +--- global group placed in all the buffers are returned. +--- See |sign-group|. +--- +--- Each list item in the returned value is a dictionary with the +--- following entries: +--- bufnr number of the buffer with the sign +--- signs list of signs placed in {bufnr}. Each list +--- item is a dictionary with the below listed +--- entries +--- +--- The dictionary for each sign contains the following entries: +--- group sign group. Set to '' for the global group. +--- id identifier of the sign +--- lnum line number where the sign is placed +--- name name of the defined sign +--- priority sign priority +--- +--- The returned signs in a buffer are ordered by their line +--- number and priority. +--- +--- Returns an empty list on failure or if there are no placed +--- signs. +--- +--- Examples: >vim +--- " Get a List of signs placed in eval.c in the +--- " global group +--- echo sign_getplaced("eval.c") +--- +--- " Get a List of signs in group 'g1' placed in eval.c +--- echo sign_getplaced("eval.c", {'group' : 'g1'}) +--- +--- " Get a List of signs placed at line 10 in eval.c +--- echo sign_getplaced("eval.c", {'lnum' : 10}) +--- +--- " Get sign with identifier 10 placed in a.py +--- echo sign_getplaced("a.py", {'id' : 10}) +--- +--- " Get sign with id 20 in group 'g1' placed in a.py +--- echo sign_getplaced("a.py", {'group' : 'g1', +--- \ 'id' : 20}) +--- +--- " Get a List of all the placed signs +--- echo sign_getplaced() +--- < +--- +--- @param buf? any +--- @param dict? vim.fn.sign_getplaced.dict +--- @return vim.fn.sign_getplaced.ret.item[] +function vim.fn.sign_getplaced(buf, dict) end + +--- Open the buffer {buf} or jump to the window that contains +--- {buf} and position the cursor at sign {id} in group {group}. +--- This is similar to the |:sign-jump| command. +--- +--- If {group} is an empty string, then the global group is used. +--- For the use of {buf}, see |bufname()|. +--- +--- Returns the line number of the sign. Returns -1 if the +--- arguments are invalid. +--- +--- Example: >vim +--- " Jump to sign 10 in the current buffer +--- call sign_jump(10, '', '') +--- < +--- +--- @param id integer +--- @param group string +--- @param buf integer|string +--- @return integer +function vim.fn.sign_jump(id, group, buf) end + +--- Place the sign defined as {name} at line {lnum} in file or +--- buffer {buf} and assign {id} and {group} to sign. This is +--- similar to the |:sign-place| command. +--- +--- If the sign identifier {id} is zero, then a new identifier is +--- allocated. Otherwise the specified number is used. {group} is +--- the sign group name. To use the global sign group, use an +--- empty string. {group} functions as a namespace for {id}, thus +--- two groups can use the same IDs. Refer to |sign-identifier| +--- and |sign-group| for more information. +--- +--- {name} refers to a defined sign. +--- {buf} refers to a buffer name or number. For the accepted +--- values, see |bufname()|. +--- +--- The optional {dict} argument supports the following entries: +--- lnum line number in the file or buffer +--- {buf} where the sign is to be placed. +--- For the accepted values, see |line()|. +--- priority priority of the sign. See +--- |sign-priority| for more information. +--- +--- If the optional {dict} is not specified, then it modifies the +--- placed sign {id} in group {group} to use the defined sign +--- {name}. +--- +--- Returns the sign identifier on success and -1 on failure. +--- +--- Examples: >vim +--- " Place a sign named sign1 with id 5 at line 20 in +--- " buffer json.c +--- call sign_place(5, '', 'sign1', 'json.c', +--- \ {'lnum' : 20}) +--- +--- " Updates sign 5 in buffer json.c to use sign2 +--- call sign_place(5, '', 'sign2', 'json.c') +--- +--- " Place a sign named sign3 at line 30 in +--- " buffer json.c with a new identifier +--- let id = sign_place(0, '', 'sign3', 'json.c', +--- \ {'lnum' : 30}) +--- +--- " Place a sign named sign4 with id 10 in group 'g3' +--- " at line 40 in buffer json.c with priority 90 +--- call sign_place(10, 'g3', 'sign4', 'json.c', +--- \ {'lnum' : 40, 'priority' : 90}) +--- < +--- +--- @param id any +--- @param group any +--- @param name string +--- @param buf any +--- @param dict? vim.fn.sign_place.dict +--- @return integer +function vim.fn.sign_place(id, group, name, buf, dict) end + +--- Place one or more signs. This is similar to the +--- |sign_place()| function. The {list} argument specifies the +--- List of signs to place. Each list item is a dict with the +--- following sign attributes: +--- buffer Buffer name or number. For the accepted +--- values, see |bufname()|. +--- group Sign group. {group} functions as a namespace +--- for {id}, thus two groups can use the same +--- IDs. If not specified or set to an empty +--- string, then the global group is used. See +--- |sign-group| for more information. +--- id Sign identifier. If not specified or zero, +--- then a new unique identifier is allocated. +--- Otherwise the specified number is used. See +--- |sign-identifier| for more information. +--- lnum Line number in the buffer where the sign is to +--- be placed. For the accepted values, see +--- |line()|. +--- name Name of the sign to place. See |sign_define()| +--- for more information. +--- priority Priority of the sign. When multiple signs are +--- placed on a line, the sign with the highest +--- priority is used. If not specified, the +--- default value of 10 is used. See +--- |sign-priority| for more information. +--- +--- If {id} refers to an existing sign, then the existing sign is +--- modified to use the specified {name} and/or {priority}. +--- +--- Returns a List of sign identifiers. If failed to place a +--- sign, the corresponding list item is set to -1. +--- +--- Examples: >vim +--- " Place sign s1 with id 5 at line 20 and id 10 at line +--- " 30 in buffer a.c +--- let [n1, n2] = sign_placelist([ +--- \ {'id' : 5, +--- \ 'name' : 's1', +--- \ 'buffer' : 'a.c', +--- \ 'lnum' : 20}, +--- \ {'id' : 10, +--- \ 'name' : 's1', +--- \ 'buffer' : 'a.c', +--- \ 'lnum' : 30} +--- \ ]) +--- +--- " Place sign s1 in buffer a.c at line 40 and 50 +--- " with auto-generated identifiers +--- let [n1, n2] = sign_placelist([ +--- \ {'name' : 's1', +--- \ 'buffer' : 'a.c', +--- \ 'lnum' : 40}, +--- \ {'name' : 's1', +--- \ 'buffer' : 'a.c', +--- \ 'lnum' : 50} +--- \ ]) +--- < +--- +--- @param list vim.fn.sign_placelist.list.item[] +--- @return integer[] +function vim.fn.sign_placelist(list) end + +--- @param name? string +--- @return 0|-1 +function vim.fn.sign_undefine(name) end + +--- Deletes a previously defined sign {name}. This is similar to +--- the |:sign-undefine| command. If {name} is not supplied, then +--- deletes all the defined signs. +--- +--- The one argument {list} can be used to undefine a list of +--- signs. Each list item is the name of a sign. +--- +--- Returns 0 on success and -1 on failure. For the one argument +--- {list} call, returns a list of values one for each undefined +--- sign. +--- +--- Examples: >vim +--- " Delete a sign named mySign +--- call sign_undefine("mySign") +--- +--- " Delete signs 'sign1' and 'sign2' +--- call sign_undefine(["sign1", "sign2"]) +--- +--- " Delete all the signs +--- call sign_undefine() +--- < +--- +--- @param list? string[] +--- @return integer[] +function vim.fn.sign_undefine(list) end + +--- Remove a previously placed sign in one or more buffers. This +--- is similar to the |:sign-unplace| command. +--- +--- {group} is the sign group name. To use the global sign group, +--- use an empty string. If {group} is set to "*", then all the +--- groups including the global group are used. +--- The signs in {group} are selected based on the entries in +--- {dict}. The following optional entries in {dict} are +--- supported: +--- buffer buffer name or number. See |bufname()|. +--- id sign identifier +--- If {dict} is not supplied, then all the signs in {group} are +--- removed. +--- +--- Returns 0 on success and -1 on failure. +--- +--- Examples: >vim +--- " Remove sign 10 from buffer a.vim +--- call sign_unplace('', {'buffer' : "a.vim", 'id' : 10}) +--- +--- " Remove sign 20 in group 'g1' from buffer 3 +--- call sign_unplace('g1', {'buffer' : 3, 'id' : 20}) +--- +--- " Remove all the signs in group 'g2' from buffer 10 +--- call sign_unplace('g2', {'buffer' : 10}) +--- +--- " Remove sign 30 in group 'g3' from all the buffers +--- call sign_unplace('g3', {'id' : 30}) +--- +--- " Remove all the signs placed in buffer 5 +--- call sign_unplace('*', {'buffer' : 5}) +--- +--- " Remove the signs in group 'g4' from all the buffers +--- call sign_unplace('g4') +--- +--- " Remove sign 40 from all the buffers +--- call sign_unplace('*', {'id' : 40}) +--- +--- " Remove all the placed signs from all the buffers +--- call sign_unplace('*') +--- +--- @param group string +--- @param dict? vim.fn.sign_unplace.dict +--- @return 0|-1 +function vim.fn.sign_unplace(group, dict) end + +--- Remove previously placed signs from one or more buffers. This +--- is similar to the |sign_unplace()| function. +--- +--- The {list} argument specifies the List of signs to remove. +--- Each list item is a dict with the following sign attributes: +--- buffer buffer name or number. For the accepted +--- values, see |bufname()|. If not specified, +--- then the specified sign is removed from all +--- the buffers. +--- group sign group name. If not specified or set to an +--- empty string, then the global sign group is +--- used. If set to "*", then all the groups +--- including the global group are used. +--- id sign identifier. If not specified, then all +--- the signs in the specified group are removed. +--- +--- Returns a List where an entry is set to 0 if the corresponding +--- sign was successfully removed or -1 on failure. +--- +--- Example: >vim +--- " Remove sign with id 10 from buffer a.vim and sign +--- " with id 20 from buffer b.vim +--- call sign_unplacelist([ +--- \ {'id' : 10, 'buffer' : "a.vim"}, +--- \ {'id' : 20, 'buffer' : 'b.vim'}, +--- \ ]) +--- < +--- +--- @param list vim.fn.sign_unplacelist.list.item +--- @return (0|-1)[] +function vim.fn.sign_unplacelist(list) end + +--- Simplify the file name as much as possible without changing +--- the meaning. Shortcuts (on MS-Windows) or symbolic links (on +--- Unix) are not resolved. If the first path component in +--- {filename} designates the current directory, this will be +--- valid for the result as well. A trailing path separator is +--- not removed either. On Unix "//path" is unchanged, but +--- "///path" is simplified to "/path" (this follows the Posix +--- standard). +--- Example: >vim +--- simplify("./dir/.././/file/") == "./file/" +--- <Note: The combination "dir/.." is only removed if "dir" is +--- a searchable directory or does not exist. On Unix, it is also +--- removed when "dir" is a symbolic link within the same +--- directory. In order to resolve all the involved symbolic +--- links before simplifying the path name, use |resolve()|. +--- +--- @param filename any +--- @return any +function vim.fn.simplify(filename) end + +--- Return the sine of {expr}, measured in radians, as a |Float|. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo sin(100) +--- < -0.506366 >vim +--- echo sin(-4.01) +--- < 0.763301 +--- +--- @param expr any +--- @return any +function vim.fn.sin(expr) end + +--- Return the hyperbolic sine of {expr} as a |Float| in the range +--- [-inf, inf]. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo sinh(0.5) +--- < 0.521095 >vim +--- echo sinh(-0.9) +--- < -1.026517 +--- +--- @param expr any +--- @return any +function vim.fn.sinh(expr) end + +--- Similar to using a |slice| "expr[start : end]", but "end" is +--- used exclusive. And for a string the indexes are used as +--- character indexes instead of byte indexes. +--- Also, composing characters are not counted. +--- When {end} is omitted the slice continues to the last item. +--- When {end} is -1 the last item is omitted. +--- Returns an empty value if {start} or {end} are invalid. +--- +--- @param expr any +--- @param start any +--- @param end_? any +--- @return any +function vim.fn.slice(expr, start, end_) end + +--- Connect a socket to an address. If {mode} is "pipe" then +--- {address} should be the path of a local domain socket (on +--- unix) or named pipe (on Windows). If {mode} is "tcp" then +--- {address} should be of the form "host:port" where the host +--- should be an ip address or host name, and port the port +--- number. +--- +--- For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see +--- |luv-tcp-handle|. +--- +--- Returns a |channel| ID. Close the socket with |chanclose()|. +--- Use |chansend()| to send data over a bytes socket, and +--- |rpcrequest()| and |rpcnotify()| to communicate with a RPC +--- socket. +--- +--- {opts} is an optional dictionary with these keys: +--- |on_data| : callback invoked when data was read from socket +--- data_buffered : read socket data in |channel-buffered| mode. +--- rpc : If set, |msgpack-rpc| will be used to communicate +--- over the socket. +--- Returns: +--- - The channel ID on success (greater than zero) +--- - 0 on invalid arguments or connection failure. +--- +--- @param mode string +--- @param address any +--- @param opts? table +--- @return any +function vim.fn.sockconnect(mode, address, opts) end + +--- Sort the items in {list} in-place. Returns {list}. +--- +--- If you want a list to remain unmodified make a copy first: >vim +--- let sortedlist = sort(copy(mylist)) +--- +--- <When {how} is omitted or is a string, then sort() uses the +--- string representation of each item to sort on. Numbers sort +--- after Strings, |Lists| after Numbers. For sorting text in the +--- current buffer use |:sort|. +--- +--- When {how} is given and it is 'i' then case is ignored. +--- For backwards compatibility, the value one can be used to +--- ignore case. Zero means to not ignore case. +--- +--- When {how} is given and it is 'l' then the current collation +--- locale is used for ordering. Implementation details: strcoll() +--- is used to compare strings. See |:language| check or set the +--- collation locale. |v:collate| can also be used to check the +--- current locale. Sorting using the locale typically ignores +--- case. Example: >vim +--- " ö is sorted similarly to o with English locale. +--- language collate en_US.UTF8 +--- echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l') +--- < ['n', 'o', 'O', 'ö', 'p', 'z'] ~ +--- >vim +--- " ö is sorted after z with Swedish locale. +--- language collate sv_SE.UTF8 +--- echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l') +--- < ['n', 'o', 'O', 'p', 'z', 'ö'] ~ +--- This does not work properly on Mac. +--- +--- When {how} is given and it is 'n' then all items will be +--- sorted numerical (Implementation detail: this uses the +--- strtod() function to parse numbers, Strings, Lists, Dicts and +--- Funcrefs will be considered as being 0). +--- +--- When {how} is given and it is 'N' then all items will be +--- sorted numerical. This is like 'n' but a string containing +--- digits will be used as the number they represent. +--- +--- When {how} is given and it is 'f' then all items will be +--- sorted numerical. All values must be a Number or a Float. +--- +--- When {how} is a |Funcref| or a function name, this function +--- is called to compare items. The function is invoked with two +--- items as argument and must return zero if they are equal, 1 or +--- bigger if the first one sorts after the second one, -1 or +--- smaller if the first one sorts before the second one. +--- +--- {dict} is for functions with the "dict" attribute. It will be +--- used to set the local variable "self". |Dictionary-function| +--- +--- The sort is stable, items which compare equal (as number or as +--- string) will keep their relative position. E.g., when sorting +--- on numbers, text strings will sort next to each other, in the +--- same order as they were originally. +--- +--- +--- Example: >vim +--- func MyCompare(i1, i2) +--- return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1 +--- endfunc +--- eval mylist->sort("MyCompare") +--- <A shorter compare version for this specific simple case, which +--- ignores overflow: >vim +--- func MyCompare(i1, i2) +--- return a:i1 - a:i2 +--- endfunc +--- <For a simple expression you can use a lambda: >vim +--- eval mylist->sort({i1, i2 -> i1 - i2}) +--- < +--- +--- @param list any +--- @param how? any +--- @param dict? any +--- @return any +function vim.fn.sort(list, how, dict) end + +--- Return the sound-folded equivalent of {word}. Uses the first +--- language in 'spelllang' for the current window that supports +--- soundfolding. 'spell' must be set. When no sound folding is +--- possible the {word} is returned unmodified. +--- This can be used for making spelling suggestions. Note that +--- the method can be quite slow. +--- +--- @param word any +--- @return any +function vim.fn.soundfold(word) end + +--- Without argument: The result is the badly spelled word under +--- or after the cursor. The cursor is moved to the start of the +--- bad word. When no bad word is found in the cursor line the +--- result is an empty string and the cursor doesn't move. +--- +--- With argument: The result is the first word in {sentence} that +--- is badly spelled. If there are no spelling mistakes the +--- result is an empty string. +--- +--- The return value is a list with two items: +--- - The badly spelled word or an empty string. +--- - The type of the spelling error: +--- "bad" spelling mistake +--- "rare" rare word +--- "local" word only valid in another region +--- "caps" word should start with Capital +--- Example: >vim +--- echo spellbadword("the quik brown fox") +--- < ['quik', 'bad'] ~ +--- +--- The spelling information for the current window and the value +--- of 'spelllang' are used. +--- +--- @param sentence? any +--- @return any +function vim.fn.spellbadword(sentence) end + +--- Return a |List| with spelling suggestions to replace {word}. +--- When {max} is given up to this number of suggestions are +--- returned. Otherwise up to 25 suggestions are returned. +--- +--- When the {capital} argument is given and it's non-zero only +--- suggestions with a leading capital will be given. Use this +--- after a match with 'spellcapcheck'. +--- +--- {word} can be a badly spelled word followed by other text. +--- This allows for joining two words that were split. The +--- suggestions also include the following text, thus you can +--- replace a line. +--- +--- {word} may also be a good word. Similar words will then be +--- returned. {word} itself is not included in the suggestions, +--- although it may appear capitalized. +--- +--- The spelling information for the current window is used. The +--- values of 'spelllang' and 'spellsuggest' are used. +--- +--- @param word any +--- @param max? any +--- @param capital? any +--- @return any +function vim.fn.spellsuggest(word, max, capital) end + +--- Make a |List| out of {string}. When {pattern} is omitted or +--- empty each white-separated sequence of characters becomes an +--- item. +--- Otherwise the string is split where {pattern} matches, +--- removing the matched characters. 'ignorecase' is not used +--- here, add \c to ignore case. |/\c| +--- When the first or last item is empty it is omitted, unless the +--- {keepempty} argument is given and it's non-zero. +--- Other empty items are kept when {pattern} matches at least one +--- character or when {keepempty} is non-zero. +--- Example: >vim +--- let words = split(getline('.'), '\W\+') +--- <To split a string in individual characters: >vim +--- for c in split(mystring, '\zs') | endfor +--- <If you want to keep the separator you can also use '\zs' at +--- the end of the pattern: >vim +--- echo split('abc:def:ghi', ':\zs') +--- < > +--- ['abc:', 'def:', 'ghi'] +--- < +--- Splitting a table where the first element can be empty: >vim +--- let items = split(line, ':', 1) +--- <The opposite function is |join()|. +--- +--- @param string string +--- @param pattern? any +--- @param keepempty? any +--- @return any +function vim.fn.split(string, pattern, keepempty) end + +--- Return the non-negative square root of Float {expr} as a +--- |Float|. +--- {expr} must evaluate to a |Float| or a |Number|. When {expr} +--- is negative the result is NaN (Not a Number). Returns 0.0 if +--- {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo sqrt(100) +--- < 10.0 >vim +--- echo sqrt(-4.01) +--- < str2float("nan") +--- NaN may be different, it depends on system libraries. +--- +--- @param expr any +--- @return any +function vim.fn.sqrt(expr) end + +--- Initialize seed used by |rand()|: +--- - If {expr} is not given, seed values are initialized by +--- reading from /dev/urandom, if possible, or using time(NULL) +--- a.k.a. epoch time otherwise; this only has second accuracy. +--- - If {expr} is given it must be a Number. It is used to +--- initialize the seed values. This is useful for testing or +--- when a predictable sequence is intended. +--- +--- Examples: >vim +--- let seed = srand() +--- let seed = srand(userinput) +--- echo rand(seed) +--- < +--- +--- @param expr? any +--- @return any +function vim.fn.srand(expr) end + +--- Return a string which contains characters indicating the +--- current state. Mostly useful in callbacks that want to do +--- work that may not always be safe. Roughly this works like: +--- - callback uses state() to check if work is safe to do. +--- Yes: then do it right away. +--- No: add to work queue and add a |SafeState| autocommand. +--- - When SafeState is triggered and executes your autocommand, +--- check with `state()` if the work can be done now, and if yes +--- remove it from the queue and execute. +--- Remove the autocommand if the queue is now empty. +--- Also see |mode()|. +--- +--- When {what} is given only characters in this string will be +--- added. E.g, this checks if the screen has scrolled: >vim +--- if state('s') == '' +--- " screen has not scrolled +--- < +--- These characters indicate the state, generally indicating that +--- something is busy: +--- m halfway a mapping, :normal command, feedkeys() or +--- stuffed command +--- o operator pending, e.g. after |d| +--- a Insert mode autocomplete active +--- x executing an autocommand +--- S not triggering SafeState, e.g. after |f| or a count +--- c callback invoked, including timer (repeats for +--- recursiveness up to "ccc") +--- s screen has scrolled for messages +--- +--- @param what? string +--- @return any +function vim.fn.state(what) end + +--- With |--headless| this opens stdin and stdout as a |channel|. +--- May be called only once. See |channel-stdio|. stderr is not +--- handled by this function, see |v:stderr|. +--- +--- Close the stdio handles with |chanclose()|. Use |chansend()| +--- to send data to stdout, and |rpcrequest()| and |rpcnotify()| +--- to communicate over RPC. +--- +--- {opts} is a dictionary with these keys: +--- |on_stdin| : callback invoked when stdin is written to. +--- on_print : callback invoked when Nvim needs to print a +--- message, with the message (whose type is string) +--- as sole argument. +--- stdin_buffered : read stdin in |channel-buffered| mode. +--- rpc : If set, |msgpack-rpc| will be used to communicate +--- over stdio +--- Returns: +--- - |channel-id| on success (value is always 1) +--- - 0 on invalid arguments +--- +--- @param opts table +--- @return any +function vim.fn.stdioopen(opts) end + +--- Returns |standard-path| locations of various default files and +--- directories. +--- +--- {what} Type Description ~ +--- cache String Cache directory: arbitrary temporary +--- storage for plugins, etc. +--- config String User configuration directory. |init.vim| +--- is stored here. +--- config_dirs List Other configuration directories. +--- data String User data directory. +--- data_dirs List Other data directories. +--- log String Logs directory (for use by plugins too). +--- run String Run directory: temporary, local storage +--- for sockets, named pipes, etc. +--- state String Session state directory: storage for file +--- drafts, swap, undo, |shada|. +--- +--- Example: >vim +--- echo stdpath("config") +--- < +--- +--- @param what 'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state' +--- @return string|string[] +function vim.fn.stdpath(what) end + +--- Convert String {string} to a Float. This mostly works the +--- same as when using a floating point number in an expression, +--- see |floating-point-format|. But it's a bit more permissive. +--- E.g., "1e40" is accepted, while in an expression you need to +--- write "1.0e40". The hexadecimal form "0x123" is also +--- accepted, but not others, like binary or octal. +--- When {quoted} is present and non-zero then embedded single +--- quotes before the dot are ignored, thus "1'000.0" is a +--- thousand. +--- Text after the number is silently ignored. +--- The decimal point is always '.', no matter what the locale is +--- set to. A comma ends the number: "12,345.67" is converted to +--- 12.0. You can strip out thousands separators with +--- |substitute()|: >vim +--- let f = str2float(substitute(text, ',', '', 'g')) +--- < +--- Returns 0.0 if the conversion fails. +--- +--- @param string string +--- @param quoted? any +--- @return any +function vim.fn.str2float(string, quoted) end + +--- Return a list containing the number values which represent +--- each character in String {string}. Examples: >vim +--- echo str2list(" ") " returns [32] +--- echo str2list("ABC") " returns [65, 66, 67] +--- <|list2str()| does the opposite. +--- +--- UTF-8 encoding is always used, {utf8} option has no effect, +--- and exists only for backwards-compatibility. +--- With UTF-8 composing characters are handled properly: >vim +--- echo str2list("á") " returns [97, 769] +--- +--- @param string string +--- @param utf8? any +--- @return any +function vim.fn.str2list(string, utf8) end + +--- Convert string {string} to a number. +--- {base} is the conversion base, it can be 2, 8, 10 or 16. +--- When {quoted} is present and non-zero then embedded single +--- quotes are ignored, thus "1'000'000" is a million. +--- +--- When {base} is omitted base 10 is used. This also means that +--- a leading zero doesn't cause octal conversion to be used, as +--- with the default String to Number conversion. Example: >vim +--- let nr = str2nr('0123') +--- < +--- When {base} is 16 a leading "0x" or "0X" is ignored. With a +--- different base the result will be zero. Similarly, when +--- {base} is 8 a leading "0", "0o" or "0O" is ignored, and when +--- {base} is 2 a leading "0b" or "0B" is ignored. +--- Text after the number is silently ignored. +--- +--- Returns 0 if {string} is empty or on error. +--- +--- @param string string +--- @param base? any +--- @return any +function vim.fn.str2nr(string, base) end + +--- The result is a Number, which is the number of characters +--- in String {string}. Composing characters are ignored. +--- |strchars()| can count the number of characters, counting +--- composing characters separately. +--- +--- Returns 0 if {string} is empty or on error. +--- +--- Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. +--- +--- @param string string +--- @return any +function vim.fn.strcharlen(string) end + +--- Like |strpart()| but using character index and length instead +--- of byte index and length. +--- When {skipcc} is omitted or zero, composing characters are +--- counted separately. +--- When {skipcc} set to 1, Composing characters are ignored, +--- similar to |slice()|. +--- When a character index is used where a character does not +--- exist it is omitted and counted as one character. For +--- example: >vim +--- echo strcharpart('abc', -1, 2) +--- <results in 'a'. +--- +--- Returns an empty string on error. +--- +--- @param src any +--- @param start any +--- @param len? any +--- @param skipcc? any +--- @return any +function vim.fn.strcharpart(src, start, len, skipcc) end + +--- The result is a Number, which is the number of characters +--- in String {string}. +--- When {skipcc} is omitted or zero, composing characters are +--- counted separately. +--- When {skipcc} set to 1, Composing characters are ignored. +--- |strcharlen()| always does this. +--- +--- Returns zero on error. +--- +--- Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. +--- +--- {skipcc} is only available after 7.4.755. For backward +--- compatibility, you can define a wrapper function: >vim +--- if has("patch-7.4.755") +--- function s:strchars(str, skipcc) +--- return strchars(a:str, a:skipcc) +--- endfunction +--- else +--- function s:strchars(str, skipcc) +--- if a:skipcc +--- return strlen(substitute(a:str, ".", "x", "g")) +--- else +--- return strchars(a:str) +--- endif +--- endfunction +--- endif +--- < +--- +--- @param string string +--- @param skipcc? any +--- @return integer +function vim.fn.strchars(string, skipcc) end + +--- The result is a Number, which is the number of display cells +--- String {string} occupies on the screen when it starts at {col} +--- (first column is zero). When {col} is omitted zero is used. +--- Otherwise it is the screen column where to start. This +--- matters for Tab characters. +--- The option settings of the current window are used. This +--- matters for anything that's displayed differently, such as +--- 'tabstop' and 'display'. +--- When {string} contains characters with East Asian Width Class +--- Ambiguous, this function's return value depends on 'ambiwidth'. +--- Returns zero on error. +--- Also see |strlen()|, |strwidth()| and |strchars()|. +--- +--- @param string string +--- @param col? integer +--- @return integer +function vim.fn.strdisplaywidth(string, col) end + +--- The result is a String, which is a formatted date and time, as +--- specified by the {format} string. The given {time} is used, +--- or the current time if no time is given. The accepted +--- {format} depends on your system, thus this is not portable! +--- See the manual page of the C function strftime() for the +--- format. The maximum length of the result is 80 characters. +--- See also |localtime()|, |getftime()| and |strptime()|. +--- The language can be changed with the |:language| command. +--- Examples: >vim +--- echo strftime("%c") " Sun Apr 27 11:49:23 1997 +--- echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25 +--- echo strftime("%y%m%d %T") " 970427 11:53:55 +--- echo strftime("%H:%M") " 11:55 +--- echo strftime("%c", getftime("file.c")) +--- " Show mod time of file.c. +--- +--- @param format any +--- @param time? any +--- @return string +function vim.fn.strftime(format, time) end + +--- Get a Number corresponding to the character at {index} in +--- {str}. This uses a zero-based character index, not a byte +--- index. Composing characters are considered separate +--- characters here. Use |nr2char()| to convert the Number to a +--- String. +--- Returns -1 if {index} is invalid. +--- Also see |strcharpart()| and |strchars()|. +--- +--- @param str string +--- @param index integer +--- @return integer +function vim.fn.strgetchar(str, index) end + +--- The result is a Number, which gives the byte index in +--- {haystack} of the first occurrence of the String {needle}. +--- If {start} is specified, the search starts at index {start}. +--- This can be used to find a second match: >vim +--- let colon1 = stridx(line, ":") +--- let colon2 = stridx(line, ":", colon1 + 1) +--- <The search is done case-sensitive. +--- For pattern searches use |match()|. +--- -1 is returned if the {needle} does not occur in {haystack}. +--- See also |strridx()|. +--- Examples: >vim +--- echo stridx("An Example", "Example") " 3 +--- echo stridx("Starting point", "Start") " 0 +--- echo stridx("Starting point", "start") " -1 +--- < *strstr()* *strchr()* +--- stridx() works similar to the C function strstr(). When used +--- with a single character it works similar to strchr(). +--- +--- @param haystack string +--- @param needle string +--- @param start? integer +--- @return integer +function vim.fn.stridx(haystack, needle, start) end + +--- Return {expr} converted to a String. If {expr} is a Number, +--- Float, String, Blob or a composition of them, then the result +--- can be parsed back with |eval()|. +--- {expr} type result ~ +--- String 'string' +--- Number 123 +--- Float 123.123456 or 1.123456e8 or +--- `str2float('inf')` +--- Funcref `function('name')` +--- Blob 0z00112233.44556677.8899 +--- List [item, item] +--- Dictionary `{key: value, key: value}` +--- Note that in String values the ' character is doubled. +--- Also see |strtrans()|. +--- Note 2: Output format is mostly compatible with YAML, except +--- for infinite and NaN floating-point values representations +--- which use |str2float()|. Strings are also dumped literally, +--- only single quote is escaped, which does not allow using YAML +--- for parsing back binary strings. |eval()| should always work for +--- strings and floats though and this is the only official +--- method, use |msgpackdump()| or |json_encode()| if you need to +--- share data with other application. +--- +--- @param expr any +--- @return string +function vim.fn.string(expr) end + +--- The result is a Number, which is the length of the String +--- {string} in bytes. +--- If the argument is a Number it is first converted to a String. +--- For other types an error is given and zero is returned. +--- If you want to count the number of multibyte characters use +--- |strchars()|. +--- Also see |len()|, |strdisplaywidth()| and |strwidth()|. +--- +--- @param string string +--- @return integer +function vim.fn.strlen(string) end + +--- The result is a String, which is part of {src}, starting from +--- byte {start}, with the byte length {len}. +--- When {chars} is present and TRUE then {len} is the number of +--- characters positions (composing characters are not counted +--- separately, thus "1" means one base character and any +--- following composing characters). +--- To count {start} as characters instead of bytes use +--- |strcharpart()|. +--- +--- When bytes are selected which do not exist, this doesn't +--- result in an error, the bytes are simply omitted. +--- If {len} is missing, the copy continues from {start} till the +--- end of the {src}. >vim +--- echo strpart("abcdefg", 3, 2) " returns 'de' +--- echo strpart("abcdefg", -2, 4) " returns 'ab' +--- echo strpart("abcdefg", 5, 4) " returns 'fg' +--- echo strpart("abcdefg", 3) " returns 'defg' +--- +--- <Note: To get the first character, {start} must be 0. For +--- example, to get the character under the cursor: >vim +--- strpart(getline("."), col(".") - 1, 1, v:true) +--- < +--- Returns an empty string on error. +--- +--- @param src string +--- @param start integer +--- @param len? integer +--- @param chars? 0|1 +--- @return string +function vim.fn.strpart(src, start, len, chars) end + +--- The result is a Number, which is a unix timestamp representing +--- the date and time in {timestring}, which is expected to match +--- the format specified in {format}. +--- +--- The accepted {format} depends on your system, thus this is not +--- portable! See the manual page of the C function strptime() +--- for the format. Especially avoid "%c". The value of $TZ also +--- matters. +--- +--- If the {timestring} cannot be parsed with {format} zero is +--- returned. If you do not know the format of {timestring} you +--- can try different {format} values until you get a non-zero +--- result. +--- +--- See also |strftime()|. +--- Examples: >vim +--- echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23") +--- < 862156163 >vim +--- echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55")) +--- < Sun Apr 27 11:53:55 1997 >vim +--- echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600) +--- < Sun Apr 27 12:53:55 1997 +--- +--- @param format string +--- @param timestring string +--- @return integer +function vim.fn.strptime(format, timestring) end + +--- The result is a Number, which gives the byte index in +--- {haystack} of the last occurrence of the String {needle}. +--- When {start} is specified, matches beyond this index are +--- ignored. This can be used to find a match before a previous +--- match: >vim +--- let lastcomma = strridx(line, ",") +--- let comma2 = strridx(line, ",", lastcomma - 1) +--- <The search is done case-sensitive. +--- For pattern searches use |match()|. +--- -1 is returned if the {needle} does not occur in {haystack}. +--- If the {needle} is empty the length of {haystack} is returned. +--- See also |stridx()|. Examples: >vim +--- echo strridx("an angry armadillo", "an") 3 +--- < *strrchr()* +--- When used with a single character it works similar to the C +--- function strrchr(). +--- +--- @param haystack string +--- @param needle string +--- @param start? integer +--- @return integer +function vim.fn.strridx(haystack, needle, start) end + +--- The result is a String, which is {string} with all unprintable +--- characters translated into printable characters |'isprint'|. +--- Like they are shown in a window. Example: >vim +--- echo strtrans(\@a) +--- <This displays a newline in register a as "^\@" instead of +--- starting a new line. +--- +--- Returns an empty string on error. +--- +--- @param string string +--- @return string +function vim.fn.strtrans(string) end + +--- The result is a Number, which is the number of UTF-16 code +--- units in String {string} (after converting it to UTF-16). +--- +--- When {countcc} is TRUE, composing characters are counted +--- separately. +--- When {countcc} is omitted or FALSE, composing characters are +--- ignored. +--- +--- Returns zero on error. +--- +--- Also see |strlen()| and |strcharlen()|. +--- Examples: >vim +--- echo strutf16len('a') " returns 1 +--- echo strutf16len('©') " returns 1 +--- echo strutf16len('😊') " returns 2 +--- echo strutf16len('ą́') " returns 1 +--- echo strutf16len('ą́', v:true) " returns 3 +--- < +--- +--- @param string string +--- @param countcc? 0|1 +--- @return integer +function vim.fn.strutf16len(string, countcc) end + +--- The result is a Number, which is the number of display cells +--- String {string} occupies. A Tab character is counted as one +--- cell, alternatively use |strdisplaywidth()|. +--- When {string} contains characters with East Asian Width Class +--- Ambiguous, this function's return value depends on 'ambiwidth'. +--- Returns zero on error. +--- Also see |strlen()|, |strdisplaywidth()| and |strchars()|. +--- +--- @param string string +--- @return integer +function vim.fn.strwidth(string) end + +--- Only for an expression in a |:substitute| command or +--- substitute() function. +--- Returns the {nr}th submatch of the matched text. When {nr} +--- is 0 the whole matched text is returned. +--- Note that a NL in the string can stand for a line break of a +--- multi-line match or a NUL character in the text. +--- Also see |sub-replace-expression|. +--- +--- If {list} is present and non-zero then submatch() returns +--- a list of strings, similar to |getline()| with two arguments. +--- NL characters in the text represent NUL characters in the +--- text. +--- Only returns more than one item for |:substitute|, inside +--- |substitute()| this list will always contain one or zero +--- items, since there are no real line breaks. +--- +--- When substitute() is used recursively only the submatches in +--- the current (deepest) call can be obtained. +--- +--- Returns an empty string or list on error. +--- +--- Examples: >vim +--- s/\d\+/\=submatch(0) + 1/ +--- echo substitute(text, '\d\+', '\=submatch(0) + 1', '') +--- <This finds the first number in the line and adds one to it. +--- A line break is included as a newline character. +--- +--- @param nr integer +--- @param list? integer +--- @return string|string[] +function vim.fn.submatch(nr, list) end + +--- The result is a String, which is a copy of {string}, in which +--- the first match of {pat} is replaced with {sub}. +--- When {flags} is "g", all matches of {pat} in {string} are +--- replaced. Otherwise {flags} should be "". +--- +--- This works like the ":substitute" command (without any flags). +--- But the matching with {pat} is always done like the 'magic' +--- option is set and 'cpoptions' is empty (to make scripts +--- portable). 'ignorecase' is still relevant, use |/\c| or |/\C| +--- if you want to ignore or match case and ignore 'ignorecase'. +--- 'smartcase' is not used. See |string-match| for how {pat} is +--- used. +--- +--- A "~" in {sub} is not replaced with the previous {sub}. +--- Note that some codes in {sub} have a special meaning +--- |sub-replace-special|. For example, to replace something with +--- "\n" (two characters), use "\\\\n" or '\\n'. +--- +--- When {pat} does not match in {string}, {string} is returned +--- unmodified. +--- +--- Example: >vim +--- let &path = substitute(&path, ",\\=[^,]*$", "", "") +--- <This removes the last component of the 'path' option. >vim +--- echo substitute("testing", ".*", "\\U\\0", "") +--- <results in "TESTING". +--- +--- When {sub} starts with "\=", the remainder is interpreted as +--- an expression. See |sub-replace-expression|. Example: >vim +--- echo substitute(s, '%\(\x\x\)', +--- \ '\=nr2char("0x" .. submatch(1))', 'g') +--- +--- <When {sub} is a Funcref that function is called, with one +--- optional argument. Example: >vim +--- echo substitute(s, '%\(\x\x\)', SubNr, 'g') +--- <The optional argument is a list which contains the whole +--- matched string and up to nine submatches, like what +--- |submatch()| returns. Example: >vim +--- echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g') +--- +--- <Returns an empty string on error. +--- +--- @param string string +--- @param pat string +--- @param sub string +--- @param flags string +--- @return string +function vim.fn.substitute(string, pat, sub, flags) end + +--- Returns a list of swap file names, like what "vim -r" shows. +--- See the |-r| command argument. The 'directory' option is used +--- for the directories to inspect. If you only want to get a +--- list of swap files in the current directory then temporarily +--- set 'directory' to a dot: >vim +--- let save_dir = &directory +--- let &directory = '.' +--- let swapfiles = swapfilelist() +--- let &directory = save_dir +--- +--- @return string[] +function vim.fn.swapfilelist() end + +--- The result is a dictionary, which holds information about the +--- swapfile {fname}. The available fields are: +--- version Vim version +--- user user name +--- host host name +--- fname original file name +--- pid PID of the Nvim process that created the swap +--- file, or zero if not running. +--- mtime last modification time in seconds +--- inode Optional: INODE number of the file +--- dirty 1 if file was modified, 0 if not +--- In case of failure an "error" item is added with the reason: +--- Cannot open file: file not found or in accessible +--- Cannot read file: cannot read first block +--- Not a swap file: does not contain correct block ID +--- Magic number mismatch: Info in first block is invalid +--- +--- @param fname string +--- @return any +function vim.fn.swapinfo(fname) end + +--- The result is the swap file path of the buffer {buf}. +--- For the use of {buf}, see |bufname()| above. +--- If buffer {buf} is the current buffer, the result is equal to +--- |:swapname| (unless there is no swap file). +--- If buffer {buf} has no swap file, returns an empty string. +--- +--- @param buf integer|string +--- @return string +function vim.fn.swapname(buf) end + +--- The result is a Number, which is the syntax ID at the position +--- {lnum} and {col} in the current window. +--- The syntax ID can be used with |synIDattr()| and +--- |synIDtrans()| to obtain syntax information about text. +--- +--- {col} is 1 for the leftmost column, {lnum} is 1 for the first +--- line. 'synmaxcol' applies, in a longer line zero is returned. +--- Note that when the position is after the last character, +--- that's where the cursor can be in Insert mode, synID() returns +--- zero. {lnum} is used like with |getline()|. +--- +--- When {trans} is |TRUE|, transparent items are reduced to the +--- item that they reveal. This is useful when wanting to know +--- the effective color. When {trans} is |FALSE|, the transparent +--- item is returned. This is useful when wanting to know which +--- syntax item is effective (e.g. inside parens). +--- Warning: This function can be very slow. Best speed is +--- obtained by going through the file in forward direction. +--- +--- Returns zero on error. +--- +--- Example (echoes the name of the syntax item under the cursor): >vim +--- echo synIDattr(synID(line("."), col("."), 1), "name") +--- < +--- +--- @param lnum integer +--- @param col integer +--- @param trans 0|1 +--- @return integer +function vim.fn.synID(lnum, col, trans) end + +--- The result is a String, which is the {what} attribute of +--- syntax ID {synID}. This can be used to obtain information +--- about a syntax item. +--- {mode} can be "gui" or "cterm", to get the attributes +--- for that mode. When {mode} is omitted, or an invalid value is +--- used, the attributes for the currently active highlighting are +--- used (GUI or cterm). +--- Use synIDtrans() to follow linked highlight groups. +--- {what} result +--- "name" the name of the syntax item +--- "fg" foreground color (GUI: color name used to set +--- the color, cterm: color number as a string, +--- term: empty string) +--- "bg" background color (as with "fg") +--- "font" font name (only available in the GUI) +--- |highlight-font| +--- "sp" special color (as with "fg") |guisp| +--- "fg#" like "fg", but for the GUI and the GUI is +--- running the name in "#RRGGBB" form +--- "bg#" like "fg#" for "bg" +--- "sp#" like "fg#" for "sp" +--- "bold" "1" if bold +--- "italic" "1" if italic +--- "reverse" "1" if reverse +--- "inverse" "1" if inverse (= reverse) +--- "standout" "1" if standout +--- "underline" "1" if underlined +--- "undercurl" "1" if undercurled +--- "underdouble" "1" if double underlined +--- "underdotted" "1" if dotted underlined +--- "underdashed" "1" if dashed underlined +--- "strikethrough" "1" if struckthrough +--- "altfont" "1" if alternative font +--- "nocombine" "1" if nocombine +--- +--- Returns an empty string on error. +--- +--- Example (echoes the color of the syntax item under the +--- cursor): >vim +--- echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg") +--- < +--- Can also be used as a |method|: >vim +--- echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg") +--- < +--- +--- @param synID integer +--- @param what string +--- @param mode? string +--- @return string +function vim.fn.synIDattr(synID, what, mode) end + +--- The result is a Number, which is the translated syntax ID of +--- {synID}. This is the syntax group ID of what is being used to +--- highlight the character. Highlight links given with +--- ":highlight link" are followed. +--- +--- Returns zero on error. +--- +--- @param synID integer +--- @return integer +function vim.fn.synIDtrans(synID) end + +--- The result is a |List| with currently three items: +--- 1. The first item in the list is 0 if the character at the +--- position {lnum} and {col} is not part of a concealable +--- region, 1 if it is. {lnum} is used like with |getline()|. +--- 2. The second item in the list is a string. If the first item +--- is 1, the second item contains the text which will be +--- displayed in place of the concealed text, depending on the +--- current setting of 'conceallevel' and 'listchars'. +--- 3. The third and final item in the list is a number +--- representing the specific syntax region matched in the +--- line. When the character is not concealed the value is +--- zero. This allows detection of the beginning of a new +--- concealable region if there are two consecutive regions +--- with the same replacement character. For an example, if +--- the text is "123456" and both "23" and "45" are concealed +--- and replaced by the character "X", then: +--- call returns ~ +--- synconcealed(lnum, 1) [0, '', 0] +--- synconcealed(lnum, 2) [1, 'X', 1] +--- synconcealed(lnum, 3) [1, 'X', 1] +--- synconcealed(lnum, 4) [1, 'X', 2] +--- synconcealed(lnum, 5) [1, 'X', 2] +--- synconcealed(lnum, 6) [0, '', 0] +--- +--- @param lnum integer +--- @param col integer +--- @return {[1]: integer, [2]: string, [3]: integer}[] +function vim.fn.synconcealed(lnum, col) end + +--- Return a |List|, which is the stack of syntax items at the +--- position {lnum} and {col} in the current window. {lnum} is +--- used like with |getline()|. Each item in the List is an ID +--- like what |synID()| returns. +--- The first item in the List is the outer region, following are +--- items contained in that one. The last one is what |synID()| +--- returns, unless not the whole item is highlighted or it is a +--- transparent item. +--- This function is useful for debugging a syntax file. +--- Example that shows the syntax stack under the cursor: >vim +--- for id in synstack(line("."), col(".")) +--- echo synIDattr(id, "name") +--- endfor +--- <When the position specified with {lnum} and {col} is invalid +--- an empty list is returned. The position just after the last +--- character in a line and the first column in an empty line are +--- valid positions. +--- +--- @param lnum integer +--- @param col integer +--- @return integer[] +function vim.fn.synstack(lnum, col) end + +--- Note: Prefer |vim.system()| in Lua. +--- +--- Gets the output of {cmd} as a |string| (|systemlist()| returns +--- a |List|) and sets |v:shell_error| to the error code. +--- {cmd} is treated as in |jobstart()|: +--- If {cmd} is a List it runs directly (no 'shell'). +--- If {cmd} is a String it runs in the 'shell', like this: >vim +--- call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) +--- +--- <Not to be used for interactive commands. +--- +--- Result is a String, filtered to avoid platform-specific quirks: +--- - <CR><NL> is replaced with <NL> +--- - NUL characters are replaced with SOH (0x01) +--- +--- Example: >vim +--- echo system(['ls', expand('%:h')]) +--- +--- <If {input} is a string it is written to a pipe and passed as +--- stdin to the command. The string is written as-is, line +--- separators are not changed. +--- If {input} is a |List| it is written to the pipe as +--- |writefile()| does with {binary} set to "b" (i.e. with +--- a newline between each list item, and newlines inside list +--- items converted to NULs). +--- When {input} is given and is a valid buffer id, the content of +--- the buffer is written to the file line by line, each line +--- terminated by NL (and NUL where the text has NL). +--- *E5677* +--- Note: system() cannot write to or read from backgrounded ("&") +--- shell commands, e.g.: >vim +--- echo system("cat - &", "foo") +--- <which is equivalent to: > +--- $ echo foo | bash -c 'cat - &' +--- <The pipes are disconnected (unless overridden by shell +--- redirection syntax) before input can reach it. Use +--- |jobstart()| instead. +--- +--- Note: Use |shellescape()| or |::S| with |expand()| or +--- |fnamemodify()| to escape special characters in a command +--- argument. 'shellquote' and 'shellxquote' must be properly +--- configured. Example: >vim +--- echo system('ls '..shellescape(expand('%:h'))) +--- echo system('ls '..expand('%:h:S')) +--- +--- <Unlike ":!cmd" there is no automatic check for changed files. +--- Use |:checktime| to force a check. +--- +--- @param cmd string|string[] +--- @param input? string|string[]|integer +--- @return string +function vim.fn.system(cmd, input) end + +--- Same as |system()|, but returns a |List| with lines (parts of +--- output separated by NL) with NULs transformed into NLs. Output +--- is the same as |readfile()| will output with {binary} argument +--- set to "b", except that a final newline is not preserved, +--- unless {keepempty} is non-zero. +--- Note that on MS-Windows you may get trailing CR characters. +--- +--- To see the difference between "echo hello" and "echo -n hello" +--- use |system()| and |split()|: >vim +--- echo split(system('echo hello'), '\n', 1) +--- < +--- Returns an empty string on error. +--- +--- @param cmd string|string[] +--- @param input? string|string[]|integer +--- @param keepempty? integer +--- @return string[] +function vim.fn.systemlist(cmd, input, keepempty) end + +--- The result is a |List|, where each item is the number of the +--- buffer associated with each window in the current tab page. +--- {arg} specifies the number of the tab page to be used. When +--- omitted the current tab page is used. +--- When {arg} is invalid the number zero is returned. +--- To get a list of all buffers in all tabs use this: >vim +--- let buflist = [] +--- for i in range(tabpagenr('$')) +--- call extend(buflist, tabpagebuflist(i + 1)) +--- endfor +--- <Note that a buffer may appear in more than one window. +--- +--- @param arg? any +--- @return any +function vim.fn.tabpagebuflist(arg) end + +--- The result is a Number, which is the number of the current +--- tab page. The first tab page has number 1. +--- +--- The optional argument {arg} supports the following values: +--- $ the number of the last tab page (the tab page +--- count). +--- # the number of the last accessed tab page +--- (where |g<Tab>| goes to). If there is no +--- previous tab page, 0 is returned. +--- The number can be used with the |:tab| command. +--- +--- Returns zero on error. +--- +--- @param arg? '$'|'#' +--- @return integer +function vim.fn.tabpagenr(arg) end + +--- Like |winnr()| but for tab page {tabarg}. +--- {tabarg} specifies the number of tab page to be used. +--- {arg} is used like with |winnr()|: +--- - When omitted the current window number is returned. This is +--- the window which will be used when going to this tab page. +--- - When "$" the number of windows is returned. +--- - When "#" the previous window nr is returned. +--- Useful examples: >vim +--- tabpagewinnr(1) " current window of tab page 1 +--- tabpagewinnr(4, '$') " number of windows in tab page 4 +--- <When {tabarg} is invalid zero is returned. +--- +--- @param tabarg integer +--- @param arg? '$'|'#' +--- @return integer +function vim.fn.tabpagewinnr(tabarg, arg) end + +--- Returns a |List| with the file names used to search for tags +--- for the current buffer. This is the 'tags' option expanded. +--- +--- @return string[] +function vim.fn.tagfiles() end + +--- Returns a |List| of tags matching the regular expression {expr}. +--- +--- If {filename} is passed it is used to prioritize the results +--- in the same way that |:tselect| does. See |tag-priority|. +--- {filename} should be the full path of the file. +--- +--- Each list item is a dictionary with at least the following +--- entries: +--- name Name of the tag. +--- filename Name of the file where the tag is +--- defined. It is either relative to the +--- current directory or a full path. +--- cmd Ex command used to locate the tag in +--- the file. +--- kind Type of the tag. The value for this +--- entry depends on the language specific +--- kind values. Only available when +--- using a tags file generated by +--- Universal/Exuberant ctags or hdrtag. +--- static A file specific tag. Refer to +--- |static-tag| for more information. +--- More entries may be present, depending on the content of the +--- tags file: access, implementation, inherits and signature. +--- Refer to the ctags documentation for information about these +--- fields. For C code the fields "struct", "class" and "enum" +--- may appear, they give the name of the entity the tag is +--- contained in. +--- +--- The ex-command "cmd" can be either an ex search pattern, a +--- line number or a line number followed by a byte number. +--- +--- If there are no matching tags, then an empty list is returned. +--- +--- To get an exact tag match, the anchors '^' and '$' should be +--- used in {expr}. This also make the function work faster. +--- Refer to |tag-regexp| for more information about the tag +--- search regular expression pattern. +--- +--- Refer to |'tags'| for information about how the tags file is +--- located by Vim. Refer to |tags-file-format| for the format of +--- the tags file generated by the different ctags tools. +--- +--- @param expr any +--- @param filename? string +--- @return any +function vim.fn.taglist(expr, filename) end + +--- Return the tangent of {expr}, measured in radians, as a |Float| +--- in the range [-inf, inf]. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo tan(10) +--- < 0.648361 >vim +--- echo tan(-4.01) +--- < -1.181502 +--- +--- @param expr number +--- @return number +function vim.fn.tan(expr) end + +--- Return the hyperbolic tangent of {expr} as a |Float| in the +--- range [-1, 1]. +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo tanh(0.5) +--- < 0.462117 >vim +--- echo tanh(-1) +--- < -0.761594 +--- +--- @param expr number +--- @return number +function vim.fn.tanh(expr) end + +--- Generates a (non-existent) filename located in the Nvim root +--- |tempdir|. Scripts can use the filename as a temporary file. +--- Example: >vim +--- let tmpfile = tempname() +--- exe "redir > " .. tmpfile +--- < +--- +--- @return string +function vim.fn.tempname() end + +--- Spawns {cmd} in a new pseudo-terminal session connected +--- to the current (unmodified) buffer. Parameters and behavior +--- are the same as |jobstart()| except "pty", "width", "height", +--- and "TERM" are ignored: "height" and "width" are taken from +--- the current window. Note that termopen() implies a "pty" arg +--- to jobstart(), and thus has the implications documented at +--- |jobstart()|. +--- +--- Returns the same values as jobstart(). +--- +--- Terminal environment is initialized as in |jobstart-env|, +--- except $TERM is set to "xterm-256color". Full behavior is +--- described in |terminal|. +--- +--- @param cmd any +--- @param opts? table +--- @return any +function vim.fn.termopen(cmd, opts) end + +--- Return a list with information about timers. +--- When {id} is given only information about this timer is +--- returned. When timer {id} does not exist an empty list is +--- returned. +--- When {id} is omitted information about all timers is returned. +--- +--- For each timer the information is stored in a |Dictionary| with +--- these items: +--- "id" the timer ID +--- "time" time the timer was started with +--- "repeat" number of times the timer will still fire; +--- -1 means forever +--- "callback" the callback +--- +--- @param id? any +--- @return any +function vim.fn.timer_info(id) end + +--- Pause or unpause a timer. A paused timer does not invoke its +--- callback when its time expires. Unpausing a timer may cause +--- the callback to be invoked almost immediately if enough time +--- has passed. +--- +--- Pausing a timer is useful to avoid the callback to be called +--- for a short time. +--- +--- If {paused} evaluates to a non-zero Number or a non-empty +--- String, then the timer is paused, otherwise it is unpaused. +--- See |non-zero-arg|. +--- +--- @param timer any +--- @param paused any +--- @return any +function vim.fn.timer_pause(timer, paused) end + +--- Create a timer and return the timer ID. +--- +--- {time} is the waiting time in milliseconds. This is the +--- minimum time before invoking the callback. When the system is +--- busy or Vim is not waiting for input the time will be longer. +--- Zero can be used to execute the callback when Vim is back in +--- the main loop. +--- +--- {callback} is the function to call. It can be the name of a +--- function or a |Funcref|. It is called with one argument, which +--- is the timer ID. The callback is only invoked when Vim is +--- waiting for input. +--- +--- {options} is a dictionary. Supported entries: +--- "repeat" Number of times to repeat the callback. +--- -1 means forever. Default is 1. +--- If the timer causes an error three times in a +--- row the repeat is cancelled. +--- +--- Returns -1 on error. +--- +--- Example: >vim +--- func MyHandler(timer) +--- echo 'Handler called' +--- endfunc +--- let timer = timer_start(500, 'MyHandler', +--- \ {'repeat': 3}) +--- <This invokes MyHandler() three times at 500 msec intervals. +--- +--- @param time any +--- @param callback any +--- @param options? table +--- @return any +function vim.fn.timer_start(time, callback, options) end + +--- Stop a timer. The timer callback will no longer be invoked. +--- {timer} is an ID returned by timer_start(), thus it must be a +--- Number. If {timer} does not exist there is no error. +--- +--- @param timer any +--- @return any +function vim.fn.timer_stop(timer) end + +--- Stop all timers. The timer callbacks will no longer be +--- invoked. Useful if some timers is misbehaving. If there are +--- no timers there is no error. +--- +--- @return any +function vim.fn.timer_stopall() end + +--- The result is a copy of the String given, with all uppercase +--- characters turned into lowercase (just like applying |gu| to +--- the string). Returns an empty string on error. +--- +--- @param expr any +--- @return string +function vim.fn.tolower(expr) end + +--- The result is a copy of the String given, with all lowercase +--- characters turned into uppercase (just like applying |gU| to +--- the string). Returns an empty string on error. +--- +--- @param expr any +--- @return string +function vim.fn.toupper(expr) end + +--- The result is a copy of the {src} string with all characters +--- which appear in {fromstr} replaced by the character in that +--- position in the {tostr} string. Thus the first character in +--- {fromstr} is translated into the first character in {tostr} +--- and so on. Exactly like the unix "tr" command. +--- This code also deals with multibyte characters properly. +--- +--- Returns an empty string on error. +--- +--- Examples: >vim +--- echo tr("hello there", "ht", "HT") +--- <returns "Hello THere" >vim +--- echo tr("<blob>", "<>", "{}") +--- <returns "{blob}" +--- +--- @param src string +--- @param fromstr string +--- @param tostr string +--- @return string +function vim.fn.tr(src, fromstr, tostr) end + +--- Return {text} as a String where any character in {mask} is +--- removed from the beginning and/or end of {text}. +--- +--- If {mask} is not given, or is an empty string, {mask} is all +--- characters up to 0x20, which includes Tab, space, NL and CR, +--- plus the non-breaking space character 0xa0. +--- +--- The optional {dir} argument specifies where to remove the +--- characters: +--- 0 remove from the beginning and end of {text} +--- 1 remove only at the beginning of {text} +--- 2 remove only at the end of {text} +--- When omitted both ends are trimmed. +--- +--- This function deals with multibyte characters properly. +--- Returns an empty string on error. +--- +--- Examples: >vim +--- echo trim(" some text ") +--- <returns "some text" >vim +--- echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL" +--- <returns "RESERVE_TAIL" >vim +--- echo trim("rm<Xrm<>X>rrm", "rm<>") +--- <returns "Xrm<>X" (characters in the middle are not removed) >vim +--- echo trim(" vim ", " ", 2) +--- <returns " vim" +--- +--- @param text any +--- @param mask? string +--- @param dir? 0|1|2 +--- @return string +function vim.fn.trim(text, mask, dir) end + +--- Return the largest integral value with magnitude less than or +--- equal to {expr} as a |Float| (truncate towards zero). +--- {expr} must evaluate to a |Float| or a |Number|. +--- Returns 0.0 if {expr} is not a |Float| or a |Number|. +--- Examples: >vim +--- echo trunc(1.456) +--- < 1.0 >vim +--- echo trunc(-5.456) +--- < -5.0 >vim +--- echo trunc(4.0) +--- < 4.0 +--- +--- @param expr any +--- @return integer +function vim.fn.trunc(expr) end + +--- The result is a Number representing the type of {expr}. +--- Instead of using the number directly, it is better to use the +--- v:t_ variable that has the value: +--- Number: 0 |v:t_number| +--- String: 1 |v:t_string| +--- Funcref: 2 |v:t_func| +--- List: 3 |v:t_list| +--- Dictionary: 4 |v:t_dict| +--- Float: 5 |v:t_float| +--- Boolean: 6 |v:t_bool| (|v:false| and |v:true|) +--- Null: 7 (|v:null|) +--- Blob: 10 |v:t_blob| +--- For backward compatibility, this method can be used: >vim +--- if type(myvar) == type(0) | endif +--- if type(myvar) == type("") | endif +--- if type(myvar) == type(function("tr")) | endif +--- if type(myvar) == type([]) | endif +--- if type(myvar) == type({}) | endif +--- if type(myvar) == type(0.0) | endif +--- if type(myvar) == type(v:true) | endif +--- <In place of checking for |v:null| type it is better to check +--- for |v:null| directly as it is the only value of this type: >vim +--- if myvar is v:null | endif +--- <To check if the v:t_ variables exist use this: >vim +--- if exists('v:t_number') | endif +--- +--- @param expr any +--- @return integer +function vim.fn.type(expr) end + +--- Return the name of the undo file that would be used for a file +--- with name {name} when writing. This uses the 'undodir' +--- option, finding directories that exist. It does not check if +--- the undo file exists. +--- {name} is always expanded to the full path, since that is what +--- is used internally. +--- If {name} is empty undofile() returns an empty string, since a +--- buffer without a file name will not write an undo file. +--- Useful in combination with |:wundo| and |:rundo|. +--- +--- @param name string +--- @return string +function vim.fn.undofile(name) end + +--- Return the current state of the undo tree for the current +--- buffer, or for a specific buffer if {buf} is given. The +--- result is a dictionary with the following items: +--- "seq_last" The highest undo sequence number used. +--- "seq_cur" The sequence number of the current position in +--- the undo tree. This differs from "seq_last" +--- when some changes were undone. +--- "time_cur" Time last used for |:earlier| and related +--- commands. Use |strftime()| to convert to +--- something readable. +--- "save_last" Number of the last file write. Zero when no +--- write yet. +--- "save_cur" Number of the current position in the undo +--- tree. +--- "synced" Non-zero when the last undo block was synced. +--- This happens when waiting from input from the +--- user. See |undo-blocks|. +--- "entries" A list of dictionaries with information about +--- undo blocks. +--- +--- The first item in the "entries" list is the oldest undo item. +--- Each List item is a |Dictionary| with these items: +--- "seq" Undo sequence number. Same as what appears in +--- |:undolist|. +--- "time" Timestamp when the change happened. Use +--- |strftime()| to convert to something readable. +--- "newhead" Only appears in the item that is the last one +--- that was added. This marks the last change +--- and where further changes will be added. +--- "curhead" Only appears in the item that is the last one +--- that was undone. This marks the current +--- position in the undo tree, the block that will +--- be used by a redo command. When nothing was +--- undone after the last change this item will +--- not appear anywhere. +--- "save" Only appears on the last block before a file +--- write. The number is the write count. The +--- first write has number 1, the last one the +--- "save_last" mentioned above. +--- "alt" Alternate entry. This is again a List of undo +--- blocks. Each item may again have an "alt" +--- item. +--- +--- @param buf? integer|string +--- @return any +function vim.fn.undotree(buf) end + +--- Remove second and succeeding copies of repeated adjacent +--- {list} items in-place. Returns {list}. If you want a list +--- to remain unmodified make a copy first: >vim +--- let newlist = uniq(copy(mylist)) +--- <The default compare function uses the string representation of +--- each item. For the use of {func} and {dict} see |sort()|. +--- +--- Returns zero if {list} is not a |List|. +--- +--- @param list any +--- @param func? any +--- @param dict? any +--- @return any[]|0 +function vim.fn.uniq(list, func, dict) end + +--- Same as |charidx()| but returns the UTF-16 code unit index of +--- the byte at {idx} in {string} (after converting it to UTF-16). +--- +--- When {charidx} is present and TRUE, {idx} is used as the +--- character index in the String {string} instead of as the byte +--- index. +--- An {idx} in the middle of a UTF-8 sequence is rounded +--- downwards to the beginning of that sequence. +--- +--- Returns -1 if the arguments are invalid or if there are less +--- than {idx} bytes in {string}. If there are exactly {idx} bytes +--- the length of the string in UTF-16 code units is returned. +--- +--- See |byteidx()| and |byteidxcomp()| for getting the byte index +--- from the UTF-16 index and |charidx()| for getting the +--- character index from the UTF-16 index. +--- Refer to |string-offset-encoding| for more information. +--- Examples: >vim +--- echo utf16idx('a😊😊', 3) " returns 2 +--- echo utf16idx('a😊😊', 7) " returns 4 +--- echo utf16idx('a😊😊', 1, 0, 1) " returns 2 +--- echo utf16idx('a😊😊', 2, 0, 1) " returns 4 +--- echo utf16idx('aą́c', 6) " returns 2 +--- echo utf16idx('aą́c', 6, 1) " returns 4 +--- echo utf16idx('a😊😊', 9) " returns -1 +--- < +--- +--- @param string string +--- @param idx integer +--- @param countcc? any +--- @param charidx? any +--- @return integer +function vim.fn.utf16idx(string, idx, countcc, charidx) end + +--- Return a |List| with all the values of {dict}. The |List| is +--- in arbitrary order. Also see |items()| and |keys()|. +--- Returns zero if {dict} is not a |Dict|. +--- +--- @param dict any +--- @return any +function vim.fn.values(dict) end + +--- The result is a Number, which is the screen column of the file +--- position given with {expr}. That is, the last screen position +--- occupied by the character at that position, when the screen +--- would be of unlimited width. When there is a <Tab> at the +--- position, the returned Number will be the column at the end of +--- the <Tab>. For example, for a <Tab> in column 1, with 'ts' +--- set to 8, it returns 8. |conceal| is ignored. +--- For the byte position use |col()|. +--- +--- For the use of {expr} see |col()|. +--- +--- When 'virtualedit' is used {expr} can be [lnum, col, off], +--- where "off" is the offset in screen columns from the start of +--- the character. E.g., a position within a <Tab> or after the +--- last character. When "off" is omitted zero is used. When +--- Virtual editing is active in the current mode, a position +--- beyond the end of the line can be returned. Also see +--- |'virtualedit'| +--- +--- The accepted positions are: +--- . the cursor position +--- $ the end of the cursor line (the result is the +--- number of displayed characters in the cursor line +--- plus one) +--- 'x position of mark x (if the mark is not set, 0 is +--- returned) +--- v In Visual mode: the start of the Visual area (the +--- cursor is the end). When not in Visual mode +--- returns the cursor position. Differs from |'<| in +--- that it's updated right away. +--- +--- If {list} is present and non-zero then virtcol() returns a +--- List with the first and last screen position occupied by the +--- character. +--- +--- With the optional {winid} argument the values are obtained for +--- that window instead of the current window. +--- +--- Note that only marks in the current file can be used. +--- Examples: >vim +--- " With text "foo^Lbar" and cursor on the "^L": +--- +--- echo virtcol(".") " returns 5 +--- echo virtcol(".", 1) " returns [4, 5] +--- echo virtcol("$") " returns 9 +--- +--- " With text " there", with 't at 'h': +--- +--- echo virtcol("'t") " returns 6 +--- <The first column is 1. 0 or [0, 0] is returned for an error. +--- A more advanced example that echoes the maximum length of +--- all lines: >vim +--- echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) +--- +--- @param expr any +--- @param list? any +--- @param winid? integer +--- @return any +function vim.fn.virtcol(expr, list, winid) end + +--- The result is a Number, which is the byte index of the +--- character in window {winid} at buffer line {lnum} and virtual +--- column {col}. +--- +--- If buffer line {lnum} is an empty line, 0 is returned. +--- +--- If {col} is greater than the last virtual column in line +--- {lnum}, then the byte index of the character at the last +--- virtual column is returned. +--- +--- For a multi-byte character, the column number of the first +--- byte in the character is returned. +--- +--- The {winid} argument can be the window number or the +--- |window-ID|. If this is zero, then the current window is used. +--- +--- Returns -1 if the window {winid} doesn't exist or the buffer +--- line {lnum} or virtual column {col} is invalid. +--- +--- See also |screenpos()|, |virtcol()| and |col()|. +--- +--- @param winid integer +--- @param lnum integer +--- @param col integer +--- @return any +function vim.fn.virtcol2col(winid, lnum, col) end + +--- The result is a String, which describes the last Visual mode +--- used in the current buffer. Initially it returns an empty +--- string, but once Visual mode has been used, it returns "v", +--- "V", or "<CTRL-V>" (a single CTRL-V character) for +--- character-wise, line-wise, or block-wise Visual mode +--- respectively. +--- Example: >vim +--- exe "normal " .. visualmode() +--- <This enters the same Visual mode as before. It is also useful +--- in scripts if you wish to act differently depending on the +--- Visual mode that was used. +--- If Visual mode is active, use |mode()| to get the Visual mode +--- (e.g., in a |:vmap|). +--- If {expr} is supplied and it evaluates to a non-zero Number or +--- a non-empty String, then the Visual mode will be cleared and +--- the old value is returned. See |non-zero-arg|. +--- +--- @param expr? any +--- @return any +function vim.fn.visualmode(expr) end + +--- Waits until {condition} evaluates to |TRUE|, where {condition} +--- is a |Funcref| or |string| containing an expression. +--- +--- {timeout} is the maximum waiting time in milliseconds, -1 +--- means forever. +--- +--- Condition is evaluated on user events, internal events, and +--- every {interval} milliseconds (default: 200). +--- +--- Returns a status integer: +--- 0 if the condition was satisfied before timeout +--- -1 if the timeout was exceeded +--- -2 if the function was interrupted (by |CTRL-C|) +--- -3 if an error occurred +--- +--- @param timeout integer +--- @param condition any +--- @param interval? any +--- @return any +function vim.fn.wait(timeout, condition, interval) end + +--- Returns |TRUE| when the wildmenu is active and |FALSE| +--- otherwise. See 'wildmenu' and 'wildmode'. +--- This can be used in mappings to handle the 'wildcharm' option +--- gracefully. (Makes only sense with |mapmode-c| mappings). +--- +--- For example to make <c-j> work like <down> in wildmode, use: >vim +--- cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>" +--- < +--- (Note, this needs the 'wildcharm' option set appropriately). +--- +--- @return any +function vim.fn.wildmenumode() end + +--- Like `execute()` but in the context of window {id}. +--- The window will temporarily be made the current window, +--- without triggering autocommands or changing directory. When +--- executing {command} autocommands will be triggered, this may +--- have unexpected side effects. Use `:noautocmd` if needed. +--- Example: >vim +--- call win_execute(winid, 'syntax enable') +--- <Doing the same with `setwinvar()` would not trigger +--- autocommands and not actually show syntax highlighting. +--- +--- When window {id} does not exist then no error is given and +--- an empty string is returned. +--- +--- @param id any +--- @param command any +--- @param silent? boolean +--- @return any +function vim.fn.win_execute(id, command, silent) end + +--- Returns a |List| with |window-ID|s for windows that contain +--- buffer {bufnr}. When there is none the list is empty. +--- +--- @param bufnr any +--- @return integer[] +function vim.fn.win_findbuf(bufnr) end + +--- Get the |window-ID| for the specified window. +--- When {win} is missing use the current window. +--- With {win} this is the window number. The top window has +--- number 1. +--- Without {tab} use the current tab, otherwise the tab with +--- number {tab}. The first tab has number one. +--- Return zero if the window cannot be found. +--- +--- @param win? any +--- @param tab? any +--- @return integer +function vim.fn.win_getid(win, tab) end + +--- Return the type of the window: +--- "autocmd" autocommand window. Temporary window +--- used to execute autocommands. +--- "command" command-line window |cmdwin| +--- (empty) normal window +--- "loclist" |location-list-window| +--- "popup" floating window |api-floatwin| +--- "preview" preview window |preview-window| +--- "quickfix" |quickfix-window| +--- "unknown" window {nr} not found +--- +--- When {nr} is omitted return the type of the current window. +--- When {nr} is given return the type of this window by number or +--- |window-ID|. +--- +--- Also see the 'buftype' option. +--- +--- @param nr? integer +--- @return 'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown' +function vim.fn.win_gettype(nr) end + +--- Go to window with ID {expr}. This may also change the current +--- tabpage. +--- Return TRUE if successful, FALSE if the window cannot be found. +--- +--- @param expr any +--- @return 0|1 +function vim.fn.win_gotoid(expr) end + +--- Return a list with the tab number and window number of window +--- with ID {expr}: [tabnr, winnr]. +--- Return [0, 0] if the window cannot be found. +--- +--- @param expr any +--- @return any +function vim.fn.win_id2tabwin(expr) end + +--- Return the window number of window with ID {expr}. +--- Return 0 if the window cannot be found in the current tabpage. +--- +--- @param expr any +--- @return any +function vim.fn.win_id2win(expr) end + +--- Move window {nr}'s vertical separator (i.e., the right border) +--- by {offset} columns, as if being dragged by the mouse. {nr} +--- can be a window number or |window-ID|. A positive {offset} +--- moves right and a negative {offset} moves left. Moving a +--- window's vertical separator will change the width of the +--- window and the width of other windows adjacent to the vertical +--- separator. The magnitude of movement may be smaller than +--- specified (e.g., as a consequence of maintaining +--- 'winminwidth'). Returns TRUE if the window can be found and +--- FALSE otherwise. +--- This will fail for the rightmost window and a full-width +--- window, since it has no separator on the right. +--- Only works for the current tab page. *E1308* +--- +--- @param nr integer +--- @param offset any +--- @return any +function vim.fn.win_move_separator(nr, offset) end + +--- Move window {nr}'s status line (i.e., the bottom border) by +--- {offset} rows, as if being dragged by the mouse. {nr} can be a +--- window number or |window-ID|. A positive {offset} moves down +--- and a negative {offset} moves up. Moving a window's status +--- line will change the height of the window and the height of +--- other windows adjacent to the status line. The magnitude of +--- movement may be smaller than specified (e.g., as a consequence +--- of maintaining 'winminheight'). Returns TRUE if the window can +--- be found and FALSE otherwise. +--- Only works for the current tab page. +--- +--- @param nr integer +--- @param offset any +--- @return any +function vim.fn.win_move_statusline(nr, offset) end + +--- Return the screen position of window {nr} as a list with two +--- numbers: [row, col]. The first window always has position +--- [1, 1], unless there is a tabline, then it is [2, 1]. +--- {nr} can be the window number or the |window-ID|. Use zero +--- for the current window. +--- Returns [0, 0] if the window cannot be found in the current +--- tabpage. +--- +--- @param nr integer +--- @return any +function vim.fn.win_screenpos(nr) end + +--- Move the window {nr} to a new split of the window {target}. +--- This is similar to moving to {target}, creating a new window +--- using |:split| but having the same contents as window {nr}, and +--- then closing {nr}. +--- +--- Both {nr} and {target} can be window numbers or |window-ID|s. +--- Both must be in the current tab page. +--- +--- Returns zero for success, non-zero for failure. +--- +--- {options} is a |Dictionary| with the following optional entries: +--- "vertical" When TRUE, the split is created vertically, +--- like with |:vsplit|. +--- "rightbelow" When TRUE, the split is made below or to the +--- right (if vertical). When FALSE, it is done +--- above or to the left (if vertical). When not +--- present, the values of 'splitbelow' and +--- 'splitright' are used. +--- +--- @param nr integer +--- @param target any +--- @param options? table +--- @return any +function vim.fn.win_splitmove(nr, target, options) end + +--- The result is a Number, which is the number of the buffer +--- associated with window {nr}. {nr} can be the window number or +--- the |window-ID|. +--- When {nr} is zero, the number of the buffer in the current +--- window is returned. +--- When window {nr} doesn't exist, -1 is returned. +--- Example: >vim +--- echo "The file in the current window is " .. bufname(winbufnr(0)) +--- < +--- +--- @param nr integer +--- @return integer +function vim.fn.winbufnr(nr) end + +--- The result is a Number, which is the virtual column of the +--- cursor in the window. This is counting screen cells from the +--- left side of the window. The leftmost column is one. +--- +--- @return integer +function vim.fn.wincol() end + +--- The result is a String. For MS-Windows it indicates the OS +--- version. E.g, Windows 10 is "10.0", Windows 8 is "6.2", +--- Windows XP is "5.1". For non-MS-Windows systems the result is +--- an empty string. +--- +--- @return string +function vim.fn.windowsversion() end + +--- The result is a Number, which is the height of window {nr}. +--- {nr} can be the window number or the |window-ID|. +--- When {nr} is zero, the height of the current window is +--- returned. When window {nr} doesn't exist, -1 is returned. +--- An existing window always has a height of zero or more. +--- This excludes any window toolbar line. +--- Examples: >vim +--- echo "The current window has " .. winheight(0) .. " lines." +--- +--- @param nr integer +--- @return integer +function vim.fn.winheight(nr) end + +--- The result is a nested List containing the layout of windows +--- in a tabpage. +--- +--- Without {tabnr} use the current tabpage, otherwise the tabpage +--- with number {tabnr}. If the tabpage {tabnr} is not found, +--- returns an empty list. +--- +--- For a leaf window, it returns: > +--- ["leaf", {winid}] +--- < +--- For horizontally split windows, which form a column, it +--- returns: > +--- ["col", [{nested list of windows}]] +--- <For vertically split windows, which form a row, it returns: > +--- ["row", [{nested list of windows}]] +--- < +--- Example: >vim +--- " Only one window in the tab page +--- echo winlayout() +--- < > +--- ['leaf', 1000] +--- < >vim +--- " Two horizontally split windows +--- echo winlayout() +--- < > +--- ['col', [['leaf', 1000], ['leaf', 1001]]] +--- < >vim +--- " The second tab page, with three horizontally split +--- " windows, with two vertically split windows in the +--- " middle window +--- echo winlayout(2) +--- < > +--- ['col', [['leaf', 1002], ['row', [['leaf', 1003], +--- ['leaf', 1001]]], ['leaf', 1000]]] +--- < +--- +--- @param tabnr? integer +--- @return any +function vim.fn.winlayout(tabnr) end + +--- The result is a Number, which is the screen line of the cursor +--- in the window. This is counting screen lines from the top of +--- the window. The first line is one. +--- If the cursor was moved the view on the file will be updated +--- first, this may cause a scroll. +--- +--- @return integer +function vim.fn.winline() end + +--- The result is a Number, which is the number of the current +--- window. The top window has number 1. +--- Returns zero for a popup window. +--- +--- The optional argument {arg} supports the following values: +--- $ the number of the last window (the window +--- count). +--- # the number of the last accessed window (where +--- |CTRL-W_p| goes to). If there is no previous +--- window or it is in another tab page 0 is +--- returned. +--- {N}j the number of the Nth window below the +--- current window (where |CTRL-W_j| goes to). +--- {N}k the number of the Nth window above the current +--- window (where |CTRL-W_k| goes to). +--- {N}h the number of the Nth window left of the +--- current window (where |CTRL-W_h| goes to). +--- {N}l the number of the Nth window right of the +--- current window (where |CTRL-W_l| goes to). +--- The number can be used with |CTRL-W_w| and ":wincmd w" +--- |:wincmd|. +--- When {arg} is invalid an error is given and zero is returned. +--- Also see |tabpagewinnr()| and |win_getid()|. +--- Examples: >vim +--- let window_count = winnr('$') +--- let prev_window = winnr('#') +--- let wnum = winnr('3k') +--- +--- @param arg? any +--- @return any +function vim.fn.winnr(arg) end + +--- Returns a sequence of |:resize| commands that should restore +--- the current window sizes. Only works properly when no windows +--- are opened or closed and the current window and tab page is +--- unchanged. +--- Example: >vim +--- let cmd = winrestcmd() +--- call MessWithWindowSizes() +--- exe cmd +--- < +--- +--- @return any +function vim.fn.winrestcmd() end + +--- Uses the |Dictionary| returned by |winsaveview()| to restore +--- the view of the current window. +--- Note: The {dict} does not have to contain all values, that are +--- returned by |winsaveview()|. If values are missing, those +--- settings won't be restored. So you can use: >vim +--- call winrestview({'curswant': 4}) +--- < +--- This will only set the curswant value (the column the cursor +--- wants to move on vertical movements) of the cursor to column 5 +--- (yes, that is 5), while all other settings will remain the +--- same. This is useful, if you set the cursor position manually. +--- +--- If you have changed the values the result is unpredictable. +--- If the window size changed the result won't be the same. +--- +--- @param dict vim.fn.winrestview.dict +--- @return any +function vim.fn.winrestview(dict) end + +--- Returns a |Dictionary| that contains information to restore +--- the view of the current window. Use |winrestview()| to +--- restore the view. +--- This is useful if you have a mapping that jumps around in the +--- buffer and you want to go back to the original view. +--- This does not save fold information. Use the 'foldenable' +--- option to temporarily switch off folding, so that folds are +--- not opened when moving around. This may have side effects. +--- The return value includes: +--- lnum cursor line number +--- col cursor column (Note: the first column +--- zero, as opposed to what |getcurpos()| +--- returns) +--- coladd cursor column offset for 'virtualedit' +--- curswant column for vertical movement (Note: +--- the first column is zero, as opposed +--- to what |getcurpos()| returns). After +--- |$| command it will be a very large +--- number equal to |v:maxcol|. +--- topline first line in the window +--- topfill filler lines, only in diff mode +--- leftcol first column displayed; only used when +--- 'wrap' is off +--- skipcol columns skipped +--- Note that no option values are saved. +--- +--- @return vim.fn.winsaveview.ret +function vim.fn.winsaveview() end + +--- The result is a Number, which is the width of window {nr}. +--- {nr} can be the window number or the |window-ID|. +--- When {nr} is zero, the width of the current window is +--- returned. When window {nr} doesn't exist, -1 is returned. +--- An existing window always has a width of zero or more. +--- Examples: >vim +--- echo "The current window has " .. winwidth(0) .. " columns." +--- if winwidth(0) <= 50 +--- 50 wincmd | +--- endif +--- <For getting the terminal or screen size, see the 'columns' +--- option. +--- +--- @param nr integer +--- @return any +function vim.fn.winwidth(nr) end + +--- The result is a dictionary of byte/chars/word statistics for +--- the current buffer. This is the same info as provided by +--- |g_CTRL-G| +--- The return value includes: +--- bytes Number of bytes in the buffer +--- chars Number of chars in the buffer +--- words Number of words in the buffer +--- cursor_bytes Number of bytes before cursor position +--- (not in Visual mode) +--- cursor_chars Number of chars before cursor position +--- (not in Visual mode) +--- cursor_words Number of words before cursor position +--- (not in Visual mode) +--- visual_bytes Number of bytes visually selected +--- (only in Visual mode) +--- visual_chars Number of chars visually selected +--- (only in Visual mode) +--- visual_words Number of words visually selected +--- (only in Visual mode) +--- +--- @return any +function vim.fn.wordcount() end + +--- When {object} is a |List| write it to file {fname}. Each list +--- item is separated with a NL. Each list item must be a String +--- or Number. +--- All NL characters are replaced with a NUL character. +--- Inserting CR characters needs to be done before passing {list} +--- to writefile(). +--- +--- When {object} is a |Blob| write the bytes to file {fname} +--- unmodified, also when binary mode is not specified. +--- +--- {flags} must be a String. These characters are recognized: +--- +--- 'b' Binary mode is used: There will not be a NL after the +--- last list item. An empty item at the end does cause the +--- last line in the file to end in a NL. +--- +--- 'a' Append mode is used, lines are appended to the file: >vim +--- call writefile(["foo"], "event.log", "a") +--- call writefile(["bar"], "event.log", "a") +--- < +--- 'D' Delete the file when the current function ends. This +--- works like: >vim +--- defer delete({fname}) +--- < Fails when not in a function. Also see |:defer|. +--- +--- 's' fsync() is called after writing the file. This flushes +--- the file to disk, if possible. This takes more time but +--- avoids losing the file if the system crashes. +--- +--- 'S' fsync() is not called, even when 'fsync' is set. +--- +--- When {flags} does not contain "S" or "s" then fsync() is +--- called if the 'fsync' option is set. +--- +--- An existing file is overwritten, if possible. +--- +--- When the write fails -1 is returned, otherwise 0. There is an +--- error message if the file can't be created or when writing +--- fails. +--- +--- Also see |readfile()|. +--- To copy a file byte for byte: >vim +--- let fl = readfile("foo", "b") +--- call writefile(fl, "foocopy", "b") +--- +--- @param object any +--- @param fname string +--- @param flags? string +--- @return any +function vim.fn.writefile(object, fname, flags) end + +--- Bitwise XOR on the two arguments. The arguments are converted +--- to a number. A List, Dict or Float argument causes an error. +--- Also see `and()` and `or()`. +--- Example: >vim +--- let bits = xor(bits, 0x80) +--- < +--- +--- @param expr any +--- @param expr1 any +--- @return any +function vim.fn.xor(expr, expr1) end |