of the values from |vim.log.levels|.
• {opts} (`table?`) Optional parameters. Unused by default.
vim.notify_once({msg}, {level}, {opts}) *vim.notify_once()*
Displays a notification only one time.
Like |vim.notify()|, but subsequent calls with the same message will not
display a notification.
Parameters: ~
• {msg} (`string`) Content of the notification to show to the user.
• {level} (`integer?`) One of the values from |vim.log.levels|.
• {opts} (`table?`) Optional parameters. Unused by default.
Return: ~
(`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.
The Nvim command-line option |-w| is related but does not support
callbacks and cannot be toggled dynamically.
Note: ~
• {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. 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.
• {opts} (`table?`) Optional parameters
Return: ~
(`integer`) Namespace id associated with {fn}. Or count of all
callbacks if on_key() is called without arguments.
See also: ~
• |keytrans()|
vim.paste({lines}, {phase}) *vim.paste()*
Paste handler, invoked by |nvim_paste()|.
Note: This is provided only as a "hook", don't call it directly; call
|nvim_paste()| instead, which arranges redo (dot-repeat) and invokes
`vim.paste`.
Example: To remove ANSI color codes when pasting: >lua
vim.paste = (function(overridden)
return function(lines, phase)
for i,line in ipairs(lines) do
-- Scrub ANSI color codes from paste input.
lines[i] = line:gsub('\27%[[0-9;mK]+', '')
end
return overridden(lines, phase)
end
end)(vim.paste)
<
Parameters: ~
• {lines} (`string[]`) |readfile()|-style list of lines to paste.
|channel-lines|
• {phase} (`-1|1|2|3`) -1: "non-streaming" paste: the call contains all
lines. If paste is "streamed", `phase` indicates the stream
state:
• 1: starts the paste (exactly once)
• 2: continues the paste (zero or more times)
• 3: ends the paste (exactly once)
Return: ~
(`boolean`) result false if client should cancel the paste.
See also: ~
• |paste|
vim.print({...}) *vim.print()*
"Pretty prints" the given arguments and returns them unmodified.
Example: >lua
local hl_normal = vim.print(vim.api.nvim_get_hl(0, { name = 'Normal' }))
<
Parameters: ~
• {...} (`any`)
Return: ~
(`any`) given arguments.
See also: ~
• |vim.inspect()|
• |:=|
vim.schedule_wrap({fn})