mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
docs(lua): clarify when on_key "typed" will be empty (#30774)
(cherry picked from commit 45f8f957c0
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
5480c0bd75
commit
27fca9c7d2
@@ -1643,12 +1643,15 @@ vim.on_key({fn}, {ns_id}) *vim.on_key()*
|
|||||||
• {fn} will not be cleared by |nvim_buf_clear_namespace()|
|
• {fn} will not be cleared by |nvim_buf_clear_namespace()|
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {fn} (`fun(key: string, typed: string)?`) Function invoked on
|
• {fn} (`fun(key: string, typed: string)?`) Function invoked for
|
||||||
every key press. |i_CTRL-V| {key} is the key after mappings
|
every input key, after mappings have been applied but before
|
||||||
have been applied, and {typed} is the key(s) before mappings
|
further processing. Arguments {key} and {typed} are raw
|
||||||
are applied, which may be empty if {key} is produced by
|
keycodes, where {key} is the key after mappings are applied,
|
||||||
non-typed keys. When {fn} is nil and {ns_id} is specified,
|
and {typed} is the key(s) before mappings are applied.
|
||||||
the callback associated with namespace {ns_id} is removed.
|
{typed} may be empty if {key} is produced by non-typed key(s)
|
||||||
|
or by the same typed key(s) that produced a previous {key}.
|
||||||
|
When {fn} is `nil` and {ns_id} is specified, the callback
|
||||||
|
associated with namespace {ns_id} is removed.
|
||||||
• {ns_id} (`integer?`) Namespace ID. If nil or 0, generates and returns
|
• {ns_id} (`integer?`) Namespace ID. If nil or 0, generates and returns
|
||||||
a new |nvim_create_namespace()| id.
|
a new |nvim_create_namespace()| id.
|
||||||
|
|
||||||
@@ -1656,6 +1659,9 @@ vim.on_key({fn}, {ns_id}) *vim.on_key()*
|
|||||||
(`integer`) Namespace id associated with {fn}. Or count of all
|
(`integer`) Namespace id associated with {fn}. Or count of all
|
||||||
callbacks if on_key() is called without arguments.
|
callbacks if on_key() is called without arguments.
|
||||||
|
|
||||||
|
See also: ~
|
||||||
|
• |keytrans()|
|
||||||
|
|
||||||
vim.paste({lines}, {phase}) *vim.paste()*
|
vim.paste({lines}, {phase}) *vim.paste()*
|
||||||
Paste handler, invoked by |nvim_paste()| when a conforming UI (such as the
|
Paste handler, invoked by |nvim_paste()| when a conforming UI (such as the
|
||||||
|TUI|) pastes text into the editor.
|
|TUI|) pastes text into the editor.
|
||||||
|
@@ -656,15 +656,18 @@ local on_key_cbs = {} --- @type table<integer,function>
|
|||||||
---@note {fn} will be removed on error.
|
---@note {fn} will be removed on error.
|
||||||
---@note {fn} will not be cleared by |nvim_buf_clear_namespace()|
|
---@note {fn} will not be cleared by |nvim_buf_clear_namespace()|
|
||||||
---
|
---
|
||||||
---@param fn fun(key: string, typed: string)?
|
---@param fn fun(key: string, typed: string)? Function invoked for every input key,
|
||||||
--- Function invoked on every key press. |i_CTRL-V|
|
--- after mappings have been applied but before further processing. Arguments
|
||||||
--- {key} is the key after mappings have been applied, and
|
--- {key} and {typed} are raw keycodes, where {key} is the key after mappings
|
||||||
--- {typed} is the key(s) before mappings are applied, which
|
--- are applied, and {typed} is the key(s) before mappings are applied.
|
||||||
--- may be empty if {key} is produced by non-typed keys.
|
--- {typed} may be empty if {key} is produced by non-typed key(s) or by the
|
||||||
--- When {fn} is nil and {ns_id} is specified, the callback
|
--- same typed key(s) that produced a previous {key}.
|
||||||
--- associated with namespace {ns_id} is removed.
|
--- When {fn} is `nil` and {ns_id} is specified, the callback associated with
|
||||||
|
--- namespace {ns_id} is removed.
|
||||||
---@param ns_id integer? Namespace ID. If nil or 0, generates and returns a
|
---@param ns_id integer? Namespace ID. If nil or 0, generates and returns a
|
||||||
--- new |nvim_create_namespace()| id.
|
--- new |nvim_create_namespace()| id.
|
||||||
|
---
|
||||||
|
---@see |keytrans()|
|
||||||
---
|
---
|
||||||
---@return integer Namespace id associated with {fn}. Or count of all callbacks
|
---@return integer Namespace id associated with {fn}. Or count of all callbacks
|
||||||
---if on_key() is called without arguments.
|
---if on_key() is called without arguments.
|
||||||
|
Reference in New Issue
Block a user