Files
tiny-lastplace.nvim/lua/tiny-lastplace/init.lua
T
swaits 0b9ead7857
CI / lint (push) Canceled after 0s
CI / test (push) Canceled after 0s
feat: initial release
2026-04-09 17:30:24 -06:00

24 lines
692 B
Lua

local M = {}
function M.setup(opts)
opts = opts or {}
local exclude = opts.exclude or { "gitcommit" }
vim.api.nvim_create_autocmd("BufReadPost", {
group = vim.api.nvim_create_augroup("tiny-lastplace", { clear = true }),
callback = function(event)
local buf = event.buf
if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].tiny_lastplace then
return
end
vim.b[buf].tiny_lastplace = true
local mark = vim.api.nvim_buf_get_mark(buf, '"')
local lcount = vim.api.nvim_buf_line_count(buf)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
end
return M