Restore last position when opening a buffer
This commit is contained in:
		
							
								
								
									
										2
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								lua/restore-position.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lua/restore-position.lua
									
									
									
									
									
										Normal 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,
 | 
			
		||||
})
 | 
			
		||||
		Reference in New Issue
	
	Block a user