Co-authored-by: darkdi <rantovov5@gmail.com>
Co-authored-by: Qiaoxi Guo <28090444+breadtitor@users.noreply.github.com>
Co-authored-by: zaveshaa <zaveshaa@gmail.com>
This commit is contained in:
Justin M. Keyes
2026-08-23 12:38:07 -04:00
committed by GitHub
parent 211bef2315
commit 354ea3bf2a
18 changed files with 97 additions and 86 deletions

View File

@@ -391,7 +391,8 @@ was changed. The parameters received are ("changedtick", {buf}, {changedtick}).
*api-lua-detach*
In-process Lua callbacks can detach by returning `true`. This will detach all
callbacks attached with the same |nvim_buf_attach()| call.
callbacks attached with the same |nvim_buf_attach()| call without invoking the
"on_detach" callback.
==============================================================================
@@ -2179,7 +2180,8 @@ 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`).
that will trigger the handler (`callback` or `command`): one
handler is created for each event name.
• {opts} (`vim.api.keyset.create_autocmd?`) Options dict:
• buf (`integer?`) Buffer id for buffer-local autocommands
|autocmd-buflocal|. Not allowed with {pattern}.
@@ -2206,7 +2208,8 @@ nvim_create_autocmd({event}, {opts}) *nvim_create_autocmd()*
• nested (`boolean?`, default: false) Run nested autocommands
|autocmd-nested|.
• once (`boolean?`, default: false) Handle the event only
once |autocmd-once|.
once |autocmd-once|. If {event} is a list, each handler
will fire once.
• pattern (`string|array?`) Pattern(s) to match literally
|autocmd-pattern|.
@@ -2385,8 +2388,8 @@ nvim_buf_attach({buf}, {send_buffer}, {opts}) *nvim_buf_attach()*
• {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:
`:edit`, …), see `on_reload`. Returning
|lua-truthy| deletes the callback. Args:
• the string "bytes"
• buffer id
• b:changedtick
@@ -2409,13 +2412,15 @@ nvim_buf_attach({buf}, {send_buffer}, {opts}) *nvim_buf_attach()*
• the string "changedtick"
• buffer id
• b:changedtick
• on_detach: Called on detach. Args:
• on_detach: Called on detach, or when the buffer is
unloaded or deleted. Not called when a callback
returns |lua-truthy| to delete itself. Args:
• the string "detach"
• buffer id
• on_lines: Called on linewise changes. Not called on
buffer reload (`:checktime`, `:edit`, …), see
`on_reload:`. Return a |lua-truthy| value to detach.
Args:
`on_reload`. Returning |lua-truthy| deletes the
callback. Args:
• the string "lines"
• buffer id
• b:changedtick

View File

@@ -55,7 +55,8 @@ Vimscript commands are described below.
they execute in the order in which they were defined.
See |autocmd-nested| for [++nested].
*autocmd-once*
If [++once] is supplied the command is executed once,
If [++once] is supplied the command is executed once
(per {event}, which may be a comma-separated list),
then removed ("one shot").
The special pattern <buffer> or <buffer=N> defines a buffer-local autocommand.

View File

@@ -1189,7 +1189,7 @@ Also see |`=|.
7. Command-line window *cmdline-window* *cmdwin*
*command-line-window*
The command-line window ("cmdwin") is a buffer+window in which the command
line can be edited.
line can be edited. See also |:exmode|, a REPL-like mode based on the cmdwin.
OPEN *c_CTRL-F* *q:* *q/* *q?*

View File

@@ -6105,7 +6105,7 @@ To enable this feature (default opts shown): >lua
msg = { -- Options related to the message module.
---@type string|table<string, 'cmd'|'msg'|'pager'> Default message target
---or table mapping |ui-messages| kinds, triggers and IDs to a target.
---Table keys are are matched as a Lua pattern to the message ID. 'default'
---Table keys are matched as a Lua pattern to the message ID. 'default'
---mapping applies to any omitted kind: { default = 'cmd', progress = 'msg' }.
targets = 'cmd',
cmd = { -- Options related to messages in the cmdline window.

View File

@@ -100,28 +100,28 @@ entry name: |dir-buffer-mappings| resolve the line under the cursor against the
buffer name, so rewriting line text makes <CR> open a nonexistent path.
Sort directories last: >vim
autocmd User DirReadPost silent keeppatterns sort r /\/$/
autocmd User DirReadPost silent keeppatterns sort r /\/$/
<
Hide dot-prefixed entries: >vim
autocmd User DirReadPost silent keeppatterns g/^\./d _
autocmd User DirReadPost silent keeppatterns g/^\./d _
<
Sort by modification time, newest first: >lua
vim.api.nvim_create_autocmd('User', {
pattern = 'DirReadPost',
callback = function(args)
local dir = vim.api.nvim_buf_get_name(args.buf)
local names = vim.api.nvim_buf_get_lines(args.buf, 0, -1, true)
local mtime = {} --- @type table<string, integer>
for _, name in ipairs(names) do
local stat = vim.uv.fs_stat(vim.fs.joinpath(dir, name))
mtime[name] = stat and stat.mtime.sec or 0
end
table.sort(names, function(a, b)
return mtime[a] > mtime[b]
end)
vim.api.nvim_buf_set_lines(args.buf, 0, -1, true, names)
end,
})
vim.api.nvim_create_autocmd('User', {
pattern = 'DirReadPost',
callback = function(args)
local dir = vim.api.nvim_buf_get_name(args.buf)
local names = vim.api.nvim_buf_get_lines(args.buf, 0, -1, true)
local mtime = {} --- @type table<string, integer>
for _, name in ipairs(names) do
local stat = vim.uv.fs_stat(vim.fs.joinpath(dir, name))
mtime[name] = stat and stat.mtime.sec or 0
end
table.sort(names, function(a, b)
return mtime[a] > mtime[b]
end)
vim.api.nvim_buf_set_lines(args.buf, 0, -1, true, names)
end,
})
<
Decorating the listing *dir-decorate*
@@ -130,40 +130,40 @@ A |nvim_set_decoration_provider()| sets |extmarks| on the visible lines of
each redraw, so they survive reordering by a |DirReadPost| handler.
Classify each entry, and show where a symbolic link points: >lua
local ns = vim.api.nvim_create_namespace('my.dir.classify')
local glyph = {
fifo = '|', socket = '=', char = '%', block = '#',
}
vim.api.nvim_set_decoration_provider(ns, {
on_win = function(_, _, buf)
return vim.bo[buf].filetype == 'directory'
end,
on_range = function(_, _, buf, row)
local dir = vim.api.nvim_buf_get_name(buf)
local name = vim.api.nvim_buf_get_lines(buf, row, row + 1, true)[1]
local path = vim.fs.joinpath(dir, (name:gsub('/$', '')))
local stat = vim.uv.fs_lstat(path) or {}
local exe = stat.type == 'file'
and bit.band(stat.mode, tonumber('111', 8)) ~= 0
local char = glyph[stat.type] or (exe and '*')
if char then
vim.api.nvim_buf_set_extmark(buf, ns, row, #name, {
virt_text = { { char, 'Dimmed' } },
virt_text_pos = 'overlay',
ephemeral = true,
})
end
if stat.type == 'link' then
local target = vim.uv.fs_readlink(path) or '?'
vim.api.nvim_buf_set_extmark(buf, ns, row, 0, {
virt_text = { { '-> ' .. target, 'Dimmed' } },
virt_text_pos = 'eol',
ephemeral = true,
})
end
return row + 1
end,
})
local ns = vim.api.nvim_create_namespace('my.dir.classify')
local glyph = {
fifo = '|', socket = '=', char = '%', block = '#',
}
vim.api.nvim_set_decoration_provider(ns, {
on_win = function(_, _, buf)
return vim.bo[buf].filetype == 'directory'
end,
on_range = function(_, _, buf, row)
local dir = vim.api.nvim_buf_get_name(buf)
local name = vim.api.nvim_buf_get_lines(buf, row, row + 1, true)[1]
local path = vim.fs.joinpath(dir, (name:gsub('/$', '')))
local stat = vim.uv.fs_lstat(path) or {}
local exe = stat.type == 'file'
and bit.band(stat.mode, tonumber('111', 8)) ~= 0
local char = glyph[stat.type] or (exe and '*')
if char then
vim.api.nvim_buf_set_extmark(buf, ns, row, #name, {
virt_text = { { char, 'Dimmed' } },
virt_text_pos = 'overlay',
ephemeral = true,
})
end
if stat.type == 'link' then
local target = vim.uv.fs_readlink(path) or '?'
vim.api.nvim_buf_set_extmark(buf, ns, row, 0, {
virt_text = { { '-> ' .. target, 'Dimmed' } },
virt_text_pos = 'eol',
ephemeral = true,
})
end
return row + 1
end,
})
<
Replacing the directory browser *dir-disable*

View File

@@ -38,13 +38,12 @@ Repeating a Visual-mode command re-executes the captured keysequence,
selection included. See |visual-repeat|.
==============================================================================
Semantic repeat *cmdatom* *action-repeat*
Semantic repeat *action-repeat* *cmdatom* *excalibur*
The |CmdAtom| event is published on every user action. This avoids the need
for plugins to "announce" the repeatable unit, thus plugins like vim-repeat
aren't needed.
*excalibur*
`CmdAtom.lhs` is the high-level user input collected during an action,
including getchar() input. This is signficant: it reflects the semantic
intent. `CmdAtom.keys` reveals the low-level internal commands that were

View File

@@ -10,7 +10,7 @@
--- msg = { -- Options related to the message module.
--- ---@type string|table<string, 'cmd'|'msg'|'pager'> Default message target
--- ---or table mapping |ui-messages| kinds, triggers and IDs to a target.
--- ---Table keys are are matched as a Lua pattern to the message ID. 'default'
--- ---Table keys are matched as a Lua pattern to the message ID. 'default'
--- ---mapping applies to any omitted kind: { default = 'cmd', progress = 'msg' }.
--- targets = 'cmd',
--- cmd = { -- Options related to messages in the cmdline window.

View File

@@ -226,8 +226,8 @@ function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start
--- Not for Lua callbacks.
--- @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:
--- reload (`:checktime`, `:edit`, …), see `on_reload`. Returning [lua-truthy] deletes
--- the callback. Args:
--- - the string "bytes"
--- - buffer id
--- - b:changedtick
@@ -247,11 +247,12 @@ function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start
--- - the string "changedtick"
--- - buffer id
--- - b:changedtick
--- - on_detach: Called on detach. Args:
--- - on_detach: Called on detach, or when the buffer is unloaded or deleted. Not called
--- when a callback returns [lua-truthy] to delete itself. Args:
--- - the string "detach"
--- - buffer id
--- - on_lines: Called on linewise changes. Not called on buffer reload (`:checktime`,
--- `:edit`, …), see `on_reload:`. Return a [lua-truthy] value to detach. Args:
--- `:edit`, …), see `on_reload`. Returning [lua-truthy] deletes the callback. Args:
--- - the string "lines"
--- - buffer id
--- - b:changedtick
@@ -954,7 +955,8 @@ 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 event vim.api.keyset.events|vim.api.keyset.events[] Event(s) that will trigger the handler (`callback` or `command`): one handler is
--- created for each event name.
--- @param opts vim.api.keyset.create_autocmd? Options dict:
--- - buf (`integer?`) Buffer id for buffer-local autocommands `autocmd-buflocal`.
--- Not allowed with {pattern}.
@@ -972,7 +974,8 @@ function vim.api.nvim_create_augroup(name, opts) end
--- - desc (`string?`) Description (for documentation and troubleshooting).
--- - group (`string|integer?`) Group name or id to match against.
--- - nested (`boolean?`, default: false) Run nested autocommands `autocmd-nested`.
--- - once (`boolean?`, default: false) Handle the event only once `autocmd-once`.
--- - once (`boolean?`, default: false) Handle the event only once `autocmd-once`. If {event}
--- is a list, each handler will fire once.
--- - pattern (`string|array?`) Pattern(s) to match literally `autocmd-pattern`.
--- @return integer # Autocommand id (number)
function vim.api.nvim_create_autocmd(event, opts) end

View File

@@ -401,7 +401,7 @@ function M.compute_diff(
position_encoding
)
-- Find the last position changed in the previous and current buffer.
-- prev_end_range is sent to the server as as the end of the changed range.
-- prev_end_range is sent to the server as the end of the changed range.
-- curr_end_range is used to grab the changed text from the latest buffer.
local prev_end_range, curr_end_range = compute_end_range(
prev_lines,

View File

@@ -365,7 +365,8 @@ cleanup:
/// pattern = vim.fn.expand('~') .. '/some/path/*.py'
/// ```
///
/// @param event Event(s) that will trigger the handler (`callback` or `command`).
/// @param event Event(s) that will trigger the handler (`callback` or `command`): one handler is
/// created for each event name.
/// @param opts Options dict:
/// - buf (`integer?`) Buffer id for buffer-local autocommands |autocmd-buflocal|.
/// Not allowed with {pattern}.
@@ -383,7 +384,8 @@ cleanup:
/// - desc (`string?`) Description (for documentation and troubleshooting).
/// - group (`string|integer?`) Group name or id to match against.
/// - nested (`boolean?`, default: false) Run nested autocommands |autocmd-nested|.
/// - once (`boolean?`, default: false) Handle the event only once |autocmd-once|.
/// - once (`boolean?`, default: false) Handle the event only once |autocmd-once|. If {event}
/// is a list, each handler will fire once.
/// - pattern (`string|array?`) Pattern(s) to match literally |autocmd-pattern|.
///
/// @return Autocommand id (number)

View File

@@ -127,8 +127,8 @@ Integer nvim_buf_line_count(Buffer buf, Error *err)
/// Not for Lua callbacks.
/// @param opts 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:
/// reload (`:checktime`, `:edit`, …), see `on_reload`. Returning [lua-truthy] deletes
/// the callback. Args:
/// - the string "bytes"
/// - buffer id
/// - b:changedtick
@@ -148,11 +148,12 @@ Integer nvim_buf_line_count(Buffer buf, Error *err)
/// - the string "changedtick"
/// - buffer id
/// - b:changedtick
/// - on_detach: Called on detach. Args:
/// - on_detach: Called on detach, or when the buffer is unloaded or deleted. Not called
/// when a callback returns [lua-truthy] to delete itself. Args:
/// - the string "detach"
/// - buffer id
/// - on_lines: Called on linewise changes. Not called on buffer reload (`:checktime`,
/// `:edit`, …), see `on_reload:`. Return a [lua-truthy] value to detach. Args:
/// `:edit`, …), see `on_reload`. Returning [lua-truthy] deletes the callback. Args:
/// - the string "lines"
/// - buffer id
/// - b:changedtick

View File

@@ -2026,7 +2026,7 @@ bool tv_dict_watcher_remove(dict_T *const dict, const char *const key_pattern,
return true;
}
/// Test if `key` matches with with `watcher->key_pattern`
/// Test if `key` matches with `watcher->key_pattern`
///
/// @param[in] watcher Watcher to check key pattern from.
/// @param[in] key Key to check.

View File

@@ -268,7 +268,7 @@ static inline uint8_t tv_blob_get(const blob_T *const b, int idx)
/// Store the byte `c` at index `idx` in the blob.
///
/// @param[in] b Blob to index. Cannot be NULL.
/// @param[in] blob Blob to index. Cannot be NULL.
/// @param[in] idx Index in a blob. Must be valid.
/// @param[in] c Value to store.
static inline void tv_blob_set(blob_T *const blob, int idx, uint8_t c)

View File

@@ -975,7 +975,7 @@ Array nlua_pop_Array(lua_State *lstate, Arena *arena, Error *err)
/// Convert Lua table to dictionary
///
/// Always pops one value from the stack. Does not check whether whether topmost
/// Always pops one value from the stack. Does not check whether topmost
/// value on the stack is a table.
///
/// @param lstate Lua interpreter state.

View File

@@ -39,7 +39,7 @@
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// Changes done by by the neovim project follow the Apache v2 license available
// Changes done by the neovim project follow the Apache v2 license available
// at the repo root.
#include <assert.h>

View File

@@ -2396,7 +2396,7 @@ static const char *did_set_laststatus(optset_T *args)
clear_cmdline = true;
}
// When switching from global statusline, increase height of topframe by STATUS_HEIGHT
// in order to to re-add the space that was previously taken by the global statusline
// in order to re-add the space that was previously taken by the global statusline
if (old_value == 3 && value != 3) {
frame_new_height(topframe, topframe->fr_height + STATUS_HEIGHT, false, false, false);
win_comp_pos();

View File

@@ -163,7 +163,7 @@ bool valid_yank_reg(int regname, bool writing)
/// clipboard register. This happens when `clipboard=unnamed[plus]` is set
/// and a provider is available.
///
/// @returns the name of of a clipboard register that should be used, or `NUL` if none.
/// @returns the name of a clipboard register that should be used, or `NUL` if none.
int get_default_register_name(void)
{
int name = NUL;

View File

@@ -823,7 +823,7 @@ static bool path_is_after(char *buf, size_t buflen)
{
// NOTE: we only consider dirs exactly matching "after" to be an AFTER dir.
// vim8 considers all dirs like "foo/bar_after", "Xafter" etc, as an
// "after" dir in SOME codepaths not not in ALL codepaths.
// "after" dir in SOME codepaths not in ALL codepaths.
return buflen >= 5
&& (!(buflen >= 6) || vim_ispathsep(buf[buflen - 6]))
&& strcmp(buf + buflen - 5, "after") == 0;