mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-31 16:14:46 +02:00
fix(autocmds): better way of opening file at last location
This commit is contained in:
parent
08e6a880f5
commit
63bea54be2
1 changed files with 5 additions and 1 deletions
|
@ -11,7 +11,11 @@ vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
-- go to last loc when opening a buffer
|
-- go to last loc when opening a buffer
|
||||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.cmd([[silent! normal! g`"]])
|
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
||||||
|
local lcount = vim.api.nvim_buf_line_count(0)
|
||||||
|
if mark[1] > 0 and mark[1] <= lcount then
|
||||||
|
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue