fix(autocmds): last_loc autocmd didn't work correctly for first opened file

This commit is contained in:
Folke Lemaitre 2023-10-04 20:40:11 +02:00
parent 7272b3e4b5
commit 0cc80b1b05
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 5 additions and 1 deletions

View file

@ -32,6 +32,9 @@ vim.api.nvim_create_autocmd({ "VimResized" }, {
vim.api.nvim_create_autocmd("BufReadPost", { vim.api.nvim_create_autocmd("BufReadPost", {
group = augroup("last_loc"), group = augroup("last_loc"),
callback = function(event) callback = function(event)
if event.data and event.data.lazy_file then
return
end
local exclude = { "gitcommit" } local exclude = { "gitcommit" }
local buf = event.buf local buf = event.buf
if vim.tbl_contains(exclude, vim.bo[buf].filetype) then if vim.tbl_contains(exclude, vim.bo[buf].filetype) then

View file

@ -168,9 +168,10 @@ function M.lazy_file()
pattern = event.pattern, pattern = event.pattern,
modeline = false, modeline = false,
buffer = event.buf, buffer = event.buf,
data = event.data, data = { lazy_file = true },
}) })
end end
vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false })
events = {} events = {}
end end