mirror of
https://github.com/neovim/neovim.git
synced 2026-07-14 13:20:35 +00:00
Merge #40721 from justinmk/refactor
This commit is contained in:
@@ -508,16 +508,16 @@ Let's set an extmark at the first row (row=0) and third column (column=2).
|
||||
<
|
||||
>vim
|
||||
let g:mark_ns = nvim_create_namespace('myplugin')
|
||||
let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 2, {})
|
||||
let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 2)
|
||||
<
|
||||
We can get the mark by its id: >vim
|
||||
|
||||
echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id, {})
|
||||
echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id)
|
||||
" => [0, 2]
|
||||
|
||||
We can get all marks in a buffer by |namespace| (or by a range): >vim
|
||||
|
||||
echo nvim_buf_get_extmarks(0, g:mark_ns, 0, -1, {})
|
||||
echo nvim_buf_get_extmarks(0, g:mark_ns, 0, -1)
|
||||
" => [[1, 0, 2]]
|
||||
|
||||
Deleting all surrounding text does NOT remove an extmark! To remove extmarks
|
||||
@@ -528,7 +528,7 @@ use |nvim_buf_del_extmark()|. Deleting "x" in our example: >
|
||||
^ extmark position
|
||||
<
|
||||
>vim
|
||||
echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id, {})
|
||||
echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id)
|
||||
" => [0, 1]
|
||||
<
|
||||
Note: Extmark "gravity" decides how it will shift after a text edit.
|
||||
@@ -674,7 +674,7 @@ nvim_echo({chunks}, {history}, {opts}) *nvim_echo()*
|
||||
avoid unintentional conflicts.
|
||||
|
||||
Example: >lua
|
||||
vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true, {})
|
||||
vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true)
|
||||
<
|
||||
|
||||
Attributes: ~
|
||||
@@ -685,7 +685,7 @@ nvim_echo({chunks}, {history}, {opts}) *nvim_echo()*
|
||||
pairs, where each is a `text` string highlighted by the
|
||||
(optional) name or ID `hl_group`.
|
||||
• {history} (`boolean`) if true, add to |message-history|.
|
||||
• {opts} (`vim.api.keyset.echo_opts`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.echo_opts?`) Optional parameters.
|
||||
• data (`table?`) Dict of arbitrary data, available in
|
||||
|Progress| |event-data|.
|
||||
• err (`boolean?`) Treat the message like `:echoerr`. Sets
|
||||
@@ -725,7 +725,7 @@ nvim_eval_statusline({str}, {opts}) *nvim_eval_statusline()*
|
||||
|
||||
Parameters: ~
|
||||
• {str} (`string`) Statusline string (see 'statusline').
|
||||
• {opts} (`vim.api.keyset.eval_statusline`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.eval_statusline?`) Optional parameters.
|
||||
• fillchar: (string) Character to fill blank spaces in the
|
||||
statusline (see 'fillchars'). Treated as single-width even
|
||||
if it isn't.
|
||||
@@ -894,7 +894,7 @@ nvim_get_context({opts}) *nvim_get_context()*
|
||||
Since: 0.4.0
|
||||
|
||||
Parameters: ~
|
||||
• {opts} (`vim.api.keyset.context`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.context?`) Optional parameters.
|
||||
• types: List of |context-types| ("regs", "jumps", "bufs",
|
||||
"gvars", …) to gather, or empty for "all".
|
||||
|
||||
@@ -951,7 +951,7 @@ nvim_get_hl({ns_id}, {opts}) *nvim_get_hl()*
|
||||
• {ns_id} (`integer`) Get highlight groups for namespace ns_id
|
||||
|nvim_get_namespaces()|. Use 0 to get global highlight groups
|
||||
|:highlight|.
|
||||
• {opts} (`vim.api.keyset.get_highlight`) Options dict:
|
||||
• {opts} (`vim.api.keyset.get_highlight?`) Options dict:
|
||||
• create: (boolean, default true) When highlight group
|
||||
doesn't exist create it.
|
||||
• id: (integer) Get a highlight definition by id.
|
||||
@@ -985,7 +985,7 @@ nvim_get_hl_ns({opts}) *nvim_get_hl_ns()*
|
||||
Since: 0.10.0
|
||||
|
||||
Parameters: ~
|
||||
• {opts} (`vim.api.keyset.get_ns`) Optional parameters
|
||||
• {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
|
||||
@@ -1022,7 +1022,7 @@ nvim_get_mark({name}, {opts}) *nvim_get_mark()*
|
||||
|
||||
Parameters: ~
|
||||
• {name} (`string`) Mark name
|
||||
• {opts} (`vim.api.keyset.empty`) Optional parameters. Reserved for
|
||||
• {opts} (`vim.api.keyset.empty?`) Optional parameters. Reserved for
|
||||
future use.
|
||||
|
||||
Return: ~
|
||||
@@ -1283,7 +1283,7 @@ nvim_open_term({buf}, {opts}) *nvim_open_term()*
|
||||
ANSI termcodes, so you can use Nvim as a "scrollback pager" (for terminals
|
||||
like kitty): *ansi-colorize* *terminal-scrollback-pager* >lua
|
||||
vim.api.nvim_create_user_command('TermHl', function()
|
||||
vim.api.nvim_open_term(0, {})
|
||||
vim.api.nvim_open_term(0)
|
||||
end, { desc = 'Highlights ANSI termcodes in curbuf' })
|
||||
<
|
||||
|
||||
@@ -1294,7 +1294,7 @@ nvim_open_term({buf}, {opts}) *nvim_open_term()*
|
||||
Parameters: ~
|
||||
• {buf} (`integer`) Buffer which displays the PTY output. The initial
|
||||
buffer contents (if any) will be written to the PTY.
|
||||
• {opts} (`vim.api.keyset.open_term`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.open_term?`) Optional parameters.
|
||||
• force_crlf: (boolean, default true) Convert "\n" to "\r\n".
|
||||
• on_input: Lua callback for input sent, i e keypresses in
|
||||
terminal mode. Note: keypresses are sent raw as they would
|
||||
@@ -1419,7 +1419,7 @@ nvim_select_popupmenu_item({item}, {insert}, {finish}, {opts})
|
||||
|cmdline-completion|.
|
||||
• {finish} (`boolean`) Finish the completion and dismiss the popup
|
||||
menu. Implies {insert}.
|
||||
• {opts} (`vim.api.keyset.empty`) Optional parameters. Reserved for
|
||||
• {opts} (`vim.api.keyset.empty?`) Optional parameters. Reserved for
|
||||
future use.
|
||||
|
||||
*nvim_set_client_info()*
|
||||
@@ -1654,9 +1654,9 @@ nvim_set_keymap({mode}, {lhs}, {rhs}, {opts}) *nvim_set_keymap()*
|
||||
mode, or both, respectively
|
||||
• {lhs} (`string`) Left-hand-side |{lhs}| of the mapping.
|
||||
• {rhs} (`string`) Right-hand-side |{rhs}| of the mapping.
|
||||
• {opts} (`vim.api.keyset.keymap`) Optional parameters map: Accepts all
|
||||
|:map-arguments| as keys except <buffer>, values are booleans
|
||||
(default false). Also:
|
||||
• {opts} (`vim.api.keyset.keymap?`) Optional parameters map: Accepts
|
||||
all |:map-arguments| as keys except <buffer>, values are
|
||||
booleans (default false). Also:
|
||||
• "callback" Lua function called in place of {rhs}.
|
||||
• "desc" human-readable description.
|
||||
• "noremap" disables |recursive_mapping|, like |:noremap|
|
||||
@@ -1734,7 +1734,7 @@ nvim__complete_set({index}, {opts}) *nvim__complete_set()*
|
||||
|
||||
Parameters: ~
|
||||
• {index} (`integer`) Completion candidate index
|
||||
• {opts} (`vim.api.keyset.complete_set`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.complete_set?`) Optional parameters.
|
||||
• info: (string) info text.
|
||||
|
||||
Return: ~
|
||||
@@ -1777,7 +1777,7 @@ nvim__get_runtime({pat}, {all}, {opts}) *nvim__get_runtime()*
|
||||
Parameters: ~
|
||||
• {pat} (`string[]`) pattern of files to search for
|
||||
• {all} (`boolean`) whether to return all matches or only the first
|
||||
• {opts} (`vim.api.keyset.runtime`) is_lua: only search Lua subdirs
|
||||
• {opts} (`vim.api.keyset.runtime?`) is_lua: only search Lua subdirs
|
||||
|
||||
Return: ~
|
||||
(`string[]`) list of absolute paths to the found files
|
||||
@@ -1867,7 +1867,7 @@ nvim__redraw({opts}) *nvim__redraw()*
|
||||
Since: 0.10.0
|
||||
|
||||
Parameters: ~
|
||||
• {opts} (`vim.api.keyset.redraw`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.redraw?`) Optional parameters.
|
||||
• buf: Target a specific buffer number as described below.
|
||||
• cursor: Immediately update cursor position on the screen in
|
||||
`win` or the current window.
|
||||
@@ -1987,7 +1987,7 @@ nvim_exec2({src}, {opts}) *nvim_exec2()*
|
||||
|
||||
Parameters: ~
|
||||
• {src} (`string`) Vimscript code
|
||||
• {opts} (`vim.api.keyset.exec_opts`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.exec_opts?`) Optional parameters.
|
||||
• output: (boolean, default false) Whether to capture and
|
||||
return all (non-error, non-shell |:!|) output.
|
||||
|
||||
@@ -2093,7 +2093,7 @@ nvim_clear_autocmds({opts}) *nvim_clear_autocmds()*
|
||||
Since: 0.7.0
|
||||
|
||||
Parameters: ~
|
||||
• {opts} (`vim.api.keyset.clear_autocmds`) Optional parameters:
|
||||
• {opts} (`vim.api.keyset.clear_autocmds?`) Optional parameters:
|
||||
• buf: (`integer?`) Select |autocmd-buflocal| autocommands.
|
||||
Not allowed with {pattern}.
|
||||
• event: (`vim.api.keyset.events|vim.api.keyset.events[]?`)
|
||||
@@ -2123,7 +2123,7 @@ nvim_create_augroup({name}, {opts}) *nvim_create_augroup()*
|
||||
|
||||
Parameters: ~
|
||||
• {name} (`string`) Group name
|
||||
• {opts} (`vim.api.keyset.create_augroup`) Optional parameters:
|
||||
• {opts} (`vim.api.keyset.create_augroup?`) Optional parameters:
|
||||
• clear (`boolean?`, default: true) Clear existing commands in
|
||||
the group |autocmd-groups|.
|
||||
|
||||
@@ -2165,7 +2165,7 @@ nvim_create_autocmd({event}, {opts}) *nvim_create_autocmd()*
|
||||
Parameters: ~
|
||||
• {event} (`vim.api.keyset.events|vim.api.keyset.events[]`) Event(s)
|
||||
that will trigger the handler (`callback` or `command`).
|
||||
• {opts} (`vim.api.keyset.create_autocmd`) Options dict:
|
||||
• {opts} (`vim.api.keyset.create_autocmd?`) Options dict:
|
||||
• buf (`integer?`) Buffer id for buffer-local autocommands
|
||||
|autocmd-buflocal|. Not allowed with {pattern}.
|
||||
• callback (`function|string?`) Lua function (or Vimscript
|
||||
@@ -2256,7 +2256,7 @@ nvim_exec_autocmds({event}, {opts}) *nvim_exec_autocmds()*
|
||||
Parameters: ~
|
||||
• {event} (`vim.api.keyset.events|vim.api.keyset.events[]`) Event(s) to
|
||||
execute.
|
||||
• {opts} (`vim.api.keyset.exec_autocmds`) Optional filters:
|
||||
• {opts} (`vim.api.keyset.exec_autocmds?`) Optional filters:
|
||||
• buf (`integer?`) Buffer where the event is applied.
|
||||
|autocmd-buflocal| Not allowed with {pattern}.
|
||||
• data (`any`): Arbitrary data passed to the callback. See
|
||||
@@ -2296,7 +2296,7 @@ nvim_get_autocmds({opts}) *nvim_get_autocmds()*
|
||||
Since: 0.7.0
|
||||
|
||||
Parameters: ~
|
||||
• {opts} (`vim.api.keyset.get_autocmds`) Dict with at least one of
|
||||
• {opts} (`vim.api.keyset.get_autocmds?`) Dict with at least one of
|
||||
these keys:
|
||||
• buf: (`integer[]|integer?`) Buffer id or list of buffer ids,
|
||||
for buffer-local autocommands |autocmd-buflocal|. Not
|
||||
@@ -2367,7 +2367,7 @@ nvim_buf_attach({buf}, {send_buffer}, {opts}) *nvim_buf_attach()*
|
||||
`nvim_buf_lines_event`. Else the first notification
|
||||
will be `nvim_buf_changedtick_event`. Not for Lua
|
||||
callbacks.
|
||||
• {opts} (`vim.api.keyset.buf_attach`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.buf_attach?`) Optional parameters.
|
||||
• on_bytes: Called on granular changes (compared to
|
||||
on_lines). Not called on buffer reload (`:checktime`,
|
||||
`:edit`, …), see `on_reload:`. Return a
|
||||
@@ -2512,7 +2512,7 @@ nvim_buf_delete({buf}, {opts}) *nvim_buf_delete()*
|
||||
|
||||
Parameters: ~
|
||||
• {buf} (`integer`) Buffer id, or 0 for current buffer
|
||||
• {opts} (`vim.api.keyset.buf_delete`) Optional parameters. Keys:
|
||||
• {opts} (`vim.api.keyset.buf_delete?`) Optional parameters. Keys:
|
||||
• force: Force deletion, ignore unsaved changes.
|
||||
• unload: Unloaded only (|:bunload|), do not delete.
|
||||
|
||||
@@ -2667,7 +2667,7 @@ nvim_buf_get_text({buf}, {start_row}, {start_col}, {end_row}, {end_col},
|
||||
• {end_row} (`integer`) Last line index, inclusive
|
||||
• {end_col} (`integer`) Ending column (byte offset) on last line,
|
||||
exclusive
|
||||
• {opts} (`vim.api.keyset.empty`) Optional parameters. Currently
|
||||
• {opts} (`vim.api.keyset.empty?`) Optional parameters. Currently
|
||||
unused.
|
||||
|
||||
Return: ~
|
||||
@@ -2739,7 +2739,7 @@ nvim_buf_set_keymap({buf}, {mode}, {lhs}, {rhs}, {opts})
|
||||
• {mode} (`string`)
|
||||
• {lhs} (`string`)
|
||||
• {rhs} (`string`)
|
||||
• {opts} (`vim.api.keyset.keymap`)
|
||||
• {opts} (`vim.api.keyset.keymap?`)
|
||||
|
||||
See also: ~
|
||||
• |nvim_set_keymap()|
|
||||
@@ -2791,7 +2791,7 @@ nvim_buf_set_mark({buf}, {name}, {line}, {col}, {opts})
|
||||
• {name} (`string`) Mark name
|
||||
• {line} (`integer`) Line number
|
||||
• {col} (`integer`) Column/row number
|
||||
• {opts} (`vim.api.keyset.empty`) Optional parameters. Reserved for
|
||||
• {opts} (`vim.api.keyset.empty?`) Optional parameters. Reserved for
|
||||
future use.
|
||||
|
||||
Return: ~
|
||||
@@ -2872,7 +2872,7 @@ nvim_buf_create_user_command({buf}, {name}, {cmd}, {opts})
|
||||
• {buf} (`integer`) Buffer id, or 0 for current buffer.
|
||||
• {name} (`string`)
|
||||
• {cmd} (`any`)
|
||||
• {opts} (`vim.api.keyset.user_command`)
|
||||
• {opts} (`vim.api.keyset.user_command?`)
|
||||
|
||||
See also: ~
|
||||
• nvim_create_user_command
|
||||
@@ -2898,8 +2898,8 @@ nvim_buf_get_commands({buf}, {opts}) *nvim_buf_get_commands()*
|
||||
|
||||
Parameters: ~
|
||||
• {buf} (`integer`) Buffer id, or 0 for current buffer
|
||||
• {opts} (`vim.api.keyset.get_commands`) Optional parameters. Currently
|
||||
not used.
|
||||
• {opts} (`vim.api.keyset.get_commands?`) Optional parameters.
|
||||
Currently not used.
|
||||
|
||||
Return: ~
|
||||
(`vim.api.keyset.command_info`) Map of maps describing commands.
|
||||
@@ -2931,7 +2931,7 @@ nvim_cmd({cmd}, {opts}) *nvim_cmd()*
|
||||
same structure as the return value of |nvim_parse_cmd()|
|
||||
(except "addr", "nargs" and "nextcmd" are ignored). All keys
|
||||
except "cmd" are optional.
|
||||
• {opts} (`vim.api.keyset.cmd_opts`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.cmd_opts?`) Optional parameters.
|
||||
• output: (boolean, default false) Whether to return command
|
||||
output.
|
||||
|
||||
@@ -2982,7 +2982,7 @@ nvim_create_user_command({name}, {cmd}, {opts})
|
||||
• reg: (string) Register name, if any. <reg>
|
||||
• smods: (table) Command modifiers (structured), same as
|
||||
"mods" in |nvim_parse_cmd()|.
|
||||
• {opts} (`vim.api.keyset.user_command`) Optional flags:
|
||||
• {opts} (`vim.api.keyset.user_command?`) Optional flags:
|
||||
• `addr` |:command-addr|
|
||||
• `complete` |:command-complete| command or function
|
||||
|:command-completion-customlist|.
|
||||
@@ -3017,8 +3017,8 @@ nvim_get_commands({opts}) *nvim_get_commands()*
|
||||
Since: 0.3.0
|
||||
|
||||
Parameters: ~
|
||||
• {opts} (`vim.api.keyset.get_commands`) Optional parameters. Currently
|
||||
only supports {"builtin":false}
|
||||
• {opts} (`vim.api.keyset.get_commands?`) Optional parameters.
|
||||
Currently only supports {"builtin":false}
|
||||
|
||||
Return: ~
|
||||
(`table<string,vim.api.keyset.command_info>`) Map of maps describing
|
||||
@@ -3038,7 +3038,7 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
|
||||
|
||||
Parameters: ~
|
||||
• {str} (`string`) Command line string to parse. Cannot contain "\n".
|
||||
• {opts} (`vim.api.keyset.empty`) Optional parameters. Reserved for
|
||||
• {opts} (`vim.api.keyset.empty?`) Optional parameters. Reserved for
|
||||
future use.
|
||||
|
||||
Return: ~
|
||||
@@ -3146,7 +3146,7 @@ nvim_buf_get_extmark_by_id({buf}, {ns_id}, {id}, {opts})
|
||||
• {buf} (`integer`) Buffer id, or 0 for current buffer
|
||||
• {ns_id} (`integer`) Namespace id from |nvim_create_namespace()|
|
||||
• {id} (`integer`) Extmark id
|
||||
• {opts} (`vim.api.keyset.get_extmark`) Optional parameters. Keys:
|
||||
• {opts} (`vim.api.keyset.get_extmark?`) Optional parameters. Keys:
|
||||
• details: Whether to include the details dict
|
||||
• hl_name: Whether to include highlight group name instead of
|
||||
id, true if omitted
|
||||
@@ -3170,8 +3170,8 @@ nvim_buf_get_extmarks({buf}, {ns_id}, {start}, {end}, {opts})
|
||||
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}, {})
|
||||
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`, marks are returned in reverse order.
|
||||
@@ -3193,13 +3193,13 @@ nvim_buf_get_extmarks({buf}, {ns_id}, {start}, {end}, {opts})
|
||||
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, {})
|
||||
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, {})
|
||||
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}, {})
|
||||
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, {})
|
||||
local all = api.nvim_buf_get_extmarks(0, ns, 0, -1)
|
||||
vim.print(ms)
|
||||
<
|
||||
|
||||
@@ -3215,7 +3215,7 @@ nvim_buf_get_extmarks({buf}, {ns_id}, {start}, {end}, {opts})
|
||||
• {end} (`any`) End of range (inclusive): a 0-indexed (row, col) or
|
||||
valid extmark id (whose position defines the bound).
|
||||
|api-indexing|
|
||||
• {opts} (`vim.api.keyset.get_extmarks`) Optional parameters. Keys:
|
||||
• {opts} (`vim.api.keyset.get_extmarks?`) Optional parameters. Keys:
|
||||
• details: Whether to include the details dict
|
||||
• hl_name: Whether to include highlight group name instead of
|
||||
id, true if omitted
|
||||
@@ -3258,7 +3258,7 @@ nvim_buf_set_extmark({buf}, {ns_id}, {line}, {col}, {opts})
|
||||
|api-indexing|
|
||||
• {col} (`integer`) Column where to place the mark, 0-based.
|
||||
|api-indexing|
|
||||
• {opts} (`vim.api.keyset.set_extmark`) Optional parameters:
|
||||
• {opts} (`vim.api.keyset.set_extmark?`) Optional parameters:
|
||||
• conceal: (boolean|string)
|
||||
• string: Single char or empty string, enables conceal
|
||||
similar to |:syn-conceal|. Non-empty char is used as
|
||||
@@ -3450,7 +3450,7 @@ nvim_set_decoration_provider({ns_id}, {opts})
|
||||
|
||||
Parameters: ~
|
||||
• {ns_id} (`integer`) Namespace id from |nvim_create_namespace()|
|
||||
• {opts} (`vim.api.keyset.set_decoration_provider`) Table of
|
||||
• {opts} (`vim.api.keyset.set_decoration_provider?`) Table of
|
||||
callbacks:
|
||||
• on_buf: called for each buffer being redrawn (once per
|
||||
edit, before window callbacks) >
|
||||
@@ -3502,7 +3502,7 @@ nvim__ns_set({ns_id}, {opts}) *nvim__ns_set()*
|
||||
|
||||
Parameters: ~
|
||||
• {ns_id} (`integer`) Namespace
|
||||
• {opts} (`vim.api.keyset.ns_opts`) Optional parameters to set:
|
||||
• {opts} (`vim.api.keyset.ns_opts?`) Optional parameters to set:
|
||||
• wins: a list of windows to be scoped in
|
||||
|
||||
|
||||
@@ -3551,7 +3551,7 @@ nvim_get_option_info2({name}, {opts}) *nvim_get_option_info2()*
|
||||
|
||||
Parameters: ~
|
||||
• {name} (`string`) Option name
|
||||
• {opts} (`vim.api.keyset.option`) Optional parameters
|
||||
• {opts} (`vim.api.keyset.option?`) Optional parameters
|
||||
• buf: Buffer number. Used for getting buffer local options.
|
||||
Implies {scope} is "local".
|
||||
• scope: One of "global" or "local". Analogous to |:setglobal|
|
||||
@@ -3572,7 +3572,7 @@ nvim_get_option_value({name}, {opts}) *nvim_get_option_value()*
|
||||
|
||||
Parameters: ~
|
||||
• {name} (`string`) Option name
|
||||
• {opts} (`vim.api.keyset.option`) Optional parameters
|
||||
• {opts} (`vim.api.keyset.option?`) Optional parameters
|
||||
• buf: Buffer number. Used for getting buffer local options.
|
||||
Implies {scope} is "local".
|
||||
• filetype: |filetype|. Used to get the default option for a
|
||||
@@ -3602,7 +3602,7 @@ nvim_set_option_value({name}, {value}, {opts})
|
||||
Parameters: ~
|
||||
• {name} (`string`) Option name
|
||||
• {value} (`any`) New option value
|
||||
• {opts} (`vim.api.keyset.option`) Optional parameters
|
||||
• {opts} (`vim.api.keyset.option?`) Optional parameters
|
||||
• buf: Buffer number. Used for setting buffer local option.
|
||||
• dry_run: (`boolean?`, default: false) If true, then the
|
||||
option value won't be set.
|
||||
@@ -4275,7 +4275,7 @@ nvim_win_resize({win}, {width}, {height}, {opts}) *nvim_win_resize()*
|
||||
• {win} (`integer`) |window-ID|, or 0 for current window
|
||||
• {width} (`integer`) New width (columns), or -1 for "no change".
|
||||
• {height} (`integer`) New height (rows), or -1 for "no change".
|
||||
• {opts} (`vim.api.keyset.win_resize`) Optional parameters.
|
||||
• {opts} (`vim.api.keyset.win_resize?`) Optional parameters.
|
||||
• anchor: Edge that stays fixed while the opposite edge
|
||||
moves; the neighbor on the moving side is resized first.
|
||||
One of:
|
||||
@@ -4350,7 +4350,7 @@ nvim_win_text_height({win}, {opts}) *nvim_win_text_height()*
|
||||
|
||||
Parameters: ~
|
||||
• {win} (`integer`) |window-ID|, or 0 for current window.
|
||||
• {opts} (`vim.api.keyset.win_text_height`) Optional parameters:
|
||||
• {opts} (`vim.api.keyset.win_text_height?`) Optional parameters:
|
||||
• end_row: Ending line index, 0-based inclusive. When omitted
|
||||
end at the very bottom.
|
||||
• end_vcol: Ending virtual column index on "end_row", 0-based
|
||||
|
||||
@@ -685,7 +685,7 @@ takes three mandatory arguments:
|
||||
|
||||
Example:
|
||||
>lua
|
||||
vim.api.nvim_create_user_command('Test', 'echo "It works!"', {})
|
||||
vim.api.nvim_create_user_command('Test', 'echo "It works!"')
|
||||
vim.cmd.Test()
|
||||
--> It works!
|
||||
<
|
||||
|
||||
@@ -121,7 +121,7 @@ end
|
||||
---@param path string
|
||||
local function edit(path)
|
||||
navigating = true
|
||||
api.nvim_cmd({ cmd = 'edit', args = { path }, magic = { file = false, bar = false } }, {})
|
||||
api.nvim_cmd({ cmd = 'edit', args = { path }, magic = { file = false, bar = false } })
|
||||
navigating = false
|
||||
end
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ function M.apply_marks()
|
||||
invalidate = true,
|
||||
})
|
||||
|
||||
local mark_id = vim.api.nvim_buf_set_extmark(0, tutor_mark_ns, lnum - 1, 0, {})
|
||||
local mark_id = vim.api.nvim_buf_set_extmark(0, tutor_mark_ns, lnum - 1, 0)
|
||||
|
||||
-- Cannot edit field of a Vimscript dictionary from Lua directly, see `:h lua-vim-variables`
|
||||
---@type nvim.TutorExtmarks
|
||||
|
||||
@@ -68,7 +68,7 @@ local function get_comment_parts(ref_position)
|
||||
local cs = get_commentstring(ref_position)
|
||||
|
||||
if cs == nil or cs == '' then
|
||||
vim.api.nvim_echo({ { "Option 'commentstring' is empty.", 'WarningMsg' } }, true, {})
|
||||
vim.api.nvim_echo({ { "Option 'commentstring' is empty.", 'WarningMsg' } }, true)
|
||||
return { left = '', right = '' }
|
||||
end
|
||||
|
||||
|
||||
@@ -548,7 +548,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
local nvim_popupmenu_augroup = vim.api.nvim_create_augroup('nvim.popupmenu', {})
|
||||
local nvim_popupmenu_augroup = vim.api.nvim_create_augroup('nvim.popupmenu')
|
||||
nvim_on('MenuPopup', nvim_popupmenu_augroup, {
|
||||
pattern = '*',
|
||||
desc = 'Mouse popup menu',
|
||||
@@ -569,7 +569,7 @@ do
|
||||
end)
|
||||
end
|
||||
|
||||
local nvim_terminal_augroup = vim.api.nvim_create_augroup('nvim.terminal', {})
|
||||
local nvim_terminal_augroup = vim.api.nvim_create_augroup('nvim.terminal')
|
||||
vim.api.nvim_create_autocmd('BufReadCmd', {
|
||||
pattern = 'term://*',
|
||||
group = nvim_terminal_augroup,
|
||||
@@ -615,7 +615,7 @@ do
|
||||
local buf = vim.bo[ev.buf]
|
||||
local pos = ev.data.pos ---@type integer
|
||||
local buf_has_exitmsg = #(
|
||||
vim.api.nvim_buf_get_extmarks(ev.buf, nvim_terminal_exitmsg_ns, 0, -1, {})
|
||||
vim.api.nvim_buf_get_extmarks(ev.buf, nvim_terminal_exitmsg_ns, 0, -1)
|
||||
) > 0
|
||||
|
||||
-- `nvim_open_term` buffers do not have an attached 'channel'.
|
||||
@@ -749,11 +749,11 @@ do
|
||||
vim.api.nvim_create_autocmd('CmdwinEnter', {
|
||||
pattern = '[:>]',
|
||||
desc = 'Limit syntax sync to maxlines=1 in the command window',
|
||||
group = vim.api.nvim_create_augroup('nvim.cmdwin', {}),
|
||||
group = vim.api.nvim_create_augroup('nvim.cmdwin'),
|
||||
command = 'syntax sync minlines=1 maxlines=1',
|
||||
})
|
||||
|
||||
nvim_on('SwapExists', vim.api.nvim_create_augroup('nvim.swapfile', {}), {
|
||||
nvim_on('SwapExists', vim.api.nvim_create_augroup('nvim.swapfile'), {
|
||||
pattern = '*',
|
||||
desc = 'Skip the swapfile prompt when the swapfile is owned by a running Nvim process',
|
||||
}, function()
|
||||
@@ -796,7 +796,7 @@ do
|
||||
-- attached terminal, and a |TermResponse| is not attributable to a UI, so the
|
||||
-- value reflects whichever terminal answers last (decided by response speed),
|
||||
-- not necessarily the most recently attached one.
|
||||
local group = vim.api.nvim_create_augroup('nvim.tty', {})
|
||||
local group = vim.api.nvim_create_augroup('nvim.tty')
|
||||
|
||||
--- Set an option after startup (so that OptionSet is fired), but only if not
|
||||
--- already set by the user.
|
||||
@@ -805,7 +805,7 @@ do
|
||||
--- @param value any Option value
|
||||
--- @param force boolean? Always set the value, even if already set
|
||||
local function setoption(option, value, force)
|
||||
if not force and vim.api.nvim_get_option_info2(option, {}).was_set then
|
||||
if not force and vim.api.nvim_get_option_info2(option).was_set then
|
||||
-- Don't do anything if option is already set
|
||||
return
|
||||
end
|
||||
@@ -831,7 +831,7 @@ do
|
||||
|
||||
--- True if 'background' was set by the user, not by our detection (sid_lua).
|
||||
local function bg_user_set()
|
||||
local info = vim.api.nvim_get_option_info2('background', {})
|
||||
local info = vim.api.nvim_get_option_info2('background')
|
||||
return info.was_set and info.last_set_sid ~= sid_lua
|
||||
end
|
||||
|
||||
@@ -925,7 +925,7 @@ do
|
||||
local function detect_background(sync, chan)
|
||||
-- Re-create (clear) the handler's augroup on each call so only the
|
||||
-- most-recently-attached TUI's handler remains.
|
||||
local bg_group = vim.api.nvim_create_augroup('nvim.tty.background', {})
|
||||
local bg_group = vim.api.nvim_create_augroup('nvim.tty.background')
|
||||
|
||||
-- Send OSC 11 query. In the startup (sync) path also send a DSR probe: if
|
||||
-- the DSR response comes first, the terminal most likely doesn't support the
|
||||
@@ -1093,7 +1093,7 @@ do
|
||||
detect_termguicolors(tty)
|
||||
|
||||
-- Show progress bars in supporting terminals
|
||||
nvim_on('Progress', vim.api.nvim_create_augroup('nvim.progress', {}), {
|
||||
nvim_on('Progress', vim.api.nvim_create_augroup('nvim.progress'), {
|
||||
desc = 'Display native progress bars',
|
||||
}, function(ev)
|
||||
if ev.data.status == 'running' then
|
||||
@@ -1127,7 +1127,7 @@ do
|
||||
return nil
|
||||
end
|
||||
|
||||
nvim_on('UIEnter', vim.api.nvim_create_augroup('nvim.tty.attach', {}), {}, function()
|
||||
nvim_on('UIEnter', vim.api.nvim_create_augroup('nvim.tty.attach'), {}, function()
|
||||
local ui = attaching_tty()
|
||||
if not ui then
|
||||
return
|
||||
|
||||
@@ -485,9 +485,9 @@ local VIM_CMD_ARG_MAX = 20
|
||||
vim.cmd = setmetatable({}, {
|
||||
__call = function(_, cmd)
|
||||
if type(cmd) == 'table' then
|
||||
return vim.api.nvim_cmd(cmd, {})
|
||||
return vim.api.nvim_cmd(cmd)
|
||||
else
|
||||
vim.api.nvim_exec2(cmd, {})
|
||||
vim.api.nvim_exec2(cmd)
|
||||
return ''
|
||||
end
|
||||
end,
|
||||
@@ -515,7 +515,7 @@ vim.cmd = setmetatable({}, {
|
||||
opts = { args = { ... } }
|
||||
end
|
||||
opts.cmd = cmd
|
||||
return vim.api.nvim_cmd(opts, {})
|
||||
return vim.api.nvim_cmd(opts)
|
||||
end
|
||||
return t[cmd]
|
||||
end,
|
||||
|
||||
@@ -266,7 +266,7 @@ function M.ex_uptime()
|
||||
local now = assert(uv.clock_gettime('realtime'))
|
||||
local uptime = math.floor((now.sec * 1e9 + now.nsec - vim.v.starttime) / 1e9)
|
||||
local uptime_display = time.fmt_rtime(uptime)
|
||||
api.nvim_echo({ { N_('Up %s'):format(uptime_display) } }, true, {})
|
||||
api.nvim_echo({ { N_('Up %s'):format(uptime_display) } }, true)
|
||||
end
|
||||
|
||||
--- `:oldfiles` and `:browse oldfiles`. Lists v:oldfiles (plain `:oldfiles`) or shows (async)
|
||||
@@ -275,7 +275,7 @@ end
|
||||
function M.ex_oldfiles(eap)
|
||||
local files = vim.v.oldfiles
|
||||
if not files or #files == 0 then
|
||||
api.nvim_echo({ { N_('No old files') } }, false, {})
|
||||
api.nvim_echo({ { N_('No old files') } }, false)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -305,7 +305,7 @@ function M.ex_oldfiles(eap)
|
||||
if #lines == 0 then
|
||||
return
|
||||
end
|
||||
api.nvim_echo(lines, false, {})
|
||||
api.nvim_echo(lines, false)
|
||||
end
|
||||
|
||||
--- Verify that all plugins in a list are installed.
|
||||
@@ -390,7 +390,7 @@ end
|
||||
--- @param line string content of the current command line
|
||||
--- @return string[] completions
|
||||
function M.packdel_complete(pattern, line)
|
||||
local cmd = api.nvim_parse_cmd(line, {})
|
||||
local cmd = api.nvim_parse_cmd(line)
|
||||
if #cmd.args == 1 and vim.startswith(pattern, '++') then
|
||||
return { '++all' }
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ for _, file in ipairs(files) do
|
||||
if vim.endswith(file, '.lua') then
|
||||
assert(loadstring(trusted, '@' .. file))()
|
||||
else
|
||||
vim.api.nvim_exec2(trusted, {})
|
||||
vim.api.nvim_exec2(trusted)
|
||||
end
|
||||
end
|
||||
-- If the user unset 'exrc' in the current exrc then stop searching
|
||||
|
||||
@@ -129,7 +129,7 @@ end
|
||||
--- @param name string
|
||||
--- @return vim._option.Info
|
||||
local function get_options_info(name)
|
||||
local info = api.nvim_get_option_info2(name, {})
|
||||
local info = api.nvim_get_option_info2(name)
|
||||
--- @cast info vim._option.Info
|
||||
info.metatype = get_option_metatype(name, info)
|
||||
return info
|
||||
@@ -247,10 +247,10 @@ end
|
||||
--- ```
|
||||
vim.o = setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
return api.nvim_get_option_value(k, {})
|
||||
return api.nvim_get_option_value(k)
|
||||
end,
|
||||
__newindex = function(_, k, v)
|
||||
api.nvim_set_option_value(k, v, {})
|
||||
api.nvim_set_option_value(k, v)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
@@ -1515,7 +1515,7 @@ local get_context_state = function(context)
|
||||
for name, _ in
|
||||
pairs(context[scope] or {} --[[@as table<string,any>]])
|
||||
do
|
||||
local sc = scope == 'o' and scope_map[vim.api.nvim_get_option_info2(name, {}).scope] or scope
|
||||
local sc = scope == 'o' and scope_map[vim.api.nvim_get_option_info2(name).scope] or scope
|
||||
|
||||
-- Do not override already set state and fall back to `vim.NIL` for
|
||||
-- state `nil` values (which still needs restoring later)
|
||||
|
||||
@@ -80,7 +80,7 @@ function M.list_swaps(items)
|
||||
lines[#lines + 1] = { ('%d. %s\n'):format(i, format_swap(path)) }
|
||||
end
|
||||
end
|
||||
api.nvim_echo(lines, false, {})
|
||||
api.nvim_echo(lines, false)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -52,7 +52,7 @@ local api = vim.api
|
||||
local nvim_on = require('vim._core.util').nvim_on
|
||||
local M = {
|
||||
ns = api.nvim_create_namespace('nvim.ui2'),
|
||||
augroup = api.nvim_create_augroup('nvim.ui2', {}),
|
||||
augroup = api.nvim_create_augroup('nvim.ui2'),
|
||||
cmdheight = vim.o.cmdheight, -- 'cmdheight' option value set by user.
|
||||
redrawing = false, -- True when redrawing to display UI event.
|
||||
wins = { cmd = -1, dialog = -1, msg = -1, pager = -1 },
|
||||
@@ -147,7 +147,7 @@ function M.check_targets()
|
||||
|
||||
if type == 'pager' then
|
||||
-- Close pager with `q`, same as `checkhealth`
|
||||
api.nvim_buf_set_keymap(M.bufs.pager, 'n', 'q', '<Cmd>wincmd c<CR>', {})
|
||||
api.nvim_buf_set_keymap(M.bufs.pager, 'n', 'q', '<Cmd>wincmd c<CR>')
|
||||
elseif M.msg[type] then
|
||||
M.msg[type].prev_msg = '' -- Will no longer be visible.
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ local function win_config(win, hide, height)
|
||||
if ui.cmdheight == 0 and api.nvim_win_get_config(win).hide ~= hide then
|
||||
api.nvim_win_set_config(win, { hide = hide, height = not hide and height or nil })
|
||||
elseif api.nvim_win_get_height(win) ~= height then
|
||||
api.nvim_win_resize(win, -1, height, {})
|
||||
api.nvim_win_resize(win, -1, height)
|
||||
end
|
||||
if vim.o.cmdheight ~= height then
|
||||
-- Avoid moving the cursor with 'splitkeep' = "screen", and altering the user
|
||||
@@ -105,7 +105,7 @@ function M.cmdline_show(content, pos, firstc, prompt, indent, level, hl_id)
|
||||
set_text(content, ('%s%s%s'):format(firstc, prompt, (' '):rep(indent)), hl_id)
|
||||
ui.msg.virt.last = { {}, {}, {}, {} }
|
||||
|
||||
local height = math.max(ui.cmdheight, api.nvim_win_text_height(ui.wins.cmd, {}).all)
|
||||
local height = math.max(ui.cmdheight, api.nvim_win_text_height(ui.wins.cmd).all)
|
||||
win_config(ui.wins.cmd, false, height)
|
||||
M.cmdline_pos(pos)
|
||||
end
|
||||
|
||||
@@ -139,7 +139,7 @@ local function set_virttext(type, tgt)
|
||||
-- Check if adding the virt_text on this line will exceed the current window width.
|
||||
local maxwidth = math.max(M.msg.width, math.min(o.columns, scol - offset + width))
|
||||
if tgt == 'msg' and api.nvim_win_get_width(win) < maxwidth then
|
||||
api.nvim_win_resize(win, maxwidth, -1, {})
|
||||
api.nvim_win_resize(win, maxwidth, -1)
|
||||
M.msg.width = maxwidth
|
||||
end
|
||||
|
||||
@@ -293,7 +293,7 @@ function M.show_msg(tgt, kind, content, replace_last, append, id)
|
||||
if tgt == 'msg' then
|
||||
local width_cmd = [[echo max(map(range(1, line('$')), 'virtcol([v:val, "$"])'))]]
|
||||
local width = tonumber(fn.win_execute(ui.wins.msg, width_cmd)) - 1
|
||||
api.nvim_win_resize(ui.wins.msg, width, -1, {})
|
||||
api.nvim_win_resize(ui.wins.msg, width, -1)
|
||||
local texth = api.nvim_win_text_height(ui.wins.msg, { start_row = start_row, end_row = row })
|
||||
if texth.all > math.ceil(lines * 0.5) then
|
||||
tgt, buf = M.expand_msg(tgt)
|
||||
|
||||
@@ -66,7 +66,7 @@ end
|
||||
function M.wrapped_edit(file, mods)
|
||||
assert(mods)
|
||||
if type(mods) == 'string' then
|
||||
mods = vim.api.nvim_parse_cmd(mods .. ' edit', {}).mods --[[@as vim.api.keyset.cmd_mods]]
|
||||
mods = vim.api.nvim_parse_cmd(mods .. ' edit').mods --[[@as vim.api.keyset.cmd_mods]]
|
||||
end
|
||||
--- @cast mods vim.api.keyset.cmd_mods
|
||||
if (mods.tab or 0) > 0 or (mods.split or '') ~= '' or mods.horizontal or mods.vertical then
|
||||
|
||||
96
runtime/lua/vim/_meta/api.gen.lua
generated
96
runtime/lua/vim/_meta/api.gen.lua
generated
@@ -38,7 +38,7 @@ function vim.api.nvim__cmdwin_set(type, buf) end
|
||||
--- returns the window and buffer ids, or empty dict if not shown.
|
||||
---
|
||||
--- @param index integer Completion candidate index
|
||||
--- @param opts vim.api.keyset.complete_set Optional parameters.
|
||||
--- @param opts vim.api.keyset.complete_set? Optional parameters.
|
||||
--- - info: (string) info text.
|
||||
--- @return table<string,number> # Dict containing these keys:
|
||||
--- - winid: (number) floating window id
|
||||
@@ -56,7 +56,7 @@ function vim.api.nvim__get_lib_dir() end
|
||||
---
|
||||
--- @param pat string[] 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
|
||||
--- @param opts vim.api.keyset.runtime? is_lua: only search Lua subdirs
|
||||
--- @return string[] # list of absolute paths to the found files
|
||||
function vim.api.nvim__get_runtime(pat, all, opts) end
|
||||
|
||||
@@ -132,7 +132,7 @@ function vim.api.nvim__ns_get(ns_id) end
|
||||
--- Set some properties for namespace
|
||||
---
|
||||
--- @param ns_id integer Namespace
|
||||
--- @param opts vim.api.keyset.ns_opts Optional parameters to set:
|
||||
--- @param opts vim.api.keyset.ns_opts? Optional parameters to set:
|
||||
--- - wins: a list of windows to be scoped in
|
||||
function vim.api.nvim__ns_set(ns_id, opts) end
|
||||
|
||||
@@ -142,7 +142,7 @@ function vim.api.nvim__ns_set(ns_id, opts) end
|
||||
---
|
||||
---
|
||||
--- @see `:help :redraw`
|
||||
--- @param opts vim.api.keyset.redraw Optional parameters.
|
||||
--- @param opts vim.api.keyset.redraw? Optional parameters.
|
||||
--- - buf: Target a specific buffer number as described below.
|
||||
--- - cursor: Immediately update cursor position on the screen in
|
||||
--- `win` or the current window.
|
||||
@@ -224,7 +224,7 @@ function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start
|
||||
--- 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 vim.api.keyset.buf_attach Optional parameters.
|
||||
--- @param opts vim.api.keyset.buf_attach? Optional parameters.
|
||||
--- - on_bytes: Called on granular changes (compared to on_lines). Not called on buffer
|
||||
--- reload (`:checktime`, `:edit`, …), see `on_reload:`. Return a [lua-truthy] value
|
||||
--- to detach. Args:
|
||||
@@ -317,7 +317,7 @@ function vim.api.nvim_buf_clear_namespace(buf, ns_id, line_start, line_end) end
|
||||
--- @param buf integer Buffer id, or 0 for current buffer.
|
||||
--- @param name string
|
||||
--- @param cmd any
|
||||
--- @param opts vim.api.keyset.user_command
|
||||
--- @param opts vim.api.keyset.user_command?
|
||||
function vim.api.nvim_buf_create_user_command(buf, name, cmd, opts) end
|
||||
|
||||
--- Removes an `extmark`.
|
||||
@@ -374,7 +374,7 @@ function vim.api.nvim_buf_del_var(buf, name) end
|
||||
--- ```
|
||||
---
|
||||
--- @param buf integer Buffer id, or 0 for current buffer
|
||||
--- @param opts vim.api.keyset.buf_delete Optional parameters. Keys:
|
||||
--- @param opts vim.api.keyset.buf_delete? Optional parameters. Keys:
|
||||
--- - force: Force deletion, ignore unsaved changes.
|
||||
--- - unload: Unloaded only (`:bunload`), do not delete.
|
||||
function vim.api.nvim_buf_delete(buf, opts) end
|
||||
@@ -388,7 +388,7 @@ function vim.api.nvim_buf_get_changedtick(buf) end
|
||||
--- Gets a map of buffer-local `user-commands`.
|
||||
---
|
||||
--- @param buf integer Buffer id, or 0 for current buffer
|
||||
--- @param opts vim.api.keyset.get_commands Optional parameters. Currently not used.
|
||||
--- @param opts vim.api.keyset.get_commands? Optional parameters. Currently not used.
|
||||
--- @return vim.api.keyset.command_info # Map of maps describing commands.
|
||||
function vim.api.nvim_buf_get_commands(buf, opts) end
|
||||
|
||||
@@ -397,7 +397,7 @@ function vim.api.nvim_buf_get_commands(buf, opts) end
|
||||
--- @param buf integer Buffer id, or 0 for current buffer
|
||||
--- @param ns_id integer Namespace id from `nvim_create_namespace()`
|
||||
--- @param id integer Extmark id
|
||||
--- @param opts vim.api.keyset.get_extmark Optional parameters. Keys:
|
||||
--- @param opts vim.api.keyset.get_extmark? 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, integer, vim.api.keyset.extmark_details?] # 0-indexed (row, col, details?) tuple or empty list () if extmark id was absent. The
|
||||
@@ -417,8 +417,8 @@ function vim.api.nvim_buf_get_extmark_by_id(buf, ns_id, id, opts) end
|
||||
--- 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}, {})
|
||||
--- 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`, marks are returned in reverse order.
|
||||
@@ -442,13 +442,13 @@ function vim.api.nvim_buf_get_extmark_by_id(buf, ns_id, id, opts) end
|
||||
--- 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, {})
|
||||
--- 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, {})
|
||||
--- 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}, {})
|
||||
--- 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, {})
|
||||
--- local all = api.nvim_buf_get_extmarks(0, ns, 0, -1)
|
||||
--- vim.print(ms)
|
||||
--- ```
|
||||
---
|
||||
@@ -458,7 +458,7 @@ function vim.api.nvim_buf_get_extmark_by_id(buf, ns_id, id, opts) end
|
||||
--- (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:
|
||||
--- @param opts vim.api.keyset.get_extmarks? Optional parameters. Keys:
|
||||
--- - details: Whether to include the details dict
|
||||
--- - hl_name: Whether to include highlight group name instead of id, true if omitted
|
||||
--- - limit: Maximum number of marks to return
|
||||
@@ -556,7 +556,7 @@ function vim.api.nvim_buf_get_option(buffer, name) end
|
||||
--- @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 vim.api.keyset.empty Optional parameters. Currently unused.
|
||||
--- @param opts vim.api.keyset.empty? Optional parameters. Currently unused.
|
||||
--- @return string[] # Array of lines, or empty array for unloaded buffer.
|
||||
function vim.api.nvim_buf_get_text(buf, start_row, start_col, end_row, end_col, opts) end
|
||||
|
||||
@@ -611,7 +611,7 @@ function vim.api.nvim_buf_line_count(buf) end
|
||||
--- @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:
|
||||
--- @param opts vim.api.keyset.set_extmark? Optional parameters:
|
||||
--- - conceal: (boolean|string)
|
||||
--- - string: Single char or empty string, enables conceal similar to `:syn-conceal`.
|
||||
--- Non-empty char is used as `:syn-cchar`. Highlighted with "hl_group" if
|
||||
@@ -711,7 +711,7 @@ function vim.api.nvim_buf_set_extmark(buf, ns_id, line, col, opts) end
|
||||
--- @param mode string
|
||||
--- @param lhs string
|
||||
--- @param rhs string
|
||||
--- @param opts vim.api.keyset.keymap
|
||||
--- @param opts vim.api.keyset.keymap?
|
||||
function vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, opts) end
|
||||
|
||||
--- Sets (replaces) a line-range in the buffer.
|
||||
@@ -750,7 +750,7 @@ function vim.api.nvim_buf_set_lines(buf, start, end_, strict_indexing, replaceme
|
||||
--- @param name string Mark name
|
||||
--- @param line integer Line number
|
||||
--- @param col integer Column/row number
|
||||
--- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
|
||||
--- @param opts vim.api.keyset.empty? Optional parameters. Reserved for future use.
|
||||
--- @return boolean # true if the mark was set, else false.
|
||||
function vim.api.nvim_buf_set_mark(buf, name, line, col, opts) end
|
||||
|
||||
@@ -804,7 +804,7 @@ function vim.api.nvim_buf_set_var(buf, name, value) end
|
||||
--- @param src_id integer
|
||||
--- @param line integer
|
||||
--- @param chunks any[]
|
||||
--- @param opts vim.api.keyset.empty
|
||||
--- @param opts vim.api.keyset.empty?
|
||||
--- @return integer
|
||||
function vim.api.nvim_buf_set_virtual_text(buffer, src_id, line, chunks, opts) end
|
||||
|
||||
@@ -843,7 +843,7 @@ function vim.api.nvim_chan_send(chan, data) end
|
||||
|
||||
--- Clears all autocommands matching the {opts} query. To delete autocmds see `nvim_del_autocmd()`.
|
||||
---
|
||||
--- @param opts vim.api.keyset.clear_autocmds Optional parameters:
|
||||
--- @param opts vim.api.keyset.clear_autocmds? Optional parameters:
|
||||
--- - buf: (`integer?`) Select `autocmd-buflocal` autocommands. Not allowed with {pattern}.
|
||||
--- - event: (`vim.api.keyset.events|vim.api.keyset.events[]?`)
|
||||
--- Examples:
|
||||
@@ -883,7 +883,7 @@ function vim.api.nvim_clear_autocmds(opts) end
|
||||
--- @param cmd vim.api.keyset.cmd Command to execute, a Dict with the same structure as the return value of
|
||||
--- `nvim_parse_cmd()` (except "addr", "nargs" and "nextcmd" are ignored).
|
||||
--- All keys except "cmd" are optional.
|
||||
--- @param opts vim.api.keyset.cmd_opts Optional parameters.
|
||||
--- @param opts vim.api.keyset.cmd_opts? Optional parameters.
|
||||
--- - output: (boolean, default false) Whether to return command output.
|
||||
--- @return string # Command output (non-error, non-shell |:!|) if `output` is true, else empty string.
|
||||
function vim.api.nvim_cmd(cmd, opts) end
|
||||
@@ -916,7 +916,7 @@ function vim.api.nvim_command_output(command) end
|
||||
---
|
||||
--- @see `:help autocmd-groups`
|
||||
--- @param name string Group name
|
||||
--- @param opts vim.api.keyset.create_augroup Optional parameters:
|
||||
--- @param opts vim.api.keyset.create_augroup? Optional parameters:
|
||||
--- - clear (`boolean?`, default: true) Clear existing commands in the group `autocmd-groups`.
|
||||
--- @return integer # Group id.
|
||||
function vim.api.nvim_create_augroup(name, opts) end
|
||||
@@ -954,7 +954,7 @@ function vim.api.nvim_create_augroup(name, opts) end
|
||||
--- @see `:help autocommand`
|
||||
--- @see vim.api.nvim_del_autocmd
|
||||
--- @param event vim.api.keyset.events|vim.api.keyset.events[] Event(s) that will trigger the handler (`callback` or `command`).
|
||||
--- @param opts vim.api.keyset.create_autocmd Options dict:
|
||||
--- @param opts vim.api.keyset.create_autocmd? Options dict:
|
||||
--- - buf (`integer?`) Buffer id for buffer-local autocommands `autocmd-buflocal`.
|
||||
--- Not allowed with {pattern}.
|
||||
--- - callback (`function|string?`) Lua function (or Vimscript function name, if string)
|
||||
@@ -1025,7 +1025,7 @@ function vim.api.nvim_create_namespace(name) end
|
||||
--- - range: (number) Number of items in the command range: 0, 1, or 2. [<range>]
|
||||
--- - reg: (string) Register name, if any. [<reg>]
|
||||
--- - smods: (table) Command modifiers (structured), same as "mods" in `nvim_parse_cmd()`.
|
||||
--- @param opts vim.api.keyset.user_command Optional flags:
|
||||
--- @param opts vim.api.keyset.user_command? Optional flags:
|
||||
--- - `addr` `:command-addr`
|
||||
--- - `complete` `:command-complete` command or function `:command-completion-customlist`.
|
||||
--- - `count` `:command-count`
|
||||
@@ -1106,13 +1106,13 @@ function vim.api.nvim_del_var(name) end
|
||||
---
|
||||
--- Example:
|
||||
--- ```lua
|
||||
--- vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true, {})
|
||||
--- vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true)
|
||||
--- ```
|
||||
---
|
||||
--- @param chunks [string, integer|string?][] List of `[text, hl_group]` pairs, where each is a `text` string highlighted by
|
||||
--- the (optional) name or ID `hl_group`.
|
||||
--- @param history boolean if true, add to `message-history`.
|
||||
--- @param opts vim.api.keyset.echo_opts Optional parameters.
|
||||
--- @param opts vim.api.keyset.echo_opts? Optional parameters.
|
||||
--- - data (`table?`) Dict of arbitrary data, available in `Progress` `event-data`.
|
||||
--- - err (`boolean?`) Treat the message like `:echoerr`. Sets `hl_group` to `hl-ErrorMsg` by default.
|
||||
--- - id (`integer|string?`) Message-id returned by a previous `nvim_echo` call, or
|
||||
@@ -1153,7 +1153,7 @@ 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.
|
||||
--- @param opts vim.api.keyset.eval_statusline? Optional parameters.
|
||||
--- - 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.
|
||||
@@ -1194,7 +1194,7 @@ function vim.api.nvim_exec(src, output) end
|
||||
--- @see vim.api.nvim_command
|
||||
--- @see vim.api.nvim_cmd
|
||||
--- @param src string Vimscript code
|
||||
--- @param opts vim.api.keyset.exec_opts Optional parameters.
|
||||
--- @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> # Dict containing information about execution, with these keys:
|
||||
@@ -1205,7 +1205,7 @@ function vim.api.nvim_exec2(src, opts) end
|
||||
---
|
||||
--- @see `:help :doautocmd`
|
||||
--- @param event vim.api.keyset.events|vim.api.keyset.events[] Event(s) to execute.
|
||||
--- @param opts vim.api.keyset.exec_autocmds Optional filters:
|
||||
--- @param opts vim.api.keyset.exec_autocmds? Optional filters:
|
||||
--- - buf (`integer?`) Buffer where the event is applied. `autocmd-buflocal` Not allowed with {pattern}.
|
||||
--- - data (`any`): Arbitrary data passed to the callback. See `nvim_create_autocmd()`.
|
||||
--- - group (`string|integer?`) Group name or id to match against. `autocmd-groups`.
|
||||
@@ -1270,7 +1270,7 @@ function vim.api.nvim_get_all_options_info() end
|
||||
--- })
|
||||
--- ```
|
||||
---
|
||||
--- @param opts vim.api.keyset.get_autocmds Dict with at least one of these keys:
|
||||
--- @param opts vim.api.keyset.get_autocmds? Dict with at least one of these keys:
|
||||
--- - buf: (`integer[]|integer?`) Buffer id or list of buffer ids, for buffer-local autocommands
|
||||
--- `autocmd-buflocal`. Not allowed with {pattern}.
|
||||
--- - event: (`vim.api.keyset.events|vim.api.keyset.events[]?`) Event(s) to match `autocmd-events`.
|
||||
@@ -1347,14 +1347,14 @@ function vim.api.nvim_get_color_map() end
|
||||
---
|
||||
---
|
||||
--- @see vim.api.nvim_get_all_options_info
|
||||
--- @param opts vim.api.keyset.get_commands Optional parameters. Currently only supports
|
||||
--- @param opts vim.api.keyset.get_commands? Optional parameters. Currently only supports
|
||||
--- {"builtin":false}
|
||||
--- @return table<string,vim.api.keyset.command_info> # Map of maps describing commands.
|
||||
function vim.api.nvim_get_commands(opts) end
|
||||
|
||||
--- Gets a map of the current editor state.
|
||||
---
|
||||
--- @param opts vim.api.keyset.context Optional parameters.
|
||||
--- @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> # map of global |context|.
|
||||
@@ -1389,7 +1389,7 @@ function vim.api.nvim_get_current_win() end
|
||||
---
|
||||
--- @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:
|
||||
--- @param opts vim.api.keyset.get_highlight? Options dict:
|
||||
--- - create: (boolean, default true) When highlight group doesn't exist create it.
|
||||
--- - id: (integer) Get a highlight definition by id.
|
||||
--- - link: (boolean, default true) Show linked group name instead of effective definition `:hi-link`.
|
||||
@@ -1421,7 +1421,7 @@ 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
|
||||
--- @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
|
||||
@@ -1448,7 +1448,7 @@ function vim.api.nvim_get_keymap(mode) end
|
||||
--- @see vim.api.nvim_buf_set_mark
|
||||
--- @see vim.api.nvim_del_mark
|
||||
--- @param name string Mark name
|
||||
--- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
|
||||
--- @param opts vim.api.keyset.empty? Optional parameters. Reserved for future use.
|
||||
--- @return [integer, integer, integer, string] # 4-tuple (row, col, buffer, buffername), (0, 0, 0, '') if the mark is
|
||||
--- not set.
|
||||
function vim.api.nvim_get_mark(name, opts) end
|
||||
@@ -1499,7 +1499,7 @@ function vim.api.nvim_get_option_info(name) end
|
||||
--- explicitly specifying {scope} in the {opts} table.
|
||||
---
|
||||
--- @param name string Option name
|
||||
--- @param opts vim.api.keyset.option Optional parameters
|
||||
--- @param opts vim.api.keyset.option? Optional parameters
|
||||
--- - buf: Buffer number. Used for getting buffer local options.
|
||||
--- Implies {scope} is "local".
|
||||
--- - scope: One of "global" or "local". Analogous to
|
||||
@@ -1514,7 +1514,7 @@ function vim.api.nvim_get_option_info2(name, opts) end
|
||||
--- buffer or window, unless "buf" or "win" is set in {opts}.
|
||||
---
|
||||
--- @param name string Option name
|
||||
--- @param opts vim.api.keyset.option Optional parameters
|
||||
--- @param opts vim.api.keyset.option? Optional parameters
|
||||
--- - buf: Buffer number. Used for getting buffer local options.
|
||||
--- Implies {scope} is "local".
|
||||
--- - filetype: `filetype`. Used to get the default option for a
|
||||
@@ -1707,13 +1707,13 @@ function vim.api.nvim_open_tabpage(buf, enter, config) end
|
||||
---
|
||||
--- ```lua
|
||||
--- vim.api.nvim_create_user_command('TermHl', function()
|
||||
--- vim.api.nvim_open_term(0, {})
|
||||
--- vim.api.nvim_open_term(0)
|
||||
--- end, { desc = 'Highlights ANSI termcodes in curbuf' })
|
||||
--- ```
|
||||
---
|
||||
--- @param buf integer Buffer which displays the PTY output. The initial buffer contents (if any) will be
|
||||
--- written to the PTY.
|
||||
--- @param opts vim.api.keyset.open_term Optional parameters.
|
||||
--- @param opts vim.api.keyset.open_term? Optional parameters.
|
||||
--- - force_crlf: (boolean, default true) Convert "\n" to "\r\n".
|
||||
--- - 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
|
||||
@@ -1886,7 +1886,7 @@ function vim.api.nvim_out_write(str) end
|
||||
--- Doesn't check the validity of command arguments.
|
||||
---
|
||||
--- @param str string Command line string to parse. Cannot contain "\n".
|
||||
--- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
|
||||
--- @param opts vim.api.keyset.empty? Optional parameters. Reserved for future use.
|
||||
--- @return vim.api.keyset.cmd # Dict containing command information, with these keys:
|
||||
--- - cmd: (string) Command name.
|
||||
--- - range: (array) (optional) Command range ([<line1>] [<line2>]).
|
||||
@@ -2092,7 +2092,7 @@ function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end
|
||||
--- @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 vim.api.keyset.empty Optional parameters. Reserved for future use.
|
||||
--- @param opts vim.api.keyset.empty? Optional parameters. Reserved for future use.
|
||||
function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end
|
||||
|
||||
--- Sets the current window's buffer to `buf`.
|
||||
@@ -2151,7 +2151,7 @@ function vim.api.nvim_set_current_win(win) end
|
||||
--- Note: Callbacks will not run for `window-hidden`, as they are not redrawn.
|
||||
---
|
||||
--- @param ns_id integer Namespace id from `nvim_create_namespace()`
|
||||
--- @param opts vim.api.keyset.set_decoration_provider Table of callbacks:
|
||||
--- @param opts vim.api.keyset.set_decoration_provider? Table of callbacks:
|
||||
--- - on_buf: called for each buffer being redrawn (once per edit,
|
||||
--- before window callbacks)
|
||||
--- ```
|
||||
@@ -2283,7 +2283,7 @@ function vim.api.nvim_set_hl_ns_fast(ns_id) end
|
||||
--- "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>],
|
||||
--- @param opts vim.api.keyset.keymap? Optional parameters map: Accepts all `:map-arguments` as keys except [<buffer>],
|
||||
--- values are booleans (default false). Also:
|
||||
--- - "callback" Lua function called in place of {rhs}.
|
||||
--- - "desc" human-readable description.
|
||||
@@ -2306,7 +2306,7 @@ function vim.api.nvim_set_option(name, value) end
|
||||
---
|
||||
--- @param name string Option name
|
||||
--- @param value any New option value
|
||||
--- @param opts vim.api.keyset.option Optional parameters
|
||||
--- @param opts vim.api.keyset.option? Optional parameters
|
||||
--- - buf: Buffer number. Used for setting buffer local option.
|
||||
--- - dry_run: (`boolean?`, default: false) If true, then the
|
||||
--- option value won't be set.
|
||||
@@ -2518,7 +2518,7 @@ function vim.api.nvim_win_is_valid(win) end
|
||||
--- @param win integer `window-ID`, or 0 for current window
|
||||
--- @param width integer New width (columns), or -1 for "no change".
|
||||
--- @param height integer New height (rows), or -1 for "no change".
|
||||
--- @param opts vim.api.keyset.win_resize Optional parameters.
|
||||
--- @param opts vim.api.keyset.win_resize? Optional parameters.
|
||||
--- - anchor: Edge that stays fixed while the opposite edge moves; the
|
||||
--- neighbor on the moving side is resized first. One of:
|
||||
--- - "top" (default) or "bottom"
|
||||
@@ -2605,7 +2605,7 @@ function vim.api.nvim_win_set_width(win, width) end
|
||||
---
|
||||
--- @see `:help virtcol()` for text width.
|
||||
--- @param win integer `window-ID`, or 0 for current window.
|
||||
--- @param opts vim.api.keyset.win_text_height Optional parameters:
|
||||
--- @param opts vim.api.keyset.win_text_height? Optional parameters:
|
||||
--- - end_row: Ending line index, 0-based inclusive.
|
||||
--- When omitted end at the very bottom.
|
||||
--- - end_vcol: Ending virtual column index on "end_row",
|
||||
|
||||
@@ -1145,7 +1145,7 @@ function M.status(buf)
|
||||
return result_str
|
||||
end
|
||||
|
||||
nvim_on('DiagnosticChanged', api.nvim_create_augroup('nvim.diagnostic.status', {}), {
|
||||
nvim_on('DiagnosticChanged', api.nvim_create_augroup('nvim.diagnostic.status'), {
|
||||
desc = 'diagnostics component for the statusline',
|
||||
}, function(ev)
|
||||
if vim.fn.win_gettype(vim.fn.bufwinid(ev.buf)) == '' then
|
||||
|
||||
@@ -123,7 +123,7 @@ end
|
||||
--- @param opts vim.diagnostic.JumpOpts?
|
||||
local function goto_diagnostic(diagnostic, opts)
|
||||
if not diagnostic then
|
||||
api.nvim_echo({ { 'No more valid diagnostics to move to', 'WarningMsg' } }, true, {})
|
||||
api.nvim_echo({ { 'No more valid diagnostics to move to', 'WarningMsg' } }, true)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ local M = {}
|
||||
-- bufnr -> ns -> Diagnostic[]
|
||||
local diagnostic_cache = {} --- @type table<integer,table<integer,vim.Diagnostic[]?>>
|
||||
|
||||
local group = api.nvim_create_augroup('nvim.diagnostic.buf_wipeout', {})
|
||||
local group = api.nvim_create_augroup('nvim.diagnostic.buf_wipeout')
|
||||
setmetatable(diagnostic_cache, {
|
||||
--- @param t table<integer,vim.Diagnostic[]>
|
||||
--- @param bufnr integer
|
||||
|
||||
@@ -527,7 +527,7 @@ function M._inspect(opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.api.nvim_echo(chunks, true, {})
|
||||
vim.api.nvim_echo(chunks, true)
|
||||
end
|
||||
return stats
|
||||
end
|
||||
|
||||
@@ -644,7 +644,7 @@ function lsp.enable(name, enable)
|
||||
else
|
||||
-- Only ever create autocmd once to reuse computation of config merging.
|
||||
lsp_enable_autocmd_id = lsp_enable_autocmd_id
|
||||
or nvim_on('FileType', api.nvim_create_augroup('nvim.lsp.enable', {}), function(ev)
|
||||
or nvim_on('FileType', api.nvim_create_augroup('nvim.lsp.enable'), function(ev)
|
||||
lsp_enable_callback(ev.buf)
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -676,8 +676,8 @@ local function update_popup_window(winid, bufnr, kind)
|
||||
vim.wo[winid].conceallevel = 2
|
||||
vim.treesitter.start(bufnr, kind)
|
||||
end
|
||||
local all = api.nvim_win_text_height(winid, {}).all
|
||||
api.nvim_win_resize(winid, -1, all, {})
|
||||
local all = api.nvim_win_text_height(winid).all
|
||||
api.nvim_win_resize(winid, -1, all)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ local function update_ranges(bufnr, client_state)
|
||||
end
|
||||
|
||||
local r = assert(ranges[client_state.range_index])
|
||||
local replacement = api.nvim_buf_get_text(bufnr, r[2], r[3], r[4].end_row, r[4].end_col, {})
|
||||
local replacement = api.nvim_buf_get_text(bufnr, r[2], r[3], r[4].end_row, r[4].end_col)
|
||||
|
||||
if not string.match(table.concat(replacement, '\n'), client_state.word_pattern) then
|
||||
clear_ranges(bufnr, client_state)
|
||||
|
||||
@@ -9,7 +9,7 @@ local current_buf = api.nvim_get_current_buf
|
||||
local get_mode = api.nvim_get_mode
|
||||
|
||||
local ns = api.nvim_create_namespace('nvim.lsp.on_type_formatting')
|
||||
local augroup = api.nvim_create_augroup('nvim.lsp.on_type_formatting', {})
|
||||
local augroup = api.nvim_create_augroup('nvim.lsp.on_type_formatting')
|
||||
|
||||
local M = {}
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ function M.apply_text_edits(text_edits, bufnr, position_encoding, change_annotat
|
||||
-- make sure we don't go out of bounds
|
||||
pos[1] = math.min(pos[1], max)
|
||||
pos[2] = math.min(pos[2], #get_line(bufnr, pos[1] - 1))
|
||||
api.nvim_buf_set_mark(bufnr or 0, mark, pos[1], pos[2], {})
|
||||
api.nvim_buf_set_mark(bufnr or 0, mark, pos[1], pos[2])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -473,7 +473,7 @@ function M.rename(old_fname, new_fname, opts)
|
||||
return
|
||||
end
|
||||
-- no need to preserve if such a buffer is empty
|
||||
api.nvim_buf_delete(existing_buf, {})
|
||||
api.nvim_buf_delete(existing_buf)
|
||||
end
|
||||
|
||||
buf_rename[b] = { from = old_bname, to = new_bname }
|
||||
@@ -1625,7 +1625,7 @@ function M.open_floating_preview(contents, syntax, opts)
|
||||
local win_height = api.nvim_win_get_height(floating_winnr)
|
||||
local text_height = api.nvim_win_text_height(floating_winnr, { max_height = win_height }).all
|
||||
if text_height < win_height then
|
||||
api.nvim_win_resize(floating_winnr, -1, text_height, {})
|
||||
api.nvim_win_resize(floating_winnr, -1, text_height)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ function M.call(method, args)
|
||||
local ok, result = pcall(vim.fn['remote#host#Require'], 'legacy-perl-provider') ---@type any, any
|
||||
if not ok then
|
||||
s_err = result
|
||||
vim.api.nvim_echo({ { result, 'WarningMsg' } }, true, {})
|
||||
vim.api.nvim_echo({ { result, 'WarningMsg' } }, true)
|
||||
return
|
||||
end
|
||||
s_host = result
|
||||
|
||||
@@ -136,7 +136,7 @@ function M.call(method, args)
|
||||
local ok, result = pcall(vim.fn['remote#host#Require'], 'legacy-python3-provider') ---@type any, any
|
||||
if not ok then
|
||||
s_err = result
|
||||
vim.api.nvim_echo({ { result, 'WarningMsg' } }, true, {})
|
||||
vim.api.nvim_echo({ { result, 'WarningMsg' } }, true)
|
||||
return
|
||||
end
|
||||
s_host = result
|
||||
|
||||
@@ -24,7 +24,7 @@ function M.call(method, args)
|
||||
local ok, result = pcall(vim.fn['remote#host#Require'], 'legacy-ruby-provider') ---@type any, any
|
||||
if not ok then
|
||||
s_err = result
|
||||
vim.api.nvim_echo({ { result, 'WarningMsg' } }, true, {})
|
||||
vim.api.nvim_echo({ { result, 'WarningMsg' } }, true)
|
||||
return
|
||||
end
|
||||
s_host = result
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
--- Heads-up: |vim.snippet.jump()| re-registers them on every jump.
|
||||
|
||||
local G = vim.lsp._snippet_grammar
|
||||
local snippet_group = vim.api.nvim_create_augroup('nvim.snippet', {})
|
||||
local snippet_group = vim.api.nvim_create_augroup('nvim.snippet')
|
||||
local snippet_ns = vim.api.nvim_create_namespace('nvim.snippet')
|
||||
local hl_group = 'SnippetTabstop'
|
||||
local hl_group_active = 'SnippetTabstopActive'
|
||||
@@ -166,7 +166,7 @@ end
|
||||
function Tabstop:get_text()
|
||||
local range = self:get_range()
|
||||
return table.concat(
|
||||
vim.api.nvim_buf_get_text(self.bufnr, range[1], range[2], range[3], range[4], {}),
|
||||
vim.api.nvim_buf_get_text(self.bufnr, range[1], range[2], range[3], range[4]),
|
||||
'\n'
|
||||
)
|
||||
end
|
||||
|
||||
@@ -213,7 +213,7 @@ local function buf_range_get_text(buf, range)
|
||||
end_row = end_row - 1
|
||||
end
|
||||
|
||||
local lines = api.nvim_buf_get_text(buf, start_row, start_col, end_row, end_col, {})
|
||||
local lines = api.nvim_buf_get_text(buf, start_row, start_col, end_row, end_col)
|
||||
if append_newline then
|
||||
table.insert(lines, '')
|
||||
end
|
||||
|
||||
@@ -202,7 +202,7 @@ local M = {}
|
||||
---@type table<integer,TS.FoldInfo>
|
||||
local foldinfos = {}
|
||||
|
||||
local group = api.nvim_create_augroup('nvim.treesitter.fold', {})
|
||||
local group = api.nvim_create_augroup('nvim.treesitter.fold')
|
||||
|
||||
--- Update the folds in the windows that contain the buffer and use expr foldmethod (assuming that
|
||||
--- the user doesn't use different foldexpr for the same buffer).
|
||||
|
||||
@@ -353,7 +353,7 @@ function M.inspect_tree(opts)
|
||||
local win = api.nvim_get_current_win()
|
||||
local treeview, err = TSTreeView:new(buf, opts.lang)
|
||||
if err and err:match('no parser for lang') then
|
||||
api.nvim_echo({ { err, 'WarningMsg' } }, true, {})
|
||||
api.nvim_echo({ { err, 'WarningMsg' } }, true)
|
||||
return
|
||||
elseif not treeview then
|
||||
error(err)
|
||||
@@ -468,7 +468,7 @@ function M.inspect_tree(opts)
|
||||
nowait = true,
|
||||
})
|
||||
|
||||
local group = api.nvim_create_augroup('nvim.treesitter.dev', {})
|
||||
local group = api.nvim_create_augroup('nvim.treesitter.dev')
|
||||
|
||||
nvim_on('CursorMoved', group, { buf = b }, function()
|
||||
if not api.nvim_buf_is_loaded(buf) then
|
||||
@@ -647,7 +647,7 @@ function M.edit_query(lang)
|
||||
-- can infer the language later.
|
||||
api.nvim_buf_set_name(query_buf, string.format('%s/query_editor.scm', lang))
|
||||
|
||||
local group = api.nvim_create_augroup('nvim.treesitter.dev_edit', {})
|
||||
local group = api.nvim_create_augroup('nvim.treesitter.dev_edit')
|
||||
nvim_on({ 'TextChanged', 'InsertLeave' }, group, {
|
||||
buf = query_buf,
|
||||
desc = 'Update query editor diagnostics when the query changes',
|
||||
|
||||
@@ -471,7 +471,7 @@ local function on_range_impl(
|
||||
|
||||
if
|
||||
(metadata.conceal_lines or metadata[capture] and metadata[capture].conceal_lines)
|
||||
and #api.nvim_buf_get_extmarks(buf, ns, { start_row, 0 }, { start_row, 0 }, {}) == 0
|
||||
and #api.nvim_buf_get_extmarks(buf, ns, { start_row, 0 }, { start_row, 0 }) == 0
|
||||
then
|
||||
api.nvim_buf_set_extmark(buf, ns, start_row, 0, {
|
||||
end_line = end_row,
|
||||
|
||||
@@ -57,7 +57,7 @@ function M.paste(reg)
|
||||
)
|
||||
elseif res == -2 then
|
||||
-- Clear message area
|
||||
vim.api.nvim_echo({ { '' } }, false, {})
|
||||
vim.api.nvim_echo({ { '' } }, false)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
@@ -354,7 +354,20 @@ if arg[1] == '--test' then
|
||||
end
|
||||
end
|
||||
|
||||
--- Index of the `opts` parameter, which starts optional parameters.
|
||||
--- @param fn_params [string,string][] Raw `{type, name}` pairs of a parsed API function.
|
||||
--- @return integer? opts_idx 1-based index of `opts`, or nil.
|
||||
local function opts_index(fn_params)
|
||||
for i = 1, #fn_params do
|
||||
local c = typed_container:match(fn_params[i][1])
|
||||
if fn_params[i][2] == 'opts' and c and c[1] == 'Dict' then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
grammar = grammar --[[@as nvim.c_grammar]],
|
||||
typed_container = typed_container,
|
||||
opts_index = opts_index,
|
||||
}
|
||||
|
||||
@@ -192,6 +192,17 @@ local function process_proto(item, state)
|
||||
table.remove(cur_obj.params, i)
|
||||
end
|
||||
end
|
||||
|
||||
-- HACK: Mark optional params (:help api-contract) with "?" so docs render them as optional.
|
||||
if c_grammar.opts_index(item.parameters) then
|
||||
local optional = false
|
||||
for _, p in ipairs(cur_obj.params) do
|
||||
optional = optional or p.name == 'opts'
|
||||
if optional and not p.type:match('%?$') then
|
||||
p.type = p.type .. '?'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -118,12 +118,7 @@ local function add_function(fn)
|
||||
fn.parameters[#fn.parameters] = nil
|
||||
end
|
||||
-- `opts` (a KeyDict) and every parameter following it are optional: clients may omit them.
|
||||
for k = 1, #fn.parameters do
|
||||
if fn.parameters[k][2] == 'opts' and real_type(fn.parameters[k][1]):match('^KeyDict_') then
|
||||
fn.opts_idx = k
|
||||
break
|
||||
end
|
||||
end
|
||||
fn.opts_idx = c_grammar.opts_index(fn.parameters)
|
||||
-- Omitted optional param is zero-initialized, which assumes Dict/Array.
|
||||
if fn.opts_idx then
|
||||
for k = fn.opts_idx + 1, #fn.parameters do
|
||||
|
||||
@@ -462,7 +462,7 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Arena
|
||||
is_numeric = true;
|
||||
count_value = first_arg.data.integer;
|
||||
} else if (first_arg.type == kObjectTypeString) {
|
||||
// Try to parse string as a number Example: vim.api.nvim_cmd({cmd = 'copen', args = {'10'}}, {})
|
||||
// Try to parse string as a number Example: vim.api.nvim_cmd({cmd = 'copen', args = {'10'}})
|
||||
char *endptr = first_arg.data.string.data;
|
||||
long val = getdigits_long(&endptr, false, 0);
|
||||
// Check if entire string was consumed (valid number) and string is not empty
|
||||
|
||||
@@ -1010,7 +1010,7 @@ Object nvim_notify(String msg, Integer log_level, Dict opts, Arena *arena, Error
|
||||
|
||||
/// @deprecated
|
||||
///
|
||||
/// Use |nvim_win_resize()| instead, e.g., nvim_win_resize(win, -1, height, {})
|
||||
/// Use |nvim_win_resize()| instead, e.g., nvim_win_resize(win, -1, height)
|
||||
///
|
||||
/// Sets the window height.
|
||||
///
|
||||
@@ -1033,7 +1033,7 @@ void nvim_win_set_height(Window win, Integer height, Error *err)
|
||||
|
||||
/// @deprecated
|
||||
///
|
||||
/// Use |nvim_win_resize()| instead, e.g., nvim_win_resize(win, width, -1, {})
|
||||
/// Use |nvim_win_resize()| instead, e.g., nvim_win_resize(win, width, -1)
|
||||
///
|
||||
/// Sets the window width. This will only succeed if the screen is split
|
||||
/// vertically.
|
||||
|
||||
@@ -240,8 +240,8 @@ nvim_buf_get_extmark_by_id(Buffer buf, Integer ns_id, Integer id, Dict(get_extma
|
||||
/// 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}, {})
|
||||
/// 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`, marks are returned in reverse order.
|
||||
@@ -265,13 +265,13 @@ nvim_buf_get_extmark_by_id(Buffer buf, Integer ns_id, Integer id, Dict(get_extma
|
||||
/// 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, {})
|
||||
/// 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, {})
|
||||
/// 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}, {})
|
||||
/// 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, {})
|
||||
/// local all = api.nvim_buf_get_extmarks(0, ns, 0, -1)
|
||||
/// vim.print(ms)
|
||||
/// ```
|
||||
///
|
||||
|
||||
@@ -806,7 +806,7 @@ void nvim_set_vvar(String name, Object value, Error *err)
|
||||
///
|
||||
/// Example:
|
||||
/// ```lua
|
||||
/// vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true, {})
|
||||
/// vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true)
|
||||
/// ```
|
||||
///
|
||||
/// @param chunks List of `[text, hl_group]` pairs, where each is a `text` string highlighted by
|
||||
@@ -1129,7 +1129,7 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err)
|
||||
///
|
||||
/// ```lua
|
||||
/// vim.api.nvim_create_user_command('TermHl', function()
|
||||
/// vim.api.nvim_open_term(0, {})
|
||||
/// vim.api.nvim_open_term(0)
|
||||
/// end, { desc = 'Highlights ANSI termcodes in curbuf' })
|
||||
/// ```
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user