preservim / vim-markdown

Markdown Vim Mode
4.68k stars 521 forks source link

Make this plugin work with R Markdown by default #601

Open amarakon opened 2 years ago

amarakon commented 2 years ago

R Markdown (rmd) is exactly the same as Markdown except with extra features. This plugin should apply not only to the markdown file type, but also to the rmd file type.

alerque commented 2 years ago

I don't think we can do this by default without creating problems for many people. There are lots or R specific plugins and many of them do not play nice with this one. See for example #263, but I am pretty sure there are others. If we try to snag the rmd filetype we're just going to create problems. It shouldn't be too hard to activate this for the file type yourself if you want to use it, but I can't see making it a default would be viable.

It's possible we could add documentation for how to enable it for more file types and use R Markdown as an example. I'll leave this issue open to track that (contributions welcome).

amarakon commented 2 years ago

It's possible we could add documentation for how to enable it for more file types and use R Markdown as an example. I'll leave this issue open to track that (contributions welcome).

I am not sure how to activate this plugin for file types other than markdown without switching the file type with the setfiletype command. I think there should be documentation on how to do that.

alerque commented 2 years ago
au BufRead,BufNewFile *.rmd set ft markdown

If you have other rmd related stuff you want to use and don't want to just pretend they are filetype markdown then you will need to piecemeal import the things you want, for example adding an after/filetype hook to source this plugin code after setting the rmd filetype to get the functions or importing the markdown highlighting into the rmd syntax rules yourself.

amarakon commented 2 years ago
au BufRead,BufNewFile *.rmd set ft markdown

Can I do autocmd FileType rmd setfiletype markdown or autocmd VimEnter *.rmd setfiletype markdown?

If you have other rmd related stuff you want to use and don't want to just pretend they are filetype markdown then you will need to piecemeal import the things you want, for example adding an after/filetype hook to source this plugin code after setting the rmd filetype to get the functions or importing the markdown highlighting into the rmd syntax rules yourself.

Sorry, I am not sure exactly how to do this. Perhaps there should be an option for this plugin to enable it for other file types?

By the way, if I symlink all markdown.vim files to rmd.vim, I get the same issue as #263. I think this plugin should add an option to enable it for other file types. Then, once #263 is solved, it should be enabled for R Markdown by default.