Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore last position when opening a buffer of the gitcommit type #7

Open
chapeupreto opened this issue Jan 15, 2025 · 0 comments
Open

Comments

@chapeupreto
Copy link

chapeupreto commented Jan 15, 2025

Hi Adib! Thank you very much for sharing your config files.

In your autocmds.lua file there is the following code:

-- go to last loc when opening a buffer
-- this mean that when you open a file, you will be at the last position
api.nvim_create_autocmd("BufReadPost", {
  callback = function()
    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,
})

Is it possible to ignore last position when the buffer is gitcommit type? I ask you that because sometimes I use git commit -v --amend and then, for such a scenario, it would be nice to always have the cursor at beginning of the buffer/file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant