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 XDG support to key bindings, snippets, themes, and file templates #5144
Conversation
YAGNI might apply, but what do you think about allowing for multiple user-defined templates for each filetype? For example, the user might want: Ie, different templates for different single-file purposes. For now we'd only accept one template, but some theoretical day in the future this would allow us to e.g. provide a list of templates for the user to choose from (e.g. New -> From Template...) |
| // Add user snippets files | ||
| dirs.push_back(getSnippetsDir()); | ||
|
|
||
| for (const auto snippetsDir: dirs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: const auto&; prefer ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, done!
I think people would find it useful, but I don't think we need to build it now as it'd be meaningless without the UI. Is there something in the existing design that you think precludes us from taking this approach in the future? |
I don't think so -- I guess at worst we might have to migrate the default template files into filetype-specific subfolders, but that wouldn't be too bad. (I just wanted to double-check that we're at least leaving that door open; not suggesting we should take that work on now) |
I don't think we'd even need to do that! The file extension is sufficient: |
|
Running R Studio Version 1.3.391 on OSX, my ~/.config/rstudio folder only contains rstudio-prefs.json and /dictionaries. Any idea why I'm not seeing /templates? |
@jmcphers can confirm, but my understanding is that the templates folder doesn't exist unless you create it and add your own default file templates to it. |
|
@samgreenbergBTO @gtritchie is correct. The |
|
Ok, I got it working. It works for making a new R Notebook if the template is named default.Rmd or notebook.Rmd but doesn't seem to work for R Markdown. Not really a big problem since they're functionally identical but is there a specific name for markdown template? I tried markdown.Rmd. |
|
It's https://docs.rstudio.com/ide/server-pro/1.3.399-1/r-sessions.html#default-document-templates |
|
Great, thank you! Very happy this feature was added. |
|
@jmcphers OK one more thing. When I create a new R notebook it loads the template as is. When I create a new R markdown it asks for title and author but even if I leave those fields blank it generates a new empty header on top of my template. If I try to create an empty document it throws an error. |
|
Yes, if you use the wizard it's going to generate a YAML header for you, so your template should not include its own YAML header. If you want to have a YAML template in your header, use If you're seeing an error when creating an empty doc, please file an issue here! |
|
OK, when I go File > New File > R Markdown.. > Create Empty Document I get Error: No Such File or Directory |
This change continues the work started in #5069, continuing to further the 1.3 goal of (a) having all configuration data in a single, configurable folder and (b) supporting global customization of all settings.
Details
Prior to this change, these files were stored in hard-coded (and occasionally inconsistent) locations in the user's home dir:
~/.R/rstudio~/.REach of these has undergone similar work:
~/.config/rstudio(configurable)As an example, if a user has done some customization to RStudio, here's what their
~/.config/rstudiofolder might look like: it contains their preferences, key bindings, snippets, templates, and themes, all in plain, user-friendly text files.Templates
The
templatesfolder deserves some special mention since it was not previously customizable. You can now define the default content for any file type. For example, to set the default content for R scripts (what you see in the editor buffer when you click File -> New R Script), you can edit:Some file types, such as R Markdown, have non-default templates. These are also customizable via specially named files; for example
default.Rmdsets the content for blank R Markdown documents, butnotebook.Rmdsets the content for blank R Markdown notebooks.The admin guide will document the full list of special templates.