tpope/vim-rhubarb

Allow overriding the filetype for hub generated files

mattr- opened this issue ยท 1 comments

Hello! ๐Ÿ‘‹ I'm having a hard time overridding the filetype set by rhubarb.vim for the hub generated files that it's handling. I made three attempts:

  • an autocommand in my .vimrc
augroup github
  au!
  autocmd BufNewFile,BufRead *.git/{PULLREQ_EDIT,ISSUE_EDIT,RELEASE_EDIT}MSG set ft=markdown
augroup END
  • a file in my local .vim/ftdetect directory with the autocommand the same as my snippet above.
autocmd BufNewFile,BufRead *.git/{PULLREQ_EDIT,ISSUE_EDIT,RELEASE_EDIT}MSG set filetype markdown
  • A change of the above snippet to use the rhubarb autogroup instead of a new one:
augroup rhubarb
  au!
  autocmd BufNewFile,BufRead *.git/{PULLREQ_EDIT,ISSUE_EDIT,RELEASE_EDIT}MSG set ft=markdown
augroup END

I was able to make this work the way I wanted by changing set ft=gitcommit to setfiletype markdown on this line of code and that allowed my custom ftdetect plugin to work.

I think the default of gitcommit for the file type for those files is great! I'd just like to be able to use markdown instead. ๐Ÿ™‚ I have a patch but didn't want to just submit it outright in case I was going about this the wrong way.

Thanks!

tpope commented

You can achieve this by making your autocommand run after Rhubarb loads, it's possible with an after/ file or a VimEnter autocommand but admittedly that's very annoying.

The problem with setfiletype is it will bail if Vim's built-in notices # comment lines and sets a conf filetype. What's needed is a conditional that looks for a blank filetype or conf and does set filetype=gitcommit in either case. Feel free to send a PR that achieves that.