Restore last position when opening a buffer

This commit is contained in:
Fabrice Mouhartem 2023-12-24 00:07:05 +01:00
parent b82fee49de
commit d2469628a5
2 changed files with 10 additions and 0 deletions

View File

@ -623,5 +623,7 @@ cmp.setup {
-- Personnalisation -- Personnalisation
require('bepo') require('bepo')
require('mappings') require('mappings')
require('restore-position')
-- The line beneath this is called `modeline`. See `:help modeline` -- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et

8
lua/restore-position.lua Normal file
View File

@ -0,0 +1,8 @@
-- Restore cursor position
-- Adapted from https://stackoverflow.com/a/72939989/10585637
vim.api.nvim_create_autocmd({ "BufReadPost" }, {
pattern = { "*" },
callback = function()
vim.api.nvim_exec2('silent! normal! g`"zv', {})
end,
})