vim-pandoc / vim-rmarkdown

Rmarkdown support for vim
99 stars 26 forks source link

Add default filetype #26

Open cenksoykan opened 5 years ago

cenksoykan commented 5 years ago

Default filetype is rmd for that reason I added rmd before rmarkdown to fix compatibility issues with any other plugin uses the default. But I don't know if this plugin fails for any significant reason with that change. I have tried and so far it works very fine in general

alerque commented 5 years ago

Thanks for the contribution. I'm not entirely sure this dot notation is correct. Can you point to VIM documentation somewhere explaining how it is supposed to work?

cenksoykan commented 5 years ago

Of course, here it is :arrow_right: VimDoc

:h 'filetype'
When a dot appears in the value then this separates two filetype
names.  Example:
    /* vim: set filetype=c.doxygen : */ 
This will use the "c" filetype first, then the "doxygen" filetype.
This works both for filetype plugins and for syntax files.  More than
one dot may appear.
alerque commented 5 years ago

Thanks for that link.

If the default VIM filetype is rmd where is the rmarkdown value even entering the picture? Is that our doing? If so would we be better off just changing that to rmd across the board?

cenksoykan commented 5 years ago

It might be before the vim support #15 Indeed it is better to change it

You can see the defaults

:echo glob($VIMRUNTIME . '/ftplugin/*.vim')
:echo glob($VIMRUNTIME . '/syntax/*.vim')
alerque commented 5 years ago

I just did a pretty complete code review and don't see anywhere else in this plugin it even needs changing. Can you just make these two lines read filetype=rmd?

alerque commented 5 years ago

After that we'll need one more commit that renames the files and add symlinks. If you like you can cherry pick this commit into your branch (or I can push it) after you fix the thing in my previous comment.

Katkıda bulunduğun için teşekkür ederim.

fmoralesc commented 5 years ago

If the default VIM filetype is rmd where is the rmarkdown value even entering the picture? Is that our doing? If so would we be better off just changing that to rmd across the board?

That is indeed our doing. The reason we have a different filetype is the same as why vim-pandoc uses pandoc as the filetype instead of markdown: since vim already provides an rmd filetype, instead of adding to it, we try to set everything on our own (of course, rmarkdown uses the pandoc markdown support underneath).

alerque commented 5 years ago

@fmoralesc Hum. I'm going to have to sleep on this here, I'm not sure we're doing this right. That actually makes sense, and yet it seems like that shouldn't be what we need to do.

alerque commented 5 years ago

@fmoralesc Two questions.

  1. Is there no way to clear other values before setting new ones?

  2. Given that our issue with *.md files is that they are ambiguous and could be generic Markdown or the could be Pandoc Flavored Markdown, to you still think this case is analogous since *.rmd files are a specific flavor already identified by a different filetype value?

alerque commented 4 years ago

@fmoralesc I think we need to resolve this, it's still tripping people up and seems wrong to me still. Any feedback on my #⁠2 question above?

joiharalds commented 3 years ago

The difference between filetype rmd and rmarkdown creates an issue with the Nvim-R plugin. Sending R code chunk to console with <leader>cc doesn't work when filetype is rmarkdown but works when filetype is rmd. On the other hand the command :RM works when filetype is rmarkdown but doesn't work when filetype is rmd.

This leads to the user having to switch manually between the different filetypes. After switching from rmarkdown to rmd filetype once after opening a .Rmd file the Nvim-R plugin behaves correctly (<leader>cc at least works) and the :RM command works. So I was using a hacky solution taking advantage of this:

In the directory ~/.config/nvim/after/ftdetect (need to create this if non-existent) I put an rmarkdown.vim file where I override the rmarkdown filetype with rmd like so

augroup rmarkdown au BufRead,BufNewFile *.Rmd set filetype=rmd au BufRead,BufNewFile *.Rpres set filetype=rmd augroup END

Note that I use au without ! because otherwise the commands in the plugin specific script ~/.local/share/nvim/plugged/vim-rmarkdown/ftdetect/rmarkdown.vim would not be run to set the filetype to rmarkdown to begin with.

I don't think this is a permanent solution and it might cause something to break but I haven't run into problems yet. I will report back if I do. The best solution would of course be that this plugin uses the rmd filetype but I have not looked into whether this is possible.

Update: This commit fixes this issue so no need for the hacky solution.