Skip to content

Commit 71c429a

Browse files
authored
Merge pull request #51 from declancm/keycode_fix
fix: don't use vim.keycode for compatibility
2 parents 41b2ef9 + 193db53 commit 71c429a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lua/cinnamon/scroll.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ H.execute_command = function(command)
122122
if type(command) == "string" then
123123
if command[1] == ":" then
124124
-- Ex (command-line) command
125-
vim.cmd(vim.keycode(command:sub(2)))
125+
vim.cmd(utils.keycode(command:sub(2)))
126126
elseif command ~= "" then
127127
-- Normal mode command
128128
if vim.v.count ~= 0 then
129-
vim.cmd("silent! normal! " .. vim.v.count .. vim.keycode(command))
129+
vim.cmd("silent! normal! " .. vim.v.count .. utils.keycode(command))
130130
else
131-
vim.cmd("silent! normal! " .. vim.keycode(command))
131+
vim.cmd("silent! normal! " .. utils.keycode(command))
132132
end
133133
end
134134
elseif type(command) == "function" then
@@ -180,9 +180,9 @@ H.scroll_view = function(direction, view_error, step_size)
180180
command = command .. step_size
181181
end
182182
if direction == "up" then
183-
command = command .. vim.keycode("<c-y>")
183+
command = command .. utils.keycode("<c-y>")
184184
elseif direction == "down" then
185-
command = command .. vim.keycode("<c-e>")
185+
command = command .. utils.keycode("<c-e>")
186186
elseif direction == "left" then
187187
command = command .. "zh"
188188
elseif direction == "right" then

lua/cinnamon/utils.lua

+6
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ M.notify = function(message, level, options)
1414
notify_fn("[cinnamon.nvim] " .. message, notify_level)
1515
end
1616

17+
---@param str string
18+
M.keycode = function(str)
19+
-- NOTE: This is a backwards-compatible vim.keycode
20+
return vim.api.nvim_replace_termcodes(str, true, true, true)
21+
end
22+
1723
return M

0 commit comments

Comments
 (0)