Add new file type associatione, e.g. .rake → lang:ruby

When I open .rb Ruby files in RStudio, they correctly (and automatically) syntax highlight. When I open a .rake file (which is also Ruby), the file is displayed as plain text (because RStudio doesn't have a file extension mapping for .rake to the language Ruby).

The problem is that the language type Ruby does not even appear in the file type menu (bottom right) for Rake files, only for Ruby files, so it appears I can't even manually set the file type.

Is this the expected behavior, that I can't set the file type of an arbitrary file I open UNLESS it has an extension that RStudio has a hard-coded association for? Is there a way to add or edit associations between file extensions and Knitr-supported languages? This is something I'm used to being able to do in e.g. Vim, Atom, VS Code, and most other editors.

This does not just affect syntax highlighting — it also affects RStudio's ability to navigate to files with Go to file/function (Ctrl+.).

1 Like

Apparently it is hardwired. See this post by @jm3

I speculate that it could be done by writing an addin, but that's not something I've ever attempted.

About the RStudio IDE stuff, I think this is the kind of feature request you can open in RStudio IDE repository. It may look like a bug that .rb are recognized but Ruby can't be chosen.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.