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