function center_cursor() local window_height = vim.api.nvim_win_get_height(0) local half_height = math.floor(window_height / 2) local first_line = vim.fn.line('w0') local pos = vim.fn.getpos('.') pos[2] = first_line + half_height vim.fn.setpos('.', pos) end