From 1b286b52c3e448acb709882792b04977afc993fe Mon Sep 17 00:00:00 2001 From: Thies Lennart Alff Date: Mon, 19 Feb 2024 11:06:08 +0100 Subject: [PATCH] jump to last position in nvim --- lua/lennartalff/set.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lennartalff/set.lua b/lua/lennartalff/set.lua index b57e57e..4c40164 100644 --- a/lua/lennartalff/set.lua +++ b/lua/lennartalff/set.lua @@ -31,3 +31,15 @@ vim.opt.scrolloff = 8 vim.opt.signcolumn = 'yes' vim.opt.updatetime = 500 vim.opt.colorcolumn = '80' + +vim.api.nvim_create_autocmd('BufReadPost', { + group = vim.g.user.event, + callback = function(args) + local valid_line = vim.fn.line([['"]]) >= 1 and vim.fn.line([['"]]) < vim.fn.line('$') + local not_commit = vim.b[args.buf].filetype ~= 'commit' + + if valid_line and not_commit then + vim.cmd([[normal! g`"]]) + end + end, +})