mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
feat(lua): vim.keycode (#22960)
Using nvim_replace_termcodes is too verbose, add vim.keycode for translating keycodes. Co-authored-by: ii14 <ii14@users.noreply.github.com>
This commit is contained in:
parent
c111460b1a
commit
7e70ca0b48
@ -1404,6 +1404,23 @@ inspect({object}, {options}) *vim.inspect()*
|
|||||||
• https://github.com/kikito/inspect.lua
|
• https://github.com/kikito/inspect.lua
|
||||||
• https://github.com/mpeterv/vinspect
|
• https://github.com/mpeterv/vinspect
|
||||||
|
|
||||||
|
keycode({str}) *vim.keycode()*
|
||||||
|
Translate keycodes.
|
||||||
|
|
||||||
|
Example: >lua
|
||||||
|
local k = vim.keycode
|
||||||
|
vim.g.mapleader = k'<bs>'
|
||||||
|
<
|
||||||
|
|
||||||
|
Parameters: ~
|
||||||
|
• {str} string String to be converted.
|
||||||
|
|
||||||
|
Return: ~
|
||||||
|
string
|
||||||
|
|
||||||
|
See also: ~
|
||||||
|
• |nvim_replace_termcodes()|
|
||||||
|
|
||||||
lua_omnifunc({find_start}, {_}) *vim.lua_omnifunc()*
|
lua_omnifunc({find_start}, {_}) *vim.lua_omnifunc()*
|
||||||
Omnifunc for completing lua values from from the runtime lua interpreter,
|
Omnifunc for completing lua values from from the runtime lua interpreter,
|
||||||
similar to the builtin completion for the `:lua` command.
|
similar to the builtin completion for the `:lua` command.
|
||||||
|
@ -37,6 +37,7 @@ The following new APIs or features were added.
|
|||||||
|
|
||||||
• |vim.iter()| provides a generic iterator interface for tables and Lua
|
• |vim.iter()| provides a generic iterator interface for tables and Lua
|
||||||
iterators |luaref-in|.
|
iterators |luaref-in|.
|
||||||
|
• Added |vim.keycode()| for translating keycodes in a string.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
CHANGED FEATURES *news-changed*
|
CHANGED FEATURES *news-changed*
|
||||||
|
@ -829,6 +829,20 @@ function vim.print(...)
|
|||||||
return ...
|
return ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Translate keycodes.
|
||||||
|
---
|
||||||
|
--- Example:
|
||||||
|
--- <pre>lua
|
||||||
|
--- local k = vim.keycode
|
||||||
|
--- vim.g.mapleader = k'<bs>'
|
||||||
|
--- </pre>
|
||||||
|
--- @param str string String to be converted.
|
||||||
|
--- @return string
|
||||||
|
--- @see |nvim_replace_termcodes()|
|
||||||
|
function vim.keycode(str)
|
||||||
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||||
|
end
|
||||||
|
|
||||||
function vim._cs_remote(rcid, server_addr, connect_error, args)
|
function vim._cs_remote(rcid, server_addr, connect_error, args)
|
||||||
local function connection_failure_errmsg(consequence)
|
local function connection_failure_errmsg(consequence)
|
||||||
local explanation
|
local explanation
|
||||||
|
Loading…
Reference in New Issue
Block a user