646bf84

Branches > main > 646bf84 > files

remove shortened aliases from nvim/center.lua

Grahp, 2026-02-26

Commit: 646bf8460ca6319f257b909c3067c866f9520984
Parent: 29e7bdf

1 changed file:

nvim/lua/center.lua modified (view file)

@@ -2,16 +2,14 @@ ---  including when at the top of a buffer. --- It does this by adding a bunch of fake virtual lines above the first line of the buf, ---  and scrolling the screen to the correct place-local api = vim.api-local ac = vim.api.nvim_create_autocmd-local ag = vim.api.nvim_create_augroup-local fn = vim.fn+local autocmd = vim.api.nvim_create_autocmd+local augroup = vim.api.nvim_create_augroup -local ns = api.nvim_create_namespace("dev.grahp.nvim.padding_lines")+local ns = vim.api.nvim_create_namespace("dev.grahp.nvim.padding_lines")  local function set_padding_lines(lines)-   api.nvim_buf_clear_namespace(0, ns, 0, -1)-   api.nvim_buf_set_extmark(0, ns, 0, 0, {+   vim.api.nvim_buf_clear_namespace(0, ns, 0, -1)+   vim.api.nvim_buf_set_extmark(0, ns, 0, 0, {       virt_lines = lines,       virt_lines_above = true    })@@ -34,17 +32,17 @@ --- Centers the screen, and then feeds enough <C-y>s to scroll the cursor to the very center of the screen --- If you're completely past the top of the buffer, just `zz` works and it won't scroll anything. local function center()-   local win_height = api.nvim_win_get_height(0)+   local win_height = vim.api.nvim_win_get_height(0)    local padding_lines = math.ceil(win_height / 2)     local blank_line = {{""}}     set_padding_lines(replicate(win_height, blank_line)) -   local _, _, col, off, curswant = unpack(fn.getcurpos())+   local _, _, col, off, curswant = unpack(vim.fn.getcurpos())    vim.cmd("norm! zz") -   local line_number = fn.line(".")+   local line_number = vim.fn.line(".")    local offset = padding_lines - line_number    if offset > 0 then      vim.cmd("norm! " .. offset .. "")@@ -52,12 +50,12 @@     -- 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})+   vim.fn.cursor({vim.fn.getcurpos()[2], col, off, curswant}) end  --- When moving the cursor, entering a buffer, etc., center the screen-ag("TopPad", {clear = true})-ac({ "BufWinEnter", "BufEnter", "WinResized", "WinScrolled", "CursorMoved", "CursorMovedI"}, {+augroup("TopPad", {clear = true})+autocmd({ "BufWinEnter", "BufEnter", "WinResized", "WinScrolled", "CursorMoved", "CursorMovedI"}, {   group = "TopPad",   callback = center, })