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

gitcommit filetype not yet set on neovim #36

Open
saecki opened this issue Sep 1, 2024 · 2 comments
Open

gitcommit filetype not yet set on neovim #36

saecki opened this issue Sep 1, 2024 · 2 comments

Comments

@saecki
Copy link

saecki commented Sep 1, 2024

Some time ago neovim switched to use filetype.lua by default. I'm guessing that's the reason that git commit message the filetype isn't yet set on BufRead and BufReadPost, but after BufEnter. So the lastplace_ignore list doesn't work on neovim.

I don't know if you want to support that and change to autocmd, or if that breaks the opening fold for some reason.
Just letting you know, feel free to close :)

Edit: never mind, using BufEnter is just plain wrong.

@farmergreg
Copy link
Owner

farmergreg commented Sep 14, 2024

@saecki , thanks for the bug report! I have not been able to reproduce the bug. Could you provide some steps to reproduce it?

Here is what I tried:

I performed a couple of multi-line git commits and confirmed that it opens on the first line correctly. When I set g:lastplace_ignore="" then I could see that git commits would jump to the line number of the last edit because vim-lastplace wasn't disabled for git commits anymore.

I tested with neovim v0.9.5 with Lazy (plugin manager) and used this config to test:

-- File: ~/.config/nvim/lua/plugins/vim-lastplace.lua

return {
  "farmergreg/vim-lastplace",
  config = function()
    vim.g.lastplace_ignore = "gitcommit,gitrebase,svn,hgcommit"
    vim.g.lastplace_ignore_buftype = "quickfix,nofile,help"
    vim.g.lastplace_open_folds = 1
  end,
}

@saecki
Copy link
Author

saecki commented Sep 14, 2024

Interesting, I'm not sure what exactly lazy.nvim does, but when adding the following auto commands before the lazy setup vs after I get different results:

vim.api.nvim_create_autocmd("BufReadPre", {
    callback = function()
        print("BufReadPre:", vim.bo.ft)
    end,
})
vim.api.nvim_create_autocmd("BufRead", {
    callback = function()
        print("BufRead:", vim.bo.ft)
    end,
})
vim.api.nvim_create_autocmd("BufReadPost", {
    callback = function()
        print("BufReadPost:", vim.bo.ft)
    end,
})

before

BufReadPre:
BufRead:
BufReadPost:

after

BufReadPre:
BufRead: gitcommit
BufReadPost: gitcommit

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

2 participants