Skip to content

Commit

Permalink
Merge pull request #7 from luozhiya/feedkeys
Browse files Browse the repository at this point in the history
fix: feed keys in normal mode
  • Loading branch information
vladdoster committed Jun 12, 2023
2 parents 6b41763 + de38e7b commit 7385ec5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/remember.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local g = vim.g
local bo = vim.bo
local fn = vim.fn
local api = vim.api
local cmd = vim.cmd

local M = {}

Expand Down Expand Up @@ -76,20 +77,20 @@ function set_cursor_position()
-- the screen
elseif api.nvim_buf_line_count(0) - row > ((fn.line("w$") - fn.line("w0")) / 2) - 1 then
api.nvim_win_set_cursor(0, cursor_position)
api.nvim_input("zz")
cmd("norm! zz")

-- If we're at the end of the screen, set the cursor position and move
-- the window up by one with C-e. This is to show that we are at the end
-- of the file. If we did "zz" half the screen would be blank.
else
api.nvim_win_set_cursor(0, cursor_position)
api.nvim_input("<c-e>")
api.nvim_feedkeys(api.nvim_replace_termcodes("<c-e>", true, false, true), "n", false)
end
end

-- If the row is within a fold, make the row visible and recenter the screen
if api.nvim_eval("foldclosed('.')") ~= -1 and config["open_folds"] then
api.nvim_input("zvzz")
cmd("norm! zvzz")
end
end

Expand Down

0 comments on commit 7385ec5

Please sign in to comment.