36 lines
892 B
Nix
36 lines
892 B
Nix
let
|
|
group = "RememberCursorPosition";
|
|
in {
|
|
autoGroups = {
|
|
${group} = {
|
|
clear = true;
|
|
};
|
|
};
|
|
autoCmd = [
|
|
{
|
|
inherit group;
|
|
event = "BufRead";
|
|
callback = {
|
|
__raw = ''
|
|
function(opts)
|
|
buffer = opts.buf,
|
|
vim.api.nvim_create_autocmd("BufWinEnter", {
|
|
callback = function()
|
|
local ft = vim.bo[opts.buf].filetype
|
|
local last_known_line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1]
|
|
if
|
|
not (ft:match("commit") and ft:match("rebase"))
|
|
and last_known_line > 1
|
|
and last_known_line <= vim.api.nvim_buf_line_count(opts.buf)
|
|
then
|
|
vim.api.nvim_feedkeys([[g`"]], "nx", false)
|
|
end
|
|
end,
|
|
})
|
|
end
|
|
'';
|
|
};
|
|
}
|
|
];
|
|
}
|