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

Does not work with filetype.nvim #56

Closed
tsakirist opened this issue Nov 7, 2021 · 3 comments
Closed

Does not work with filetype.nvim #56

tsakirist opened this issue Nov 7, 2021 · 3 comments

Comments

@tsakirist
Copy link

Hello!

I just installed filetype.nvim to speed-up my nvim startup time but unfortunately it seems that committia will not open when writing a commit message.

Any idea/fix for this?

@nsfisis
Copy link

nsfisis commented Dec 4, 2021

I had the same trouble and found the cause.

Environment:

Cause:

committia.vim registers autocmd for BufReadPost event to setup itself.

" https://github.com/rhysd/committia.vim/blob/0b4df1a7f48ffbc23b009bd14d58ee1be541917c/plugin/committia.vim#L13
    autocmd BufReadPost COMMIT_EDITMSG,MERGE_MSG if s:should_open('gitcommit') | call committia#open('git') | endif

s:should_open() checks whether the current filetype option is equal to gitcommit or not.

filetype.nvim also registers autocmd for BufRead event to set filetype.

" https://github.com/nathom/filetype.nvim/blob/ddef0faedfb561ca2af141a35ab6f256beba8b5a/plugin/filetype.vim#L3
    au BufNewFile,BufRead * lua require('filetype').resolve()

Because the autocmd event BufRead is just an alias for BufReadPost, these two event callbacks are fired in the order where they are registered, i.e., the order where the plugins are loaded. The loading order is, maybe, alphabetical or unspecified. Anyway, committia.vim can be loaded before filetype.nvim. In this case, s:should_open() returns false because filetype has not been determined yet.

Solution:

This PR of filetype.nvim resolves the problem. It works for me.

@rhysd
Copy link
Owner

rhysd commented Dec 4, 2021

@nsfisis Thank you for taking a look at this. It's really helpful. Let's wait for nathom/filetype.nvim#54 being merged.

The loading order is, maybe, alphabetical or unspecified.

When plugins are installed in different directories, the order is the same as the order of directories in runtimepath. If they're in the same, the order is implementation-defined. But it actually seems an alphabetical order.

@syphar
Copy link

syphar commented Jan 22, 2022

nathom/filetype.nvim#54 was merged, and now this plugin works again for me.

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

4 participants