aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/lua.txt
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-07-19 10:03:53 -0400
committerGitHub <noreply@github.com>2026-07-19 10:03:53 -0400
commit239125b8c8ae699beaf0753fd4042fdeb2da0ff5 (patch)
treed168ab826fcd0eded4691d6245f243d904ddbf05 /runtime/doc/lua.txt
parentf3ba77ab869375144369b9ad767182c56dd73910 (diff)
downloadrneovim-239125b8c8ae699beaf0753fd4042fdeb2da0ff5.tar.gz
rneovim-239125b8c8ae699beaf0753fd4042fdeb2da0ff5.tar.bz2
rneovim-239125b8c8ae699beaf0753fd4042fdeb2da0ff5.zip
feat(eval): declare more "fast" functions #40834
Diffstat (limited to 'runtime/doc/lua.txt')
-rw-r--r--runtime/doc/lua.txt40
1 files changed, 22 insertions, 18 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index c183a7e0cd..22b1e9e416 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1273,7 +1273,7 @@ vim.inspect() *vim.inspect()*
vim.keycode({keys}, {info}) *vim.keycode()*
Converts keys from |key-notation| to the internal encoding. Optionally
- returns structured key-chord info as retval 2.
+ returns structured *key-chord* info as retval 2.
Inverse of |keytrans()|, which converts the internal encoding back to
|key-notation|.
@@ -1347,33 +1347,36 @@ vim.notify_once({msg}, {level}, {opts}) *vim.notify_once()*
(`boolean`) true if message was displayed, else false
vim.on_key({fn}, {ns_id}, {opts}) *vim.on_key()*
- Adds Lua function {fn} with namespace id {ns_id} as a listener to every,
- yes every, input key.
+ Registers function {fn} with |namespace| {ns_id} as a listener to every,
+ yes EVERY, input key.
- The Nvim command-line option |-w| is related but does not support
- callbacks and cannot be toggled dynamically.
+ To parse |key-chord|s, see |vim.keycode()|. Example: >lua
+ local keychords = vim.keycode(vim.fn.keytrans(key), true)
+<
+
+ The |-w| command-line option is related but does not support callbacks and
+ cannot be toggled dynamically.
Note: ~
+ • If {fn} returns an empty string, {key} is discarded/ignored; if {key}
+ is <Cmd> then the "<Cmd>…<CR>" sequence is discarded as a whole.
+ • Non-recursive: if {fn} itself consumes input, it won't be invoked for
+ those keys.
+ • To UNregister a given {ns_id}, pass `nil` {fn}.
• {fn} will be removed on error.
- • {fn} won't be invoked recursively, i.e. if {fn} itself consumes input,
- it won't be invoked for those keys.
• {fn} will not be cleared by |nvim_buf_clear_namespace()|
Parameters: ~
• {fn} (`fun(key: string, typed: string): string??`) Function
invoked for every input key, after mappings have been applied
but before further processing. Arguments {key} and {typed}
- are raw keycodes, where {key} is the key after mappings are
- applied, and {typed} is the key(s) before mappings are
- applied. {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}. If {fn} returns an empty string, {key} is
- discarded/ignored, and if {key} is <Cmd> then the
- "<Cmd>…<CR>" sequence is discarded as a whole. When {fn} is
- `nil`, the callback associated with namespace {ns_id} is
- removed.
- • {ns_id} (`integer?`) Namespace ID. If nil or 0, generates and returns
- a new |nvim_create_namespace()| id.
+ are raw input (use |keytrans()| to get |keycodes|).
+ • {key} is the key after mappings are applied.
+ • {typed} is the input before mappings are applied; may be
+ empty if {key} was produced by non-typed key(s) or by the
+ same typed key(s) that produced a previous {key}.
+ • {ns_id} (`integer?`) Namespace ID. If nil or 0, returns a new
+ |namespace| id.
• {opts} (`table?`) Optional parameters
Return: ~
@@ -1382,6 +1385,7 @@ vim.on_key({fn}, {ns_id}, {opts}) *vim.on_key()*
See also: ~
• |keytrans()|
+ • |vim.keycode()|
vim.paste({lines}, {phase}) *vim.paste()*
Paste handler, invoked by |nvim_paste()|.