From 58d9c16cb409e48a7be68c114b975a6444be8c70 Mon Sep 17 00:00:00 2001 From: Ihar Hancharenka Date: Thu, 1 Feb 2024 12:26:11 +0300 Subject: [PATCH] m --- os/editors/neovim/dist/nvchad/cfg.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/os/editors/neovim/dist/nvchad/cfg.txt b/os/editors/neovim/dist/nvchad/cfg.txt index 47703c6b8..0c9b89f09 100644 --- a/os/editors/neovim/dist/nvchad/cfg.txt +++ b/os/editors/neovim/dist/nvchad/cfg.txt @@ -6,3 +6,21 @@ https://github.com/NvChad/NvChad/issues/1868 samples https://github.com/creativenull/dotfiles/blob/main/config/nvim/init.lua +https://github.com/creativenull/dotfiles/blob/main/config/nvim/init.lua#L70 + last position restore + -- --- + -- When editing a file, always jump to the last known cursor position. + -- Don't do it when the position is invalid, when inside an event handler + -- (happens when dropping a file on gvim) and for a commit message (it's + -- likely a different one than last time). + 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, + })