Improves opening files on last position

main
zoomiti 4 months ago
parent cc03c50958
commit 5bb3238094

@ -266,13 +266,7 @@ 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()
vim.api.nvim_create_autocmd("FileType", {
buffer = 0,
once = true,
callback = function() callback = function()
local ft = vim.bo.filetype local ft = vim.bo.filetype
local last_pos = vim.fn.line("'\"") local last_pos = vim.fn.line("'\"")
@ -283,10 +277,10 @@ vim.api.nvim_create_autocmd("BufRead", {
last_pos > 1 and last_pos > 1 and
last_pos <= last_line then last_pos <= last_line then
vim.cmd('silent! normal! g`"') vim.cmd('silent! normal! g`"')
vim.cmd('silent! foldopen!')
vim.cmd('silent! normal! zz')
end end
end, end,
})
end,
}) ---}}} }) ---}}}
vim.keymap.set("x", "/", "<Esc>/\\%V", { desc = 'Search forward within visual selection' }) vim.keymap.set("x", "/", "<Esc>/\\%V", { desc = 'Search forward within visual selection' })

Loading…