Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Breaks autocmd that applies default filetype #43

Open
roginfarrer opened this issue Nov 10, 2021 · 2 comments · May be fixed by #93
Open

Breaks autocmd that applies default filetype #43

roginfarrer opened this issue Nov 10, 2021 · 2 comments · May be fixed by #93

Comments

@roginfarrer
Copy link

If have this autocmd in my config that sets a default filetype for a buffer if none is set:

autocmd BufNewFile,BufReadPost * if &ft == '' | set ft=markdown | endif

This autocmd paired with filetype.nvim breaks the set of the filetype when the buffer is first read. : e<cr> fixes it.

Not sure if this can be addressed or if there's a better way for me to set a default filetype, but I thought I'd bring it up!

@roginfarrer
Copy link
Author

roginfarrer commented Nov 11, 2021

Turns out I can fix this by changing the event to BufEnter only:

autocmd BufEnter * if &ft == '' | set ft=markdown | endif

I'll leave this issue open since this is technically an incompatibility between the built-in filetype detection and this plugin.

@nathom
Copy link
Owner

nathom commented Nov 20, 2021

This is happening because you're matching all filenames and your autocmd is being run before filetype.nvim's. Not sure there's anything helpful I can do here except say that the second autocmd you provided is the "correct" way to do it, waiting for the filetype to resolve.

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

Successfully merging a pull request may close this issue.

2 participants