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

Add default filetype #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cenksoykan
Copy link

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
Copy link
Member

alerque commented Oct 3, 2019

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
Copy link
Author

Of course, here it is ➡️ 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
Copy link
Member

alerque commented Oct 3, 2019

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
Copy link
Author

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
Copy link
Member

alerque commented Oct 3, 2019

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
Copy link
Member

alerque commented Oct 3, 2019

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
Copy link
Member

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
Copy link
Member

alerque commented Oct 3, 2019

@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
Copy link
Member

alerque commented Oct 7, 2019

@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
Copy link
Member

alerque commented Feb 17, 2020

@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?

@alerque alerque self-assigned this Feb 17, 2020
@joiharalds
Copy link

joiharalds commented Sep 15, 2021

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.

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 this pull request may close these issues.

4 participants