Closed smheidrich closed 1 year ago
filetype detection is executed from https://github.com/vim/vim/blob/be19d78c3d44221cbc38fbb5bac19302345c1def/runtime/filetype.vim#L2745, which is already inside a group: it is correct not to add another group in our own file.
Note that there is no "augroup" command, this has already been done when sourcing your file.
Perhaps you're doing something similar?
I see, thanks for the explanation and the links!
I haven't figured out exactly what's causing this yet but as you explained this plugin is doing everything correctly, so I'll close the ticket.
All right, for anyone who has the same issue in the future, the source of the bug in my case was another plugin's (vimoutliner) ftdetect
script leaving the augroup filetypedetect
context at the end of its execution. I've opened an issue with them here: https://github.com/vimoutliner/vimoutliner/issues/185
I'm sure this is not the only plugin that does this, so again for anyone who has the same issue, it probably makes sense to go into your Vim plugin folder and run rg 'augroup' $(find . -path '*/ftdetect/*.vim')
to see if you have any ftdetect
scripts that (wrongly) close the augroup.
What pointed me towards this being a potential cause was this comment in Vim's filetype.vim
, where it is noted that any of the ftdetect
scripts it ran could have ended the augroup context.
I'm running NeoVim 0.7.2 with this plugin installed via vim-plug, but when I open a
.tf
file, the filetype is just empty. It works fine for.hcl
files.Curiously, if I comment out this line where you disable Vim's native
.ft
filetype detection, it works. But that seems to be because recent versions of Vim are able to recognize.tf
files as Terraform, so with this line removed, Vim's native detection kicks in and sets the filetype:So that can't be the underlying issue (although it would probably make sense to have a condition there to let Vim handle this for recent versions, because then users who want to be able to detect both file types denoted by
.tf
can do so).Based on Vim's own autocmd being in group
filetypedetect
, I tried addingfiletypedetect
as the group for the four autocmds setup by vim-terraform, and that made it detect the filetype correctly as well. But there is probably a reason why you don't havefiletypedetect
as the group there, so let me know what you think.