aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_editor.lua
diff options
context:
space:
mode:
authorii14 <59243201+ii14@users.noreply.github.com>2023-04-25 16:52:44 +0200
committerGitHub <noreply@github.com>2023-04-25 16:52:44 +0200
commit7e70ca0b4808bb9d8f19c28c8f93e8f2b9e0d0f0 (patch)
tree7ea008dc777940f715f1b47fc90da63f84a0c8d3 /runtime/lua/vim/_editor.lua
parentc111460b1a2686de3892a40f71e5ae21bdbae8b7 (diff)
downloadrneovim-7e70ca0b4808bb9d8f19c28c8f93e8f2b9e0d0f0.tar.gz
rneovim-7e70ca0b4808bb9d8f19c28c8f93e8f2b9e0d0f0.tar.bz2
rneovim-7e70ca0b4808bb9d8f19c28c8f93e8f2b9e0d0f0.zip
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>
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r--runtime/lua/vim/_editor.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index c922ec93db..20e813d77c 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -829,6 +829,20 @@ function vim.print(...)
return ...
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)
local function connection_failure_errmsg(consequence)
local explanation