Improves opening files on last position

main
zoomiti 4 months ago
parent cc03c50958
commit 5bb3238094

@ -266,26 +266,20 @@ vim.g.clipboard = {
} }
-- {{{ Return to last position in file -- {{{ Return to last position in file
vim.api.nvim_create_autocmd("BufRead", { vim.api.nvim_create_autocmd("BufWinEnter", {
pattern = "*",
callback = function() callback = function()
vim.api.nvim_create_autocmd("FileType", { local ft = vim.bo.filetype
buffer = 0, local last_pos = vim.fn.line("'\"")
once = true, local last_line = vim.fn.line("$")
callback = function()
local ft = vim.bo.filetype if not string.match(ft, "commit") and
local last_pos = vim.fn.line("'\"") not string.match(ft, "rebase") and
local last_line = vim.fn.line("$") last_pos > 1 and
last_pos <= last_line then
if not string.match(ft, "commit") and vim.cmd('silent! normal! g`"')
not string.match(ft, "rebase") and vim.cmd('silent! foldopen!')
last_pos > 1 and vim.cmd('silent! normal! zz')
last_pos <= last_line then end
vim.cmd('silent! normal! g`"')
end
end,
})
end, end,
}) ---}}} }) ---}}}

Loading…