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

Leaving the filetypedetect augroup at the end of the ftdetect script messes with other plugins #185

Open
smheidrich opened this issue Mar 10, 2023 · 0 comments · May be fixed by #186
Open

Comments

@smheidrich
Copy link

The ftdetect script for .votl files that comes with this plugin is currently nested inside an augroup filetypedetect ... augroup END block:

augroup filetypedetect
au! BufRead,BufNewFile *.otl setfiletype votl
au! BufRead,BufNewFile *.oln setfiletype xoutliner
augroup END

As this comment on another plugin's issue tracker points out, there is no need to do this, as Vim already opens an augroup filetypedetect context before running ftdetect scripts.

But doing so in your own ftdetect script is not just useless, it's actually harmful to other ftdetect scripts that do rely on being run inside of an augroup filetypedetect context: By leaving this context at the end of your script, you stop all those scripts from working properly, as happened in hashivim/vim-terraform#179.

It's worth pointing out that out of the many plugins I have installed, vimoutliner is the only one that does this:

$ find . -path '*/ftdetect/*.vim'
./vimoutliner/ftdetect/votl.vim
./vimtex/ftdetect/cls.vim
./vimtex/ftdetect/tikz.vim
./vimtex/ftdetect/tex.vim
./unicode.vim/ftdetect/unicode.vim
./quantum_espresso-vim/ftdetect/espresso.vim
./vim-terraform/ftdetect/hcl.vim
./vim-graphql/ftdetect/graphql.vim
./vim-fugitive/ftdetect/fugitive.vim
./vim-maktaba/vroom/fakeplugins/ftplugin/ftdetect/newtype.vim
./vim-hcl/ftdetect/hcl.vim
$ rg 'augroup' $(find . -path '*/ftdetect/*.vim')
./vimoutliner/ftdetect/votl.vim
22:augroup filetypedetect
25:augroup END

I don't know if you introduced this as a defensive measure against another popular script doing the same thing (and hence messing it up for other scripts including vimoutliner), but if so, then it would probably be better to just specify the filetypedetect group explicitly for every single autocmd command or to not leave the augroup context at the end of the script.

Objections / thoughts?

smheidrich added a commit to smheidrich/vimoutliner that referenced this issue Mar 10, 2023
It is both pointless and introduces bugs, as Vim opens an augroup
filetypedetect context before running ftdetect scripts anyway and other
ftdetect scripts rely on being inside such a context, so by leaving it
at the end of our ftdetect script we break them.

Fixes vimoutliner#185
@smheidrich smheidrich linked a pull request Mar 10, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant