aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-02-15 17:16:04 +0000
committerLewis Russell <me@lewisr.dev>2024-02-27 14:41:17 +0000
commit9beb40a4db5613601fc1a4b828a44e5977eca046 (patch)
tree314096d28ccdf2a2b035091783baa35193887d6a /runtime/doc
parent7ad2e3c64562bfb0ea2f7be305e4b0e6d2474d64 (diff)
downloadrneovim-9beb40a4db5613601fc1a4b828a44e5977eca046.tar.gz
rneovim-9beb40a4db5613601fc1a4b828a44e5977eca046.tar.bz2
rneovim-9beb40a4db5613601fc1a4b828a44e5977eca046.zip
feat(docs): replace lua2dox.lua
Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/api.txt232
-rw-r--r--runtime/doc/diagnostic.txt17
-rw-r--r--runtime/doc/lsp.txt59
-rw-r--r--runtime/doc/lua.txt414
-rw-r--r--runtime/doc/treesitter.txt57
5 files changed, 405 insertions, 374 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index e994644be9..1b00777532 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -579,7 +579,7 @@ created for extmark changes.
==============================================================================
Global Functions *api-global*
-nvim__get_runtime({pat}, {all}, {*opts}) *nvim__get_runtime()*
+nvim__get_runtime({pat}, {all}, {opts}) *nvim__get_runtime()*
Find files in runtime directories
Attributes: ~
@@ -700,7 +700,7 @@ nvim_chan_send({chan}, {data}) *nvim_chan_send()*
• {chan} id of the channel
• {data} data to write. 8-bit clean: can contain NUL bytes.
-nvim_complete_set({index}, {*opts}) *nvim_complete_set()*
+nvim_complete_set({index}, {opts}) *nvim_complete_set()*
Set info for the completion candidate index. if the info was shown in a
window, then the window and buffer ids are returned for further
customization. If the text was not shown, an empty dict is returned.
@@ -766,7 +766,7 @@ nvim_del_var({name}) *nvim_del_var()*
Parameters: ~
• {name} Variable name
-nvim_echo({chunks}, {history}, {*opts}) *nvim_echo()*
+nvim_echo({chunks}, {history}, {opts}) *nvim_echo()*
Echo a message.
Parameters: ~
@@ -797,7 +797,7 @@ nvim_err_writeln({str}) *nvim_err_writeln()*
See also: ~
• nvim_err_write()
-nvim_eval_statusline({str}, {*opts}) *nvim_eval_statusline()*
+nvim_eval_statusline({str}, {opts}) *nvim_eval_statusline()*
Evaluates statusline string.
Attributes: ~
@@ -878,13 +878,13 @@ nvim_get_api_info() *nvim_get_api_info()*
Returns a 2-tuple (Array), where item 0 is the current channel id and item
1 is the |api-metadata| map (Dictionary).
- Return: ~
- 2-tuple [{channel-id}, {api-metadata}]
-
Attributes: ~
|api-fast|
|RPC| only
+ Return: ~
+ 2-tuple [{channel-id}, {api-metadata}]
+
nvim_get_chan_info({chan}) *nvim_get_chan_info()*
Gets information about a channel.
@@ -900,12 +900,10 @@ nvim_get_chan_info({chan}) *nvim_get_chan_info()*
• "stderr" stderr of this Nvim instance
• "socket" TCP/IP socket or named pipe
• "job" Job with communication over its stdio.
-
• "mode" How data received on the channel is interpreted.
• "bytes" Send and receive raw bytes.
• "terminal" |terminal| instance interprets ASCII sequences.
• "rpc" |RPC| communication on the channel is active.
-
• "pty" (optional) Name of pseudoterminal. On a POSIX system this is a
device path like "/dev/pts/1". If the name is unknown, the key will
still be present if a pty is used (e.g. for conpty on Windows).
@@ -937,7 +935,7 @@ nvim_get_color_map() *nvim_get_color_map()*
Return: ~
Map of color names and RGB values.
-nvim_get_context({*opts}) *nvim_get_context()*
+nvim_get_context({opts}) *nvim_get_context()*
Gets a map of the current editor state.
Parameters: ~
@@ -972,7 +970,7 @@ nvim_get_current_win() *nvim_get_current_win()*
Return: ~
Window handle
-nvim_get_hl({ns_id}, {*opts}) *nvim_get_hl()*
+nvim_get_hl({ns_id}, {opts}) *nvim_get_hl()*
Gets all or specific highlight groups in a namespace.
Note: ~
@@ -1001,7 +999,7 @@ nvim_get_hl_id_by_name({name}) *nvim_get_hl_id_by_name()*
similar to |hlID()|, but allocates a new ID if not present.
-nvim_get_hl_ns({*opts}) *nvim_get_hl_ns()*
+nvim_get_hl_ns({opts}) *nvim_get_hl_ns()*
Gets the active highlight namespace.
Parameters: ~
@@ -1024,7 +1022,7 @@ nvim_get_keymap({mode}) *nvim_get_keymap()*
Array of |maparg()|-like dictionaries describing mappings. The
"buffer" key is always zero.
-nvim_get_mark({name}, {*opts}) *nvim_get_mark()*
+nvim_get_mark({name}, {opts}) *nvim_get_mark()*
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|.
@@ -1050,12 +1048,12 @@ nvim_get_mode() *nvim_get_mode()*
Gets the current mode. |mode()| "blocking" is true if Nvim is waiting for
input.
- Return: ~
- Dictionary { "mode": String, "blocking": Boolean }
-
Attributes: ~
|api-fast|
+ Return: ~
+ Dictionary { "mode": String, "blocking": Boolean }
+
nvim_get_proc({pid}) *nvim_get_proc()*
Gets info describing process `pid`.
@@ -1222,7 +1220,7 @@ nvim_notify({msg}, {log_level}, {opts}) *nvim_notify()*
• {log_level} The log level
• {opts} Reserved for future use.
-nvim_open_term({buffer}, {*opts}) *nvim_open_term()*
+nvim_open_term({buffer}, {opts}) *nvim_open_term()*
Open a terminal instance in a buffer
By default (and currently the only option) the terminal will not be
@@ -1280,14 +1278,13 @@ nvim_paste({data}, {crlf}, {phase}) *nvim_paste()*
• {data} Multiline input. May be binary (containing NUL bytes).
• {crlf} Also break lines at CR and CRLF.
• {phase} -1: paste in a single call (i.e. without streaming). To
- "stream" a paste, call `nvim_paste` sequentially
- with these `phase` values:
+ "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: ~
-
• true: Client may continue pasting.
• false: Client must cancel the paste.
@@ -1326,7 +1323,7 @@ nvim_replace_termcodes({str}, {from_part}, {do_lt}, {special})
• cpoptions
*nvim_select_popupmenu_item()*
-nvim_select_popupmenu_item({item}, {insert}, {finish}, {*opts})
+nvim_select_popupmenu_item({item}, {insert}, {finish}, {opts})
Selects an item in the completion popup menu.
If neither |ins-completion| nor |cmdline-completion| popup menu is active
@@ -1450,20 +1447,20 @@ nvim_set_current_win({window}) *nvim_set_current_win()*
Parameters: ~
• {window} Window handle
-nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()*
+nvim_set_hl({ns_id}, {name}, {val}) *nvim_set_hl()*
Sets a highlight group.
Note: ~
- • Unlike the `:highlight` command which can update a highlight group, this
- function completely replaces the definition. For example:
+ • Unlike the `:highlight` command which can update a highlight group,
+ this function completely replaces the definition. For example:
`nvim_set_hl(0, 'Visual', {})` will clear the highlight group
'Visual'.
- • The fg and bg keys also accept the string values `"fg"` or `"bg"` which
- act as aliases to the corresponding foreground and background values
- of the Normal group. If the Normal group has not been defined, using
- these values results in an error.
- • If `link` is used in combination with other attributes; only the `link`
- will take effect (see |:hi-link|).
+ • The fg and bg keys also accept the string values `"fg"` or `"bg"`
+ which act as aliases to the corresponding foreground and background
+ values of the Normal group. If the Normal group has not been defined,
+ using these values results in an error.
+ • If `link` is used in combination with other attributes; only the
+ `link` will take effect (see |:hi-link|).
Parameters: ~
• {ns_id} Namespace id for this highlight |nvim_create_namespace()|.
@@ -1520,7 +1517,7 @@ nvim_set_hl_ns_fast({ns_id}) *nvim_set_hl_ns_fast()*
Parameters: ~
• {ns_id} the namespace to activate
-nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()*
+nvim_set_keymap({mode}, {lhs}, {rhs}, {opts}) *nvim_set_keymap()*
Sets a global |mapping| for the given mode.
To set a buffer-local mapping, use |nvim_buf_set_keymap()|.
@@ -1537,8 +1534,8 @@ nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()*
<
Parameters: ~
- • {mode} Mode short-name (map command prefix: "n", "i", "v", "x", …) or
- "!" for |:map!|, or empty string for |:map|. "ia", "ca" or
+ • {mode} 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
• {lhs} Left-hand-side |{lhs}| of the mapping.
@@ -1651,7 +1648,7 @@ nvim_eval({expr}) *nvim_eval()*
Return: ~
Evaluation result or expanded object
-nvim_exec2({src}, {*opts}) *nvim_exec2()*
+nvim_exec2({src}, {opts}) *nvim_exec2()*
Executes Vimscript (multiline block of Ex commands), like anonymous
|:source|.
@@ -1704,18 +1701,16 @@ nvim_parse_expression({expr}, {flags}, {highlight})
region [start_col, end_col)).
Return: ~
-
• AST: top-level dictionary with these keys:
• "error": Dictionary with error, present only if parser saw some
error. Contains the following keys:
• "message": String, error message in printf format, translated.
Must contain exactly one "%.*s".
• "arg": String, error message argument.
-
• "len": Amount of bytes successfully parsed. With flags equal to ""
- that should be equal to the length of expr string. (“Successfully
- parsed” here means “participated in AST creation”, not “till the
- first error”.)
+ that should be equal to the length of expr string. ("Successfully
+ parsed" here means "participated in AST creation", not "till the
+ first error".)
• "ast": AST, either nil or a dictionary with these keys:
• "type": node type, one of the value names from ExprASTNodeType
stringified without "kExprNode" prefix.
@@ -1730,7 +1725,6 @@ nvim_parse_expression({expr}, {flags}, {highlight})
is zero, one or two children, key will not be present if node
has no children. Maximum number of children may be found in
node_maxchildren array.
-
• Local values (present only for certain nodes):
• "scope": a single Integer, specifies scope for "Option" and
"PlainIdentifier" nodes. For "Option" it is one of ExprOptScope
@@ -1760,11 +1754,11 @@ nvim_parse_expression({expr}, {flags}, {highlight})
Command Functions *api-command*
*nvim_buf_create_user_command()*
-nvim_buf_create_user_command({buffer}, {name}, {command}, {*opts})
+nvim_buf_create_user_command({buffer}, {name}, {command}, {opts})
Creates a buffer-local command |user-commands|.
Parameters: ~
- • {buffer} Buffer handle, or 0 for current buffer.
+ • {buffer} Buffer handle, or 0 for current buffer.
See also: ~
• nvim_create_user_command
@@ -1780,7 +1774,7 @@ nvim_buf_del_user_command({buffer}, {name})
• {buffer} Buffer handle, or 0 for current buffer.
• {name} Name of the command to delete.
-nvim_buf_get_commands({buffer}, {*opts}) *nvim_buf_get_commands()*
+nvim_buf_get_commands({buffer}, {opts}) *nvim_buf_get_commands()*
Gets a map of buffer-local |user-commands|.
Parameters: ~
@@ -1790,7 +1784,7 @@ nvim_buf_get_commands({buffer}, {*opts}) *nvim_buf_get_commands()*
Return: ~
Map of maps describing commands.
-nvim_cmd({*cmd}, {*opts}) *nvim_cmd()*
+nvim_cmd({cmd}, {opts}) *nvim_cmd()*
Executes an Ex command.
Unlike |nvim_command()| this command takes a structured Dictionary instead
@@ -1825,7 +1819,7 @@ nvim_cmd({*cmd}, {*opts}) *nvim_cmd()*
• |nvim_command()|
*nvim_create_user_command()*
-nvim_create_user_command({name}, {command}, {*opts})
+nvim_create_user_command({name}, {command}, {opts})
Creates a global |user-commands| command.
For Lua usage see |lua-guide-commands-create|.
@@ -1885,7 +1879,7 @@ nvim_del_user_command({name}) *nvim_del_user_command()*
Parameters: ~
• {name} Name of the command to delete.
-nvim_get_commands({*opts}) *nvim_get_commands()*
+nvim_get_commands({opts}) *nvim_get_commands()*
Gets a map of global (non-buffer-local) Ex commands.
Currently only |user-commands| are supported, not builtin Ex commands.
@@ -1899,7 +1893,7 @@ nvim_get_commands({*opts}) *nvim_get_commands()*
See also: ~
• |nvim_get_all_options_info()|
-nvim_parse_cmd({str}, {*opts}) *nvim_parse_cmd()*
+nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
Parse command line.
Doesn't check the validity of command arguments.
@@ -1937,13 +1931,11 @@ nvim_parse_cmd({str}, {*opts}) *nvim_parse_cmd()*
• bar: (boolean) The "|" character is treated as a command separator
and the double quote character (") is treated as the start of a
comment.
-
• mods: (dictionary) |:command-modifiers|.
• filter: (dictionary) |:filter|.
• pattern: (string) Filter pattern. Empty string if there is no
filter.
• force: (boolean) Whether filter is inverted or not.
-
• silent: (boolean) |:silent|.
• emsg_silent: (boolean) |:silent!|.
• unsilent: (boolean) |:unsilent|.
@@ -1986,7 +1978,7 @@ nvim_get_all_options_info() *nvim_get_all_options_info()*
See also: ~
• |nvim_get_commands()|
-nvim_get_option_info2({name}, {*opts}) *nvim_get_option_info2()*
+nvim_get_option_info2({name}, {opts}) *nvim_get_option_info2()*
Gets the option information for one option from arbitrary buffer or window
Resulting dictionary has keys:
@@ -2020,7 +2012,7 @@ nvim_get_option_info2({name}, {*opts}) *nvim_get_option_info2()*
Return: ~
Option Information
-nvim_get_option_value({name}, {*opts}) *nvim_get_option_value()*
+nvim_get_option_value({name}, {opts}) *nvim_get_option_value()*
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
@@ -2043,7 +2035,7 @@ nvim_get_option_value({name}, {*opts}) *nvim_get_option_value()*
Option value
*nvim_set_option_value()*
-nvim_set_option_value({name}, {value}, {*opts})
+nvim_set_option_value({name}, {value}, {opts})
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}.
@@ -2069,16 +2061,16 @@ For more information on buffers, see |buffers|.
Unloaded Buffers: ~
Buffers may be unloaded by the |:bunload| command or the buffer's
-|'bufhidden'| option. When a buffer is unloaded its file contents are
-freed from memory and vim cannot operate on the buffer lines until it is
-reloaded (usually by opening the buffer again in a new window). API
-methods such as |nvim_buf_get_lines()| and |nvim_buf_line_count()| will be
-affected.
+|'bufhidden'| option. When a buffer is unloaded its file contents are freed
+from memory and vim cannot operate on the buffer lines until it is reloaded
+(usually by opening the buffer again in a new window). API methods such as
+|nvim_buf_get_lines()| and |nvim_buf_line_count()| will be affected.
You can use |nvim_buf_is_loaded()| or |nvim_buf_line_count()| to check
whether a buffer is loaded.
-nvim_buf_attach({buffer}, {send_buffer}, {*opts}) *nvim_buf_attach()*
+
+nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()*
Activates buffer-update events on a channel, or as Lua callbacks.
Example (Lua): capture buffer updates in a global `events` variable (use
@@ -2100,8 +2092,7 @@ nvim_buf_attach({buffer}, {send_buffer}, {*opts}) *nvim_buf_attach()*
callbacks.
• {opts} Optional parameters.
• on_lines: Lua callback invoked on change. Return a
- truthy value (not `false` or `nil`)
- to detach. Args:
+ truthy value (not `false` or `nil`) to detach. Args:
• the string "lines"
• buffer handle
• b:changedtick
@@ -2111,12 +2102,10 @@ nvim_buf_attach({buffer}, {send_buffer}, {*opts}) *nvim_buf_attach()*
• 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 a truthy value
- (not `false` or `nil`) to
- detach. Args:
+ (not `false` or `nil`) to detach. Args:
• the string "bytes"
• buffer handle
• b:changedtick
@@ -2134,22 +2123,18 @@ nvim_buf_attach({buffer}, {send_buffer}, {*opts}) *nvim_buf_attach()*
• new end column of the changed text (if new end row
= 0, offset from start column)
• 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.
@@ -2221,7 +2206,7 @@ nvim_buf_del_var({buffer}, {name}) *nvim_buf_del_var()*
• {buffer} Buffer handle, or 0 for current buffer
• {name} Variable name
-nvim_buf_delete({buffer}, {*opts}) *nvim_buf_delete()*
+nvim_buf_delete({buffer}, {opts}) *nvim_buf_delete()*
Deletes the buffer. See |:bwipeout|
Attributes: ~
@@ -2263,8 +2248,8 @@ nvim_buf_get_keymap({buffer}, {mode}) *nvim_buf_get_keymap()*
Gets a list of buffer-local |mapping| definitions.
Parameters: ~
- • {mode} Mode short-name ("n", "i", "v", ...)
• {buffer} Buffer handle, or 0 for current buffer
+ • {mode} Mode short-name ("n", "i", "v", ...)
Return: ~
Array of |maparg()|-like dictionaries describing mappings. The
@@ -2338,7 +2323,7 @@ nvim_buf_get_offset({buffer}, {index}) *nvim_buf_get_offset()*
*nvim_buf_get_text()*
nvim_buf_get_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col},
- {*opts})
+ {opts})
Gets a range from the buffer.
This differs from |nvim_buf_get_lines()| in that it allows retrieving only
@@ -2403,7 +2388,7 @@ nvim_buf_line_count({buffer}) *nvim_buf_line_count()*
Line count, or 0 for unloaded buffer. |api-buffer|
*nvim_buf_set_keymap()*
-nvim_buf_set_keymap({buffer}, {mode}, {lhs}, {rhs}, {*opts})
+nvim_buf_set_keymap({buffer}, {mode}, {lhs}, {rhs}, {opts})
Sets a buffer-local |mapping| for the given mode.
Parameters: ~
@@ -2440,7 +2425,7 @@ nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, {replacement})
• |nvim_buf_set_text()|
*nvim_buf_set_mark()*
-nvim_buf_set_mark({buffer}, {name}, {line}, {col}, {*opts})
+nvim_buf_set_mark({buffer}, {name}, {line}, {col}, {opts})
Sets a named mark in the given buffer, all marks are allowed
file/uppercase, visual, last change, etc. See |mark-motions|.
@@ -2581,7 +2566,7 @@ nvim_buf_del_extmark({buffer}, {ns_id}, {id}) *nvim_buf_del_extmark()*
true if the extmark was found, else false
*nvim_buf_get_extmark_by_id()*
-nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {*opts})
+nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
Gets the position (0-indexed) of an |extmark|.
Parameters: ~
@@ -2597,7 +2582,7 @@ nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {*opts})
0-indexed (row, col) tuple or empty list () if extmark id was absent
*nvim_buf_get_extmarks()*
-nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {*opts})
+nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
Gets |extmarks| in "traversal order" from a |charwise| region defined by
buffer positions (inclusive, 0-indexed |api-indexing|).
@@ -2657,7 +2642,7 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {*opts})
List of [extmark_id, row, col] tuples in "traversal order".
*nvim_buf_set_extmark()*
-nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
+nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts})
Creates or updates an |extmark|.
By default a new extmark is created when no id is passed in, but it is
@@ -2703,7 +2688,6 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
• "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".
@@ -2715,14 +2699,12 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
wrapped lines.
• 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.
+ 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
@@ -2815,7 +2797,7 @@ nvim_get_namespaces() *nvim_get_namespaces()*
dict that maps from names to namespace ids.
*nvim_set_decoration_provider()*
-nvim_set_decoration_provider({ns_id}, {*opts})
+nvim_set_decoration_provider({ns_id}, {opts})
Set or change decoration provider for a |namespace|
This is a very general purpose interface for having Lua callbacks being
@@ -3066,7 +3048,7 @@ nvim_win_set_hl_ns({window}, {ns_id}) *nvim_win_set_hl_ns()*
This takes precedence over the 'winhighlight' option.
Parameters: ~
- • {ns_id} the namespace to use
+ • {ns_id} the namespace to use
nvim_win_set_var({window}, {name}, {value}) *nvim_win_set_var()*
Sets a window-scoped (w:) variable
@@ -3084,7 +3066,7 @@ nvim_win_set_width({window}, {width}) *nvim_win_set_width()*
• {window} Window handle, or 0 for current window
• {width} Width as a count of columns
-nvim_win_text_height({window}, {*opts}) *nvim_win_text_height()*
+nvim_win_text_height({window}, {opts}) *nvim_win_text_height()*
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.
@@ -3120,9 +3102,9 @@ nvim_win_text_height({window}, {*opts}) *nvim_win_text_height()*
==============================================================================
-Win_Config Functions *api-win_config*
+Win_config Functions *api-win_config*
-nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
+nvim_open_win({buffer}, {enter}, {config}) *nvim_open_win()*
Opens a new split window, or a floating window if `relative` is specified,
or an external window (managed by the UI) if `external` is specified.
@@ -3188,7 +3170,6 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
window.
• "cursor" Cursor position in current window.
• "mouse" Mouse position
-
• win: |window-ID| window to split, or relative window when
creating a float (relative="win").
• anchor: Decides which corner of the float to place at
@@ -3197,17 +3178,15 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
• "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:
+ 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
@@ -3228,7 +3207,6 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
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
@@ -3241,14 +3219,13 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
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.).
+ • "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.
@@ -3256,19 +3233,26 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
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"] ].
-
+ 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`.
@@ -3306,7 +3290,7 @@ nvim_win_get_config({window}) *nvim_win_get_config()*
Return: ~
Map defining the window configuration, see |nvim_open_win()|
-nvim_win_set_config({window}, {*config}) *nvim_win_set_config()*
+nvim_win_set_config({window}, {config}) *nvim_win_set_config()*
Configures window layout. Currently only for floating and external windows
(including changing a split window to those layouts).
@@ -3397,7 +3381,7 @@ nvim_tabpage_set_win({tabpage}, {win}) *nvim_tabpage_set_win()*
==============================================================================
Autocmd Functions *api-autocmd*
-nvim_clear_autocmds({*opts}) *nvim_clear_autocmds()*
+nvim_clear_autocmds({opts}) *nvim_clear_autocmds()*
Clears all autocommands selected by {opts}. To delete autocmds see
|nvim_del_autocmd()|.
@@ -3407,25 +3391,21 @@ nvim_clear_autocmds({*opts}) *nvim_clear_autocmds()*
• 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.
-nvim_create_augroup({name}, {*opts}) *nvim_create_augroup()*
+nvim_create_augroup({name}, {opts}) *nvim_create_augroup()*
Create or get an autocommand group |autocmd-groups|.
To get an existing group id, do: >lua
@@ -3446,9 +3426,10 @@ nvim_create_augroup({name}, {*opts}) *nvim_create_augroup()*
See also: ~
• |autocmd-groups|
-nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()*
- Creates an |autocommand| event handler, defined by `callback` (Lua function
- or Vimscript function name string) or `command` (Ex command string).
+nvim_create_autocmd({event}, {opts}) *nvim_create_autocmd()*
+ 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"}, {
@@ -3487,8 +3468,8 @@ nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()*
• callback (function|string) optional: Lua function (or
Vimscript function name, if string) called when the
event(s) is triggered. Lua callback can return a truthy
- value (not `false` or `nil`) to delete the
- autocommand. Receives a table argument with these keys:
+ value (not `false` or `nil`) to delete the autocommand.
+ Receives a table argument with these keys:
• id: (number) autocommand id
• event: (string) name of the triggered event
|autocmd-events|
@@ -3498,7 +3479,6 @@ nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()*
• 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
@@ -3548,7 +3528,7 @@ nvim_del_autocmd({id}) *nvim_del_autocmd()*
Parameters: ~
• {id} Integer Autocommand id returned by |nvim_create_autocmd()|
-nvim_exec_autocmds({event}, {*opts}) *nvim_exec_autocmds()*
+nvim_exec_autocmds({event}, {opts}) *nvim_exec_autocmds()*
Execute all autocommands for {event} that match the corresponding {opts}
|autocmd-execute|.
@@ -3569,7 +3549,7 @@ nvim_exec_autocmds({event}, {*opts}) *nvim_exec_autocmds()*
See also: ~
• |:doautocmd|
-nvim_get_autocmds({*opts}) *nvim_get_autocmds()*
+nvim_get_autocmds({opts}) *nvim_get_autocmds()*
Get all autocommands that match the corresponding {opts}.
These examples will get autocommands matching ALL the given criteria: >lua
@@ -3683,13 +3663,12 @@ nvim_ui_pum_set_height({height}) *nvim_ui_pum_set_height()*
• {height} Popupmenu height, must be greater than zero.
nvim_ui_set_focus({gained}) *nvim_ui_set_focus()*
- Tells the nvim server if focus was gained or lost by the GUI.
+ Tells the nvim server if focus was gained or lost by the GUI
Attributes: ~
|RPC| only
nvim_ui_set_option({name}, {value}) *nvim_ui_set_option()*
- TODO: Documentation
Attributes: ~
|RPC| only
@@ -3698,7 +3677,6 @@ nvim_ui_term_event({event}, {value}) *nvim_ui_term_event()*
Tells Nvim when a terminal event has occurred
The following terminal events are supported:
-
• "termresponse": The terminal sent an OSC or DCS response sequence to
Nvim. The payload is the received response. Sets |v:termresponse| and
fires |TermResponse|.
@@ -3707,11 +3685,10 @@ nvim_ui_term_event({event}, {value}) *nvim_ui_term_event()*
|RPC| only
Parameters: ~
- • {event} Event name
- • {payload} Event payload
+ • {event} Event name
+ • {value} Event payload
nvim_ui_try_resize({width}, {height}) *nvim_ui_try_resize()*
- TODO: Documentation
Attributes: ~
|RPC| only
@@ -3731,4 +3708,5 @@ nvim_ui_try_resize_grid({grid}, {width}, {height})
• {width} The new requested width.
• {height} The new requested height.
+
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
index bee0445e4e..dbfa0148af 100644
--- a/runtime/doc/diagnostic.txt
+++ b/runtime/doc/diagnostic.txt
@@ -397,7 +397,6 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
diagnostics. Options:
• severity: Only underline diagnostics matching the
given severity |diagnostic-severity|
-
• virtual_text: (default true) Use virtual text for
diagnostics. If multiple diagnostics are set for a
namespace, one prefix per diagnostic + the last
@@ -430,7 +429,6 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
• format: (function) A function that takes a diagnostic
as input and returns a string. The return value is
the text used to display the diagnostic. Example: >lua
-
function(diagnostic)
if diagnostic.severity == vim.diagnostic.severity.ERROR then
return string.format("E: %s", diagnostic.message)
@@ -438,7 +436,6 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
return diagnostic.message
end
<
-
• signs: (default true) Use signs for diagnostics
|diagnostic-signs|. Options:
• severity: Only show signs for diagnostics matching
@@ -452,7 +449,6 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
default is to use "E", "W", "I", and "H" for errors,
warnings, information, and hints, respectively.
Example: >lua
-
vim.diagnostic.config({
signs = { text = { [vim.diagnostic.severity.ERROR] = 'E', ... } }
})
@@ -463,7 +459,6 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
• linehl: (table) A table mapping |diagnostic-severity|
to the highlight group used for the whole line the
sign is placed in.
-
• float: Options for floating windows. See
|vim.diagnostic.open_float()|.
• update_in_insert: (default false) Update diagnostics in
@@ -542,8 +537,8 @@ get({bufnr}, {opts}) *vim.diagnostic.get()*
Return: ~
(`vim.Diagnostic[]`) table A list of diagnostic items
- |diagnostic-structure|. Keys `bufnr` , `end_lnum` , `end_col` , and `severity` are
- guaranteed to be present.
+ |diagnostic-structure|. Keys `bufnr`, `end_lnum`, `end_col`, and
+ `severity` are guaranteed to be present.
get_namespace({namespace}) *vim.diagnostic.get_namespace()*
Get namespace metadata.
@@ -685,7 +680,7 @@ match({str}, {pat}, {groups}, {severity_map}, {defaults})
(`vim.Diagnostic?`) |diagnostic-structure| or `nil` if {pat} fails to
match {str}.
-open_float({opts}, {...}) *vim.diagnostic.open_float()*
+open_float({opts}) *vim.diagnostic.open_float()*
Show diagnostics in a floating window.
Parameters: ~
@@ -738,8 +733,9 @@ open_float({opts}, {...}) *vim.diagnostic.open_float()*
diagnostic instead of prepending it. Overrides the setting
from |vim.diagnostic.config()|.
- Return: ~
- (`integer?, integer?`) ({float_bufnr}, {win_id})
+ Return (multiple): ~
+ (`integer?`) float_bufnr
+ (`integer?`) win_id
reset({namespace}, {bufnr}) *vim.diagnostic.reset()*
Remove all diagnostics from the given namespace.
@@ -823,4 +819,5 @@ toqflist({diagnostics}) *vim.diagnostic.toqflist()*
Return: ~
(`table[]`) of quickfix list items |setqflist-what|
+
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index a94de629b2..c14c0e5b9c 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -712,10 +712,9 @@ buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
(`string?`) err On timeout, cancel, or error, `err` is a string
describing the failure reason, and `result` is nil.
-client() *vim.lsp.client*
+client *vim.lsp.client*
LSP client object. You can get an active client object via
|vim.lsp.get_client_by_id()| or |vim.lsp.get_clients()|.
-
• Methods:
• request(method, params, [handler], bufnr) Sends a request to the
server. This is a thin wrapper around {client.rpc.request} with some
@@ -750,7 +749,6 @@ client() *vim.lsp.client*
given method. Always returns true for unknown off-spec methods. [opts]
is a optional `{bufnr?: integer}` table. Some language server
capabilities can be file specific.
-
• Members
• {id} (number): The id allocated to the client.
• {name} (string): If a name is specified on creation, that will be
@@ -916,7 +914,6 @@ start({config}, {opts}) *vim.lsp.start()*
See |vim.lsp.start_client()| for all available options. The most important
are:
-
• `name` arbitrary name for the LSP client. Should be unique per language
server.
• `cmd` command string[] or function, described at
@@ -975,8 +972,7 @@ start_client({config}) *vim.lsp.start_client()*
• cmd_env: (table) Environment flags to pass to the LSP on
spawn. Must be specified using a table. Non-string values
are coerced to string. Example: >
-
- { PORT = 8080; HOST = "0.0.0.0"; }
+ { PORT = 8080; HOST = "0.0.0.0"; }
<
• detached: (boolean, default true) Daemonize the server
process so that it runs in a separate process group from
@@ -994,7 +990,6 @@ start_client({config}) *vim.lsp.start_client()*
make_client_capabilities() and modify its result.
• Note: To send an empty dictionary use
|vim.empty_dict()|, else it will be encoded as an array.
-
• handlers: Map of language server method names to
|lsp-handler|
• settings: Map with language server specific settings.
@@ -1041,7 +1036,6 @@ start_client({config}) *vim.lsp.start_client()*
• signal: number describing the signal used to terminate
(if any)
• client_id: client handle
-
• on_attach: Callback (client, bufnr) invoked when client
attaches to a buffer.
• trace: ("off" | "messages" | "verbose" | nil) passed
@@ -1059,7 +1053,6 @@ start_client({config}) *vim.lsp.start_client()*
sending the "shutdown" request before sending kill -15.
If set to false, nvim exits immediately after sending
the "shutdown" request to the server.
-
• root_dir: (string) Directory where the LSP server will
base its workspaceFolders, rootUri, and rootPath on
initialization.
@@ -1124,6 +1117,9 @@ add_workspace_folder({workspace_folder})
Add the folder at path to the workspace folders. If {path} is not
provided, the user will be prompted for a path using |input()|.
+ Parameters: ~
+ • {workspace_folder} (`string?`)
+
clear_references() *vim.lsp.buf.clear_references()*
Removes document highlights from current buffer.
@@ -1133,8 +1129,8 @@ code_action({options}) *vim.lsp.buf.code_action()*
Parameters: ~
• {options} (`table?`) Optional table which holds the following
optional fields:
- • context: (table|nil) Corresponds to `CodeActionContext` of
- the LSP specification:
+ • context: (table|nil) Corresponds to `CodeActionContext`
+ of the LSP specification:
• diagnostics (table|nil): LSP `Diagnostic[]`. Inferred
from the current position if not provided.
• only (table|nil): List of LSP `CodeActionKind`s used to
@@ -1142,7 +1138,6 @@ code_action({options}) *vim.lsp.buf.code_action()*
values like `refactor` or `quickfix`.
• triggerKind (number|nil): The reason why code actions
were requested.
-
• filter: (function|nil) Predicate taking an `CodeAction`
and returning a boolean.
• apply: (boolean|nil) When set to `true`, and there is
@@ -1235,7 +1230,8 @@ format({options}) *vim.lsp.buf.format()*
optional fields:
• formatting_options (table|nil): Can be used to specify
FormattingOptions. Some unspecified options will be
- automatically derived from the current Nvim options. See https://microsoft.github.io/language-server-protocol/specification/#formattingOptions
+ automatically derived from the current Nvim options. See
+ https://microsoft.github.io/language-server-protocol/specification/#formattingOptions
• timeout_ms (integer|nil, default 1000): Time in
milliseconds to block for formatting requests. No effect
if async=true
@@ -1245,7 +1241,6 @@ format({options}) *vim.lsp.buf.format()*
• filter (function|nil): Predicate used to filter clients.
Receives a client as argument and must return a boolean.
Clients matching the predicate are included. Example: >lua
-
-- Never request typescript-language-server for formatting
vim.lsp.buf.format {
filter = function(client) return client.name ~= "tsserver" end
@@ -1308,6 +1303,9 @@ remove_workspace_folder({workspace_folder})
Remove the folder at path from the workspace folders. If {path} is not
provided, the user will be prompted for a path using |input()|.
+ Parameters: ~
+ • {workspace_folder} (`string?`)
+
rename({new_name}, {options}) *vim.lsp.buf.rename()*
Renames all references to the symbol under the cursor.
@@ -1454,12 +1452,13 @@ get({bufnr}) *vim.lsp.codelens.get()*
Return: ~
(`lsp.CodeLens[]`)
- *vim.lsp.codelens.on_codelens()*
-on_codelens({err}, {result}, {ctx}, {_})
+on_codelens({err}, {result}, {ctx}) *vim.lsp.codelens.on_codelens()*
|lsp-handler| for the method `textDocument/codeLens`
Parameters: ~
- • {ctx} (`lsp.HandlerContext`)
+ • {err} (`lsp.ResponseError?`)
+ • {result} (`lsp.CodeLens[]`)
+ • {ctx} (`lsp.HandlerContext`)
refresh({opts}) *vim.lsp.codelens.refresh()*
Refresh the lenses.
@@ -1499,7 +1498,7 @@ enable({bufnr}, {enable}) *vim.lsp.inlay_hint.enable()*
<
Note: ~
- This API is pre-release (unstable).
+ • This API is pre-release (unstable).
Parameters: ~
• {bufnr} (`integer?`) Buffer handle, or 0 or nil for current
@@ -1523,7 +1522,7 @@ get({filter}) *vim.lsp.inlay_hint.get()*
<
Note: ~
- This API is pre-release (unstable).
+ • This API is pre-release (unstable).
Parameters: ~
• {filter} (`vim.lsp.inlay_hint.get.filter?`) Optional filters
@@ -1539,8 +1538,9 @@ get({filter}) *vim.lsp.inlay_hint.get()*
• inlay_hint (lsp.InlayHint)
is_enabled({bufnr}) *vim.lsp.inlay_hint.is_enabled()*
+
Note: ~
- This API is pre-release (unstable).
+ • This API is pre-release (unstable).
Parameters: ~
• {bufnr} (`integer?`) Buffer handle, or 0 or nil for current
@@ -1653,6 +1653,7 @@ hover({_}, {result}, {ctx}, {config}) *vim.lsp.handlers.hover()*
<
Parameters: ~
+ • {result} (`lsp.Hover`)
• {ctx} (`lsp.HandlerContext`)
• {config} (`table`) Configuration table.
• border: (default=nil)
@@ -1674,7 +1675,7 @@ signature_help({_}, {result}, {ctx}, {config})
<
Parameters: ~
- • {result} (`table`) Response from the language server
+ • {result} (`lsp.SignatureHelp`) Response from the language server
• {ctx} (`lsp.HandlerContext`) Client context
• {config} (`table`) Configuration table.
• border: (default=nil)
@@ -1695,6 +1696,7 @@ apply_text_document_edit({text_document_edit}, {index}, {offset_encoding})
• {text_document_edit} (`table`) a `TextDocumentEdit` object
• {index} (`integer`) Optional index of the edit, if from
a list of edits (or nil, if not from a list)
+ • {offset_encoding} (`string?`)
See also: ~
• https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentEdit
@@ -1719,6 +1721,9 @@ apply_workspace_edit({workspace_edit}, {offset_encoding})
• {workspace_edit} (`table`) `WorkspaceEdit`
• {offset_encoding} (`string`) utf-8|utf-16|utf-32 (required)
+ See also: ~
+ • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit
+
buf_clear_references({bufnr}) *vim.lsp.util.buf_clear_references()*
Removes document highlights from a buffer.
@@ -1994,6 +1999,7 @@ preview_location({location}, {opts}) *vim.lsp.util.preview_location()*
Parameters: ~
• {location} (`table`) a single `Location` or `LocationLink`
+ • {opts} (`table`)
Return (multiple): ~
(`integer?`) buffer id of float window
@@ -2038,6 +2044,7 @@ stylize_markdown({bufnr}, {contents}, {opts})
`open_floating_preview` instead
Parameters: ~
+ • {bufnr} (`integer`)
• {contents} (`table`) of lines to show in window
• {opts} (`table`) with optional fields
• height of floating window
@@ -2055,6 +2062,7 @@ symbols_to_items({symbols}, {bufnr}) *vim.lsp.util.symbols_to_items()*
Parameters: ~
• {symbols} (`table`) DocumentSymbol[] or SymbolInformation[]
+ • {bufnr} (`integer`)
==============================================================================
@@ -2092,7 +2100,7 @@ should_log({level}) *vim.lsp.log.should_log()*
• {level} (`integer`) log level
Return: ~
- (bool) true if would log, false if not
+ (`bool`) true if would log, false if not
==============================================================================
@@ -2110,7 +2118,8 @@ connect({host}, {port}) *vim.lsp.rpc.connect()*
• {port} (`integer`) port to connect to
Return: ~
- (`fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.PublicClient`)
+ (`fun(dispatchers: vim.lsp.rpc.Dispatchers):
+ vim.lsp.rpc.PublicClient`)
*vim.lsp.rpc.domain_socket_connect()*
domain_socket_connect({pipe_path})
@@ -2126,7 +2135,8 @@ domain_socket_connect({pipe_path})
of the named pipe (Windows) to connect to
Return: ~
- (`fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.PublicClient`)
+ (`fun(dispatchers: vim.lsp.rpc.Dispatchers):
+ vim.lsp.rpc.PublicClient`)
format_rpc_error({err}) *vim.lsp.rpc.format_rpc_error()*
Constructs an error message from an LSP error object.
@@ -2241,4 +2251,5 @@ resolve_capabilities({server_capabilities})
Return: ~
(`lsp.ServerCapabilities?`) Normalized table of capabilities
+
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 94b37ad7c6..f56d7f778a 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -582,25 +582,21 @@ A subset of the `vim.*` API is available in threads. This includes:
==============================================================================
VIM.HIGHLIGHT *vim.highlight*
-
Nvim includes a function for highlighting a selection on yank.
To enable it, add the following to your `init.vim`: >vim
au TextYankPost * silent! lua vim.highlight.on_yank()
-
<
-You can customize the highlight group and the duration of the highlight
-via: >vim
+You can customize the highlight group and the duration of the highlight via: >vim
au TextYankPost * silent! lua vim.highlight.on_yank {higroup="IncSearch", timeout=150}
-
<
If you want to exclude visual selections from highlighting on yank, use: >vim
au TextYankPost * silent! lua vim.highlight.on_yank {on_visual=false}
-
<
+
vim.highlight.on_yank({opts}) *vim.highlight.on_yank()*
Highlight the yanked text
@@ -678,12 +674,10 @@ vim.diff({a}, {b}, {opts}) *vim.diff()*
• `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
@@ -694,7 +688,6 @@ vim.diff({a}, {b}, {opts}) *vim.diff()*
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
@@ -716,30 +709,38 @@ vim.diff({a}, {b}, {opts}) *vim.diff()*
==============================================================================
VIM.MPACK *vim.mpack*
-
This module provides encoding and decoding of Lua objects to and from
msgpack-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|.
+
vim.mpack.decode({str}) *vim.mpack.decode()*
Decodes (or "unpacks") the msgpack-encoded {str} to a Lua object.
Parameters: ~
• {str} (`string`)
+ Return: ~
+ (`any`)
+
vim.mpack.encode({obj}) *vim.mpack.encode()*
Encodes (or "packs") Lua object {obj} as msgpack in a Lua string.
+ Parameters: ~
+ • {obj} (`any`)
+
+ Return: ~
+ (`string`)
+
==============================================================================
VIM.JSON *vim.json*
-
This module provides encoding and decoding of Lua objects to and from
JSON-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|.
+
vim.json.decode({str}, {opts}) *vim.json.decode()*
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).
@@ -829,24 +830,24 @@ vim.spell.check({str}) *vim.spell.check()*
VIM *vim.builtin*
-vim.api.{func}({...}) *vim.api*
+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*
+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*
+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*
+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
{
@@ -855,7 +856,7 @@ vim.val_idx *vim.val_id
}
< See also |vim.type_idx| and |lua-special-tbl|.
-vim.types *vim.types*
+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
@@ -884,6 +885,8 @@ Log levels are one of the values defined in `vim.log.levels`:
vim.log.levels.WARN
vim.log.levels.OFF
+
+
vim.empty_dict() *vim.empty_dict()*
Creates a special empty table (marked with a metatable), which Nvim
converts to an empty dictionary when translating Lua values to Vimscript
@@ -1137,8 +1140,9 @@ vim.wait({time}, {callback}, {interval}, {fast_only}) *vim.wait()*
• {fast_only} (`boolean?`) If true, only |api-fast| events will be
processed.
- Return: ~
- (`boolean, -1|-2?`)
+ Return (multiple): ~
+ (`boolean`)
+ (`-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`
@@ -1148,18 +1152,15 @@ vim.wait({time}, {callback}, {interval}, {fast_only}) *vim.wait()*
==============================================================================
LUA-VIMSCRIPT BRIDGE *lua-vimscript*
-
Nvim Lua provides an interface or "bridge" to Vimscript variables and
functions, and editor commands and options.
Objects passed over this bridge are COPIED (marshalled): there are no
-"references". |lua-guide-variables| For example, using `vim.fn.remove()`
-on a Lua list copies the list object to Vimscript and does NOT modify the
-Lua list: >lua
+"references". |lua-guide-variables| For example, using `vim.fn.remove()` on a
+Lua list copies the list object to Vimscript and does NOT modify the Lua list: >lua
local list = { 1, 2, 3 }
vim.fn.remove(list, 0)
vim.print(list) --> "{ 1, 2, 3 }"
-
<
vim.call({func}, {...}) *vim.call()*
@@ -1240,7 +1241,7 @@ vim.v *vim.v*
|v:| variables.
Invalid or unset key returns `nil`.
-` ` *lua-options*
+ *lua-options*
*lua-vim-options*
*lua-vim-set*
*lua-vim-setlocal*
@@ -1263,9 +1264,10 @@ window-scoped options. Note that this must NOT be confused with
|local-options| and |:setlocal|. There is also |vim.go| that only accesses the
global value of a |global-local| option, see |:setglobal|.
-` ` *vim.opt_local*
- *vim.opt_global*
- *vim.opt*
+ *vim.opt_local*
+ *vim.opt_global*
+ *vim.opt*
+
A special interface |vim.opt| exists for conveniently interacting with list-
and map-style option from Lua: It allows accessing them as Lua tables and
@@ -1326,6 +1328,7 @@ In any of the above examples, to replicate the behavior |:setlocal|, use
`vim.opt_local`. Additionally, to replicate the behavior of |:setglobal|, use
`vim.opt_global`.
+
Option:append({value}) *vim.opt:append()*
Append a value to string-style options. See |:set+=|
@@ -1478,7 +1481,7 @@ vim.wo *vim.wo*
==============================================================================
Lua module: vim *lua-vim*
-vim.cmd *vim.cmd()*
+vim.cmd({command}) *vim.cmd()*
Executes Vim script commands.
Note that `vim.cmd` can be indexed with a command name to return a
@@ -1552,7 +1555,7 @@ vim.deprecate({name}, {alternative}, {version}, {plugin}, {backtrace})
Return: ~
(`string?`) Deprecated message, or nil if no message was shown.
-vim.inspect *vim.inspect()*
+vim.inspect() *vim.inspect()*
Gets a human-readable representation of the given object.
Return: ~
@@ -1580,12 +1583,15 @@ vim.keycode({str}) *vim.keycode()*
See also: ~
• |nvim_replace_termcodes()|
-vim.lua_omnifunc({find_start}, {_}) *vim.lua_omnifunc()*
+vim.lua_omnifunc({find_start}) *vim.lua_omnifunc()*
Omnifunc for completing Lua values from the runtime Lua interpreter,
similar to the builtin completion for the `:lua` command.
Activate using `set omnifunc=v:lua.vim.lua_omnifunc` in a Lua buffer.
+ Parameters: ~
+ • {find_start} (`1|0`)
+
vim.notify({msg}, {level}, {opts}) *vim.notify()*
Displays a notification to the user.
@@ -1655,8 +1661,8 @@ vim.paste({lines}, {phase}) *vim.paste()*
• {lines} (`string[]`) |readfile()|-style list of lines to paste.
|channel-lines|
• {phase} (`-1|1|2|3`) -1: "non-streaming" paste: the call contains all
- lines. If paste is "streamed", `phase` indicates
- the stream state:
+ lines. If paste is "streamed", `phase` indicates the stream
+ state:
• 1: starts the paste (exactly once)
• 2: continues the paste (zero or more times)
• 3: ends the paste (exactly once)
@@ -1674,6 +1680,9 @@ vim.print({...}) *vim.print()*
local hl_normal = vim.print(vim.api.nvim_get_hl(0, { name = 'Normal' }))
<
+ Parameters: ~
+ • {...} (`any`)
+
Return: ~
(`any`) given arguments.
@@ -1799,7 +1808,6 @@ vim.system({cmd}, {opts}, {on_exit}) *vim.system()*
• signal: (integer)
• stdout: (string), nil if stdout argument is passed
• stderr: (string), nil if stderr argument is passed
-
• kill (fun(signal: integer|string))
• write (fun(data: string|nil)) Requires `stdin=true`. Pass `nil` to
close the stream.
@@ -1858,11 +1866,32 @@ vim.show_pos({bufnr}, {row}, {col}, {filter}) *vim.show_pos()*
+Ringbuf:clear() *Ringbuf:clear()*
+ Clear all items
+
+Ringbuf:peek() *Ringbuf:peek()*
+ Returns the first unread item without removing it
+
+ Return: ~
+ (`any?`)
+
+Ringbuf:pop() *Ringbuf:pop()*
+ Removes and returns the first unread item
+
+ Return: ~
+ (`any?`)
+
+Ringbuf:push({item}) *Ringbuf:push()*
+ Adds an item, overriding the oldest item if the buffer is full.
+
+ Parameters: ~
+ • {item} (`any`)
+
vim.deep_equal({a}, {b}) *vim.deep_equal()*
Deep compare values for equality
- Tables are compared recursively unless they both provide the `eq` metamethod.
- All other types are compared using the equality `==` operator.
+ Tables are compared recursively unless they both provide the `eq`
+ metamethod. All other types are compared using the equality `==` operator.
Parameters: ~
• {a} (`any`) First value
@@ -1999,12 +2028,12 @@ vim.list_slice({list}, {start}, {finish}) *vim.list_slice()*
(inclusive)
Parameters: ~
- • {list} (`list`) Table
+ • {list} (`any[]`) Table
• {start} (`integer?`) Start range of slice
• {finish} (`integer?`) End range of slice
Return: ~
- (`list`) Copy of table sliced from start to finish (inclusive)
+ (`any[]`) Copy of table sliced from start to finish (inclusive)
vim.pesc({s}) *vim.pesc()*
Escapes magic chars in |lua-patterns|.
@@ -2037,7 +2066,6 @@ vim.ringbuf({size}) *vim.ringbuf()*
<
Returns a Ringbuf instance with the following methods:
-
• |Ringbuf:push()|
• |Ringbuf:pop()|
• |Ringbuf:peek()|
@@ -2049,27 +2077,6 @@ vim.ringbuf({size}) *vim.ringbuf()*
Return: ~
(`table`)
-vim.Ringbuf:clear() *Ringbuf:clear()*
- Clear all items.
-
-vim.Ringbuf:peek() *Ringbuf:peek()*
- Returns the first unread item without removing it
-
- Return: ~
- (`any?`)
-
-vim.Ringbuf:pop() *Ringbuf:pop()*
- Removes and returns the first unread item
-
- Return: ~
- (`any?`)
-
-vim.Ringbuf:push({item}) *Ringbuf:push()*
- Adds an item, overriding the oldest item if the buffer is full.
-
- Parameters: ~
- • {item} (`any`)
-
vim.spairs({t}) *vim.spairs()*
Enumerates key-value pairs of a table, ordered by key.
@@ -2080,7 +2087,8 @@ vim.spairs({t}) *vim.spairs()*
(`function`) |for-in| iterator over sorted keys and their values
See also: ~
- • Based on https://github.com/premake/premake-core/blob/master/src/base/table.lua
+ • Based on
+ https://github.com/premake/premake-core/blob/master/src/base/table.lua
vim.split({s}, {sep}, {opts}) *vim.split()*
Splits a string at each instance of a separator and returns the result as
@@ -2171,8 +2179,8 @@ vim.tbl_deep_extend({behavior}, {...}) *vim.tbl_deep_extend()*
Merges recursively two or more tables.
Parameters: ~
- • {behavior} (`string`) Decides what to do if a key is found in more
- than one map:
+ • {behavior} (`"error"|"keep"|"force"`) (string) Decides what to do if
+ a key is found in more than one map:
• "error": raise an error
• "keep": use value from the leftmost map
• "force": use value from the rightmost map
@@ -2209,7 +2217,7 @@ vim.tbl_filter({func}, {t}) *vim.tbl_filter()*
• {t} (`table`) Table
Return: ~
- (`table`) Table of filtered values
+ (`any[]`) Table of filtered values
vim.tbl_flatten({t}) *vim.tbl_flatten()*
Creates a copy of a list-like table such that any nested tables are
@@ -2222,7 +2230,8 @@ vim.tbl_flatten({t}) *vim.tbl_flatten()*
(`table`) Flattened copy of the given list-like table
See also: ~
- • From https://github.com/premake/premake-core/blob/master/src/base/table.lua
+ • From
+ https://github.com/premake/premake-core/blob/master/src/base/table.lua
vim.tbl_get({o}, {...}) *vim.tbl_get()*
Index into a table (first argument) via string keys passed as subsequent
@@ -2298,10 +2307,11 @@ vim.tbl_keys({t}) *vim.tbl_keys()*
• {t} (`table`) Table
Return: ~
- (`list`) List of keys
+ (`any[]`) List of keys
See also: ~
- • From https://github.com/premake/premake-core/blob/master/src/base/table.lua
+ • From
+ https://github.com/premake/premake-core/blob/master/src/base/table.lua
vim.tbl_map({func}, {t}) *vim.tbl_map()*
Apply a function to all values of a table.
@@ -2321,7 +2331,7 @@ vim.tbl_values({t}) *vim.tbl_values()*
• {t} (`table`) Table
Return: ~
- (`list`) List of values
+ (`any[]`) List of values
vim.trim({s}) *vim.trim()*
Trim whitespace (Lua pattern "%s") from both sides of a string.
@@ -2378,7 +2388,6 @@ vim.validate({opt}) *vim.validate()*
"string", "s", "number", "n", "boolean", "b", "function",
"f", "nil", "thread", "userdata") or list of them.
• optional: (optional) boolean, if true, `nil` is valid
-
2. (arg_value, fn, msg)
• arg_value: argument value
• fn: any function accepting one argument, returns true if
@@ -2422,7 +2431,7 @@ vim.loader.find({modname}, {opts}) *vim.loader.find()*
first one (defaults to `false`)
Return: ~
- (`list`) A list of results with the following properties:
+ (`table`) A list of results with the following properties:
• modpath: (string) the path to the module
• modname: (string) the name of the module
• stat: (table|nil) the fs_stat of the module path. Won't be returned
@@ -2632,9 +2641,9 @@ vim.filetype.add({filetypes}) *vim.filetype.add()*
['/etc/foo/config'] = 'toml',
},
pattern = {
- ['.*&zwj;/etc/foo/.*'] = 'fooscript',
+ ['.*/etc/foo/.*'] = 'fooscript',
-- Using an optional priority
- ['.*&zwj;/etc/foo/.*%.conf'] = { 'dosini', { priority = 10 } },
+ ['.*/etc/foo/.*%.conf'] = { 'dosini', { priority = 10 } },
-- A pattern containing an environment variable
['${XDG_CONFIG_HOME}/foo/git'] = 'git',
['README.(%a+)$'] = function(path, bufnr, ext)
@@ -2756,9 +2765,11 @@ vim.keymap.del({modes}, {lhs}, {opts}) *vim.keymap.del()*
<
Parameters: ~
- • {opts} (`table?`) A table of optional arguments:
- • "buffer": (integer|boolean) Remove a mapping from the given
- buffer. When `0` or `true`, use the current buffer.
+ • {modes} (`string|string[]`)
+ • {lhs} (`string`)
+ • {opts} (`table?`) A table of optional arguments:
+ • "buffer": (integer|boolean) Remove a mapping from the given
+ buffer. When `0` or `true`, use the current buffer.
See also: ~
• |vim.keymap.set()|
@@ -2789,7 +2800,6 @@ vim.keymap.set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()*
• Same as |nvim_set_keymap()| {opts}, except:
• "replace_keycodes" defaults to `true` if "expr" is `true`.
• "noremap": inverse of "remap" (see below).
-
• Also accepts:
• "buffer": (integer|boolean) Creates buffer-local mapping,
`0` or `true` for current buffer.
@@ -2971,7 +2981,8 @@ Lua module: vim.glob *vim.glob*
vim.glob.to_lpeg({pattern}) *vim.glob.to_lpeg()*
Parses a raw glob into an |lua-lpeg| pattern.
- This uses glob semantics from LSP 3.17.0: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#pattern
+ This uses glob semantics from LSP 3.17.0:
+ https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#pattern
Glob patterns can have the following syntax:
• `*` to match one or more characters in a path segment
@@ -3008,6 +3019,35 @@ The LPeg library for parsing expression grammars is included as `vim.lpeg`
In addition, its regex-like interface is available as |vim.re|
(https://www.inf.puc-rio.br/~roberto/lpeg/re.html).
+
+
+Pattern:match({subject}, {init}) *Pattern:match()*
+ 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)
+<
+
+ Parameters: ~
+ • {subject} (`string`)
+ • {init} (`integer?`)
+
+ Return: ~
+ (`integer|vim.lpeg.Capture?`)
+
vim.lpeg.B({pattern}) *vim.lpeg.B()*
Returns a pattern that matches only if the input string at the current
position is preceded by `patt`. Pattern `patt` must match only strings
@@ -3047,7 +3087,8 @@ vim.lpeg.C({patt}) *vim.lpeg.C()*
vim.lpeg.Carg({n}) *vim.lpeg.Carg()*
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` .
+ produces the value given as the nth extra argument given in the call to
+ `lpeg.match`.
Parameters: ~
• {n} (`integer`)
@@ -3192,11 +3233,40 @@ vim.lpeg.Ct({patt}) *vim.lpeg.Ct()*
the group name as its key. The captured value is only the table.
Parameters: ~
- • {patt} (vim.lpeg.Pattern |' `) @return (` vim.lpeg.Capture`)
+ • {patt} (`vim.lpeg.Pattern|''`)
-vim.lpeg.lpeg *vim.lpeg()*
- LPeg is a new pattern-matching library for Lua, based on Parsing Expression
- Grammars (PEGs).
+ Return: ~
+ (`vim.lpeg.Capture`)
+
+vim.lpeg.locale({tab}) *vim.lpeg.locale()*
+ 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')
+<
+
+ Parameters: ~
+ • {tab} (`table?`)
+
+ Return: ~
+ (`vim.lpeg.Locale`)
vim.lpeg.match({pattern}, {subject}, {init}) *vim.lpeg.match()*
Matches the given `pattern` against the `subject` string. If the match
@@ -3252,33 +3322,6 @@ vim.lpeg.P({value}) *vim.lpeg.P()*
Return: ~
(`vim.lpeg.Pattern`)
-vim.lpeg.Pattern:match({subject}, {init}) *Pattern:match()*
- 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)
-<
-
- Parameters: ~
- • {subject} (`string`)
- • {init} (`integer?`)
-
- Return: ~
- (`integer|vim.lpeg.Capture?`)
-
vim.lpeg.R({...}) *vim.lpeg.R()*
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
@@ -3300,10 +3343,10 @@ vim.lpeg.R({...}) *vim.lpeg.R()*
vim.lpeg.S({string}) *vim.lpeg.S()*
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("+-*&zwj;/")` 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.
+ `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.
Parameters: ~
• {string} (`string`)
@@ -3327,6 +3370,9 @@ vim.lpeg.type({value}) *vim.lpeg.type()*
Returns the string `"pattern"` if the given value is a pattern, otherwise
`nil`.
+ Parameters: ~
+ • {value} (`vim.lpeg.Pattern|string|integer|boolean|table|function`)
+
Return: ~
(`"pattern"?`)
@@ -3357,13 +3403,13 @@ vim.lpeg.version() *vim.lpeg.version()*
==============================================================================
VIM.RE *vim.re*
-
-The `vim.re` module provides a conventional regex-like syntax for pattern usage
-within LPeg |vim.lpeg|.
+The `vim.re` module provides a conventional regex-like syntax for pattern
+usage within LPeg |vim.lpeg|.
See https://www.inf.puc-rio.br/~roberto/lpeg/re.html for the original
documentation including regex syntax and more concrete examples.
+
vim.re.compile({string}, {defs}) *vim.re.compile()*
Compiles the given {string} and returns an equivalent LPeg pattern. The
given string may define either an expression or a grammar. The optional
@@ -3421,28 +3467,19 @@ vim.re.match({subject}, {pattern}, {init}) *vim.re.match()*
See also: ~
• vim.lpeg.match()
+vim.re.updatelocale() *vim.re.updatelocale()*
+ Updates the pre-defined character classes to the current locale.
+
==============================================================================
VIM.REGEX *vim.regex*
+Vim regexes can be used directly from Lua. Currently they only allow matching
+within a single line.
-Vim regexes can be used directly from Lua. Currently they only allow
-matching within a single line.
-
-
-vim.regex({re}) *vim.regex()*
- 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|.
-
- Parameters: ~
- • {re} (`string`)
-
- Return: ~
- (`vim.regex`)
*regex:match_line()*
-vim.regex:match_line({bufnr}, {line_idx}, {start}, {end_})
+regex:match_line({bufnr}, {line_idx}, {start}, {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
@@ -3454,16 +3491,28 @@ vim.regex:match_line({bufnr}, {line_idx}, {start}, {end_})
• {start} (`integer?`)
• {end_} (`integer?`)
-vim.regex:match_str({str}) *regex:match_str()*
+regex:match_str({str}) *regex:match_str()*
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
+ 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.
+ 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.
Parameters: ~
• {str} (`string`)
+vim.regex({re}) *vim.regex()*
+ 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|.
+
+ Parameters: ~
+ • {re} (`string`)
+
+ Return: ~
+ (`vim.regex`)
+
==============================================================================
Lua module: vim.secure *vim.secure*
@@ -3508,29 +3557,23 @@ vim.secure.trust({opts}) *vim.secure.trust()*
==============================================================================
Lua module: vim.version *vim.version*
-
-The `vim.version` module provides functions for comparing versions and
-ranges conforming to the
-
-https://semver.org
-
-spec. Plugins, and plugin managers, can use this to check available tools
-and dependencies on the current system.
+The `vim.version` module provides functions for comparing versions and ranges
+conforming to the https://semver.org spec. Plugins, and plugin managers, can
+use this to check available tools and dependencies on the current system.
Example: >lua
local v = vim.version.parse(vim.fn.system({'tmux', '-V'}), {strict=false})
if vim.version.gt(v, {3, 2, 0}) then
-- ...
end
-
<
*vim.version()* returns the version of the current Nvim process.
-VERSION RANGE SPEC *version-range*
+VERSION RANGE SPEC *version-range*
-A version "range spec" defines a semantic version range which can be
-tested against a version, using |vim.version.range()|.
+A version "range spec" defines a semantic version range which can be tested
+against a version, using |vim.version.range()|.
Supported range specs are shown in the following table. Note: suffixed
versions (1.2.3-rc1) are not matched. >
@@ -3561,9 +3604,9 @@ versions (1.2.3-rc1) are not matched. >
Partial left: missing pieces treated as 0 (1.2 => 1.2.0).
1.2 - 2.3.0 is 1.2.0 - 2.3.0
-
<
+
vim.version.cmp({v1}, {v2}) *vim.version.cmp()*
Parses and compares two version objects (the result of
|vim.version.parse()|, or specified literally as a `{major, minor, patch}`
@@ -3586,14 +3629,14 @@ vim.version.cmp({v1}, {v2}) *vim.version.cmp()*
Parameters: ~
• {v1} (`Version|number[]|string`) Version object.
- • {v2} (`Version|number[]|string`) Version to compare with `v1` .
+ • {v2} (`Version|number[]|string`) Version to compare with `v1`.
Return: ~
(`integer`) -1 if `v1 < v2`, 0 if `v1 == v2`, 1 if `v1 > v2`.
vim.version.eq({v1}, {v2}) *vim.version.eq()*
- Returns `true` if the given versions are equal. See |vim.version.cmp()| for
- usage.
+ Returns `true` if the given versions are equal. See |vim.version.cmp()|
+ for usage.
Parameters: ~
• {v1} (`Version|number[]|string`)
@@ -3603,7 +3646,7 @@ vim.version.eq({v1}, {v2}) *vim.version.eq()*
(`boolean`)
vim.version.ge({v1}, {v2}) *vim.version.ge()*
- Returns `true` if `v1 >= v2` . See |vim.version.cmp()| for usage.
+ Returns `true` if `v1 >= v2`. See |vim.version.cmp()| for usage.
Parameters: ~
• {v1} (`Version|number[]|string`)
@@ -3613,7 +3656,7 @@ vim.version.ge({v1}, {v2}) *vim.version.ge()*
(`boolean`)
vim.version.gt({v1}, {v2}) *vim.version.gt()*
- Returns `true` if `v1 > v2` . See |vim.version.cmp()| for usage.
+ Returns `true` if `v1 > v2`. See |vim.version.cmp()| for usage.
Parameters: ~
• {v1} (`Version|number[]|string`)
@@ -3632,7 +3675,7 @@ vim.version.last({versions}) *vim.version.last()*
(`Version?`)
vim.version.le({v1}, {v2}) *vim.version.le()*
- Returns `true` if `v1 <= v2` . See |vim.version.cmp()| for usage.
+ Returns `true` if `v1 <= v2`. See |vim.version.cmp()| for usage.
Parameters: ~
• {v1} (`Version|number[]|string`)
@@ -3642,7 +3685,7 @@ vim.version.le({v1}, {v2}) *vim.version.le()*
(`boolean`)
vim.version.lt({v1}, {v2}) *vim.version.lt()*
- Returns `true` if `v1 < v2` . See |vim.version.cmp()| for usage.
+ Returns `true` if `v1 < v2`. See |vim.version.cmp()| for usage.
Parameters: ~
• {v1} (`Version|number[]|string`)
@@ -3671,7 +3714,7 @@ vim.version.parse({version}, {opts}) *vim.version.parse()*
invalid.
See also: ~
- • # https://semver.org/spec/v2.0.0.html
+ • https://semver.org/spec/v2.0.0.html
vim.version.range({spec}) *vim.version.range()*
Parses a semver |version-range| "spec" and returns a range object: >
@@ -3702,35 +3745,30 @@ vim.version.range({spec}) *vim.version.range()*
• {spec} (`string`) Version range "spec"
See also: ~
- • # https://github.com/npm/node-semver#ranges
+ • https://github.com/npm/node-semver#ranges
==============================================================================
Lua module: vim.iter *vim.iter*
-
*vim.iter()* is an interface for |iterable|s: it wraps a table or function
argument into an *Iter* object with methods (such as |Iter:filter()| and
-|Iter:map()|) that transform the underlying source data. These methods can
-be chained to create iterator "pipelines": the output of each pipeline
-stage is input to the next stage. The first stage depends on the type
-passed to `vim.iter()`:
-
+|Iter:map()|) that transform the underlying source data. These methods can be
+chained to create iterator "pipelines": the output of each pipeline stage is
+input to the next stage. The first stage depends on the type passed to
+`vim.iter()`:
• List tables (arrays, |lua-list|) yield only the value of each element.
• Use |Iter:enumerate()| to also pass the index to the next stage.
• Or initialize with ipairs(): `vim.iter(ipairs(…))`.
-
-• Non-list tables (|lua-dict|) yield both the key and value of each
- element.
-• Function |iterator|s yield all values returned by the underlying
- function.
+• Non-list tables (|lua-dict|) yield both the key and value of each element.
+• Function |iterator|s yield all values returned by the underlying function.
• Tables with a |__call()| metamethod are treated as function iterators.
-The iterator pipeline terminates when the underlying |iterable| is
-exhausted (for function iterators this means it returned nil).
+The iterator pipeline terminates when the underlying |iterable| is exhausted
+(for function iterators this means it returned nil).
-Note: `vim.iter()` scans table input to decide if it is a list or a dict;
-to avoid this cost you can wrap the table with an iterator e.g.
+Note: `vim.iter()` scans table input to decide if it is a list or a dict; to
+avoid this cost you can wrap the table with an iterator e.g.
`vim.iter(ipairs({…}))`, but that precludes the use of |list-iterator|
operations such as |Iter:rev()|).
@@ -3771,13 +3809,13 @@ Examples: >lua
rb:push("b")
vim.iter(rb):totable()
-- { "a", "b" }
-
<
In addition to the |vim.iter()| function, the |vim.iter| module provides
convenience functions like |vim.iter.filter()| and |vim.iter.totable()|.
-filter({f}, {src}, {...}) *vim.iter.filter()*
+
+filter({f}, {src}) *vim.iter.filter()*
Filters a table or other |iterable|. >lua
-- Equivalent to:
vim.iter(src):filter(f):totable()
@@ -3839,11 +3877,11 @@ Iter:enumerate() *Iter:enumerate()*
Example: >lua
local it = vim.iter(vim.gsplit('abc', '')):enumerate()
it:next()
- -- 1 'a'
+ -- 1 'a'
it:next()
- -- 2 'b'
+ -- 2 'b'
it:next()
- -- 3 'c'
+ -- 3 'c'
<
Return: ~
@@ -3884,6 +3922,9 @@ Iter:find({f}) *Iter:find()*
-- 12
<
+ Parameters: ~
+ • {f} (`any`)
+
Return: ~
(`any`)
@@ -3926,7 +3967,7 @@ Iter:fold({init}, {f}) *Iter:fold()*
Parameters: ~
• {init} (`any`) Initial value of the accumulator.
- • {f} (`fun(acc:any, ...):any`) Accumulation function.
+ • {f} (`fun(acc:A, ...):A`) Accumulation function.
Return: ~
(`any`)
@@ -4105,11 +4146,14 @@ Iter:rfind({f}) *Iter:rfind()*
Examples: >lua
local it = vim.iter({ 1, 2, 3, 2, 1 }):enumerate()
it:rfind(1)
- -- 5 1
+ -- 5 1
it:rfind(1)
- -- 1 1
+ -- 1 1
<
+ Parameters: ~
+ • {f} (`any`)
+
Return: ~
(`any`)
@@ -4205,7 +4249,7 @@ Iter:totable() *Iter:totable()*
Return: ~
(`table`)
-map({f}, {src}, {...}) *vim.iter.map()*
+map({f}, {src}) *vim.iter.map()*
Maps a table or other |iterable|. >lua
-- Equivalent to:
vim.iter(src):map(f):totable()
@@ -4223,7 +4267,7 @@ map({f}, {src}, {...}) *vim.iter.map()*
See also: ~
• |Iter:map()|
-totable({f}, {...}) *vim.iter.totable()*
+totable({f}) *vim.iter.totable()*
Collects an |iterable| into a table. >lua
-- Equivalent to:
vim.iter(f):totable()
@@ -4249,8 +4293,9 @@ vim.snippet.exit() *vim.snippet.exit()*
Exits the current snippet.
vim.snippet.expand({input}) *vim.snippet.expand()*
- Expands the given snippet text. Refer to https://microsoft.github.io/language-server-protocol/specification/#snippet_syntax for
- the specification of valid input.
+ Expands the given snippet text. Refer to
+ https://microsoft.github.io/language-server-protocol/specification/#snippet_syntax
+ for the specification of valid input.
Tabstops are highlighted with hl-SnippetTabstop.
@@ -4317,4 +4362,5 @@ vim.text.hexencode({str}) *vim.text.hexencode()*
Return: ~
(`string`) Hex encoded string
+
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 8a3770bf27..09c086b7f7 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -933,6 +933,7 @@ get_filetypes({lang}) *vim.treesitter.language.get_filetypes()*
(`string[]`) filetypes
get_lang({filetype}) *vim.treesitter.language.get_lang()*
+
Parameters: ~
• {filetype} (`string`)
@@ -1056,14 +1057,13 @@ lint({buf}, {opts}) *vim.treesitter.query.lint()*
Use |treesitter-parsers| in runtimepath to check the query file in {buf}
for errors:
-
• verify that used nodes are valid identifiers in the grammar.
• verify that predicates and directives are valid.
• verify that top-level s-expressions are valid.
The found diagnostics are reported using |diagnostic-api|. By default, the
parser used for verification is determined by the containing folder of the
- query file, e.g., if the path ends in `/lua/highlights.scm` , the parser
+ query file, e.g., if the path ends in `/lua/highlights.scm`, the parser
for the `lua` language will be used.
Parameters: ~
@@ -1093,6 +1093,10 @@ omnifunc({findstart}, {base}) *vim.treesitter.query.omnifunc()*
vim.bo.omnifunc = 'v:lua.vim.treesitter.query.omnifunc'
<
+ Parameters: ~
+ • {findstart} (`0|1`)
+ • {base} (`string`)
+
parse({lang}, {query}) *vim.treesitter.query.parse()*
Parse {query} as a string. (If the query is in a file, the caller should
read the contents into a string before calling).
@@ -1218,42 +1222,36 @@ set({lang}, {query_name}, {text}) *vim.treesitter.query.set()*
==============================================================================
Lua module: vim.treesitter.languagetree *lua-treesitter-languagetree*
+A *LanguageTree* contains a tree of parsers: the root treesitter parser for
+{lang} and any "injected" language parsers, which themselves may inject other
+languages, recursively. For example a Lua buffer containing some Vimscript
+commands needs multiple parsers to fully understand its contents.
-A *LanguageTree* contains a tree of parsers: the root treesitter parser
-for {lang} and any "injected" language parsers, which themselves may
-inject other languages, recursively. For example a Lua buffer containing
-some Vimscript commands needs multiple parsers to fully understand its
-contents.
-
-To create a LanguageTree (parser object) for a given buffer and language,
-use: >lua
+To create a LanguageTree (parser object) for a given buffer and language, use: >lua
local parser = vim.treesitter.get_parser(bufnr, lang)
-
<
-(where `bufnr=0` means current buffer). `lang` defaults to 'filetype'.
-Note: currently the parser is retained for the lifetime of a buffer but
-this may change; a plugin should keep a reference to the parser object if
-it wants incremental updates.
+(where `bufnr=0` means current buffer). `lang` defaults to 'filetype'. Note:
+currently the parser is retained for the lifetime of a buffer but this may
+change; a plugin should keep a reference to the parser object if it wants
+incremental updates.
Whenever you need to access the current syntax tree, parse the buffer: >lua
local tree = parser:parse({ start_row, end_row })
-
<
-This returns a table of immutable |treesitter-tree| objects representing
-the current state of the buffer. When the plugin wants to access the state
-after a (possible) edit it must call `parse()` again. If the buffer wasn't
-edited, the same tree will be returned again without extra work. If the
-buffer was parsed before, incremental parsing will be done of the changed
-parts.
+This returns a table of immutable |treesitter-tree| objects representing the
+current state of the buffer. When the plugin wants to access the state after a
+(possible) edit it must call `parse()` again. If the buffer wasn't edited, the
+same tree will be returned again without extra work. If the buffer was parsed
+before, incremental parsing will be done of the changed parts.
+
+Note: To use the parser directly inside a |nvim_buf_attach()| Lua callback,
+you must call |vim.treesitter.get_parser()| before you register your callback.
+But preferably parsing shouldn't be done directly in the change callback
+anyway as they will be very frequent. Rather a plugin that does any kind of
+analysis on a tree should use a timer to throttle too frequent updates.
-Note: To use the parser directly inside a |nvim_buf_attach()| Lua
-callback, you must call |vim.treesitter.get_parser()| before you register
-your callback. But preferably parsing shouldn't be done directly in the
-change callback anyway as they will be very frequent. Rather a plugin that
-does any kind of analysis on a tree should use a timer to throttle too
-frequent updates.
LanguageTree:children() *LanguageTree:children()*
Returns a map of language to child tree.
@@ -1284,7 +1282,7 @@ LanguageTree:for_each_tree({fn}) *LanguageTree:for_each_tree()*
• {fn} (`fun(tree: TSTree, ltree: LanguageTree)`)
LanguageTree:included_regions() *LanguageTree:included_regions()*
- Gets the set of included regions managed by this LanguageTree . This can be
+ Gets the set of included regions managed by this LanguageTree. This can be
different from the regions set by injection query, because a partial
|LanguageTree:parse()| drops the regions outside the requested range.
@@ -1405,4 +1403,5 @@ LanguageTree:trees() *LanguageTree:trees()*
Return: ~
(`table<integer, TSTree>`)
+
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: