From 43a97bc7ceef40c988ee9b3473913f6bc5c16868 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 31 Dec 2022 14:30:12 +0100 Subject: [PATCH] refactor(autocmds): simplified autocmd to jump to last location of file --- lua/config/autocmds.lua | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index f067f258..06309124 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -9,18 +9,9 @@ vim.api.nvim_create_autocmd("TextYankPost", { }) -- go to last loc when opening a buffer -vim.api.nvim_create_autocmd("BufReadPre", { - pattern = "*", +vim.api.nvim_create_autocmd("BufReadPost", { callback = function() - vim.api.nvim_create_autocmd("FileType", { - pattern = "", - once = true, - callback = function() - vim.cmd( - [[if &ft !~# 'commit\|rebase' && line("'\"") > 1 && line("'\"") <= line("$") | exe 'normal! g`"' | endif]] - ) - end, - }) + vim.cmd([[silent! normal! g`"]]) end, })