diff --git a/init.lua b/init.lua index 98527e6..55e3930 100644 --- a/init.lua +++ b/init.lua @@ -623,5 +623,7 @@ cmp.setup { -- Personnalisation require('bepo') require('mappings') +require('restore-position') + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/restore-position.lua b/lua/restore-position.lua new file mode 100644 index 0000000..c4b95c3 --- /dev/null +++ b/lua/restore-position.lua @@ -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, +})