aboutsummaryrefslogtreecommitdiffstats
path: root/init.lua
blob: 5ae938f92c1621c7d928ede7c2b5a1d7334107c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require "config"
require "pi.globals"

-- Restaurar la última posición del cursor al abrir un archivo (reemplaza vim-lastplace)
vim.api.nvim_create_autocmd("BufReadPost", {
    group = vim.api.nvim_create_augroup("last_place", { clear = true }),
    callback = function(args)
        local exclude_ft = { "gitcommit", "gitrebase", "svn", "hgcommit" }
        local buf = args.buf
        if vim.tbl_contains(exclude_ft, vim.bo[buf].filetype) or vim.b[buf].last_place_done then
            return
        end
        vim.b[buf].last_place_done = 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)
            vim.api.nvim_exec2("silent! normal! zv", {})
        end
    end,
})