diff --git a/nvim/lua/darcula/autocmds.lua b/nvim/lua/darcula/autocmds.lua index e53e78f..dd12048 100644 --- a/nvim/lua/darcula/autocmds.lua +++ b/nvim/lua/darcula/autocmds.lua @@ -22,16 +22,20 @@ local utils = require("darcula.utils") local group = utils.augroup_with_autocmd( "DarculaAutoCommands", - "BufReadPost", + "BufWinEnter", "*", - function() + function(args) + local bufnr = args.buf + if vim.b[bufnr]._darcula_cursor_restored then + return + end + vim.b[bufnr]._darcula_cursor_restored = true + local ft = vim.bo[bufnr].filetype + if ft == "commit" or ft == "fugitive" or ft == "gitcommit" or ft == "rebase" then + return + end local pos = vim.fn.line('\'"') - if - pos >= 1 and pos <= vim.fn.line("$") and vim.bo.filetype ~= "commit" and - vim.bo.filetype ~= "gitcommit" and - vim.bo.filetype ~= "fugitive" and - vim.bo.filetype ~= "rebase" - then + if pos >= 1 and pos <= vim.fn.line("$") then vim.cmd('normal! g`"') end end