53d95ad
Branches > main > 53d95ad > files / nvim / pack / plugins
Update center.lua
Commit: 53d95ad108a531bc6d9dfc895748c40c786fcd6f
Parent: a95eaa6
1 changed file:
nvim/lua/center.lua view file
@@ -41,20 +41,18 @@ set_padding_lines(replicate(win_height, blank_line)) - local _, lnum, col, off, curswant = unpack(fn.getcurpos())- --- TODO explain this schedule- vim.schedule(function()- vim.cmd("norm! zz")+ local _, _, col, off, curswant = unpack(fn.getcurpos())+ vim.cmd("norm! zz") - local line_number = fn.line(".")- local offset = padding_lines - line_number- if offset > 0 then- vim.cmd("norm! " .. offset .. "")- end+ local line_number = fn.line(".")+ local offset = padding_lines - line_number+ if offset > 0 then+ vim.cmd("norm! " .. offset .. "")+ end - -- Reset cursor back to the column it was at before- fn.cursor({vim.fn.getcurpos()[2], col, off, curswant})- end)+ -- Reset cursor back to the column it was at before+ -- Without this, zz and <C-y> muck up the cursor position when in insert mode+ fn.cursor({vim.fn.getcurpos()[2], col, off, curswant}) end --- When moving the cursor, entering a buffer, etc., center the screen