posit-dev / positron

Positron, a next-generation data science IDE
Other
2.52k stars 79 forks source link

Provide a way to change VS Code settings to RStudio defaults #2813

Open jmcphers opened 5 months ago

jmcphers commented 5 months ago

In many places, VS Code has settings that can be configured to make its behavior more like RStudio's. In the spirit of the RStudio Keymap extension (#669), we could provide an extension that changes VS Code setting defaults to provide a more RStudio-like experience.

For example, RStudio doesn't use an untitled file's first line to name it. VS Code does, but it can be turned off here:

image

As another example, RStudio's hot exit behavior differs from VS Code's defaults. We wound up turning on hot exit for everyone, but it's primarily desired because RStudio users are accustomed to it. https://github.com/posit-dev/positron/issues/2760

It is possible for VS code extensions to "contribute" settings defaults as documented here:

https://code.visualstudio.com/api/references/contribution-points#contributes.configurationDefaults

We could roll this into the RStudio Keymap as part of a larger "RStudio Mode" extension, or keep it separate.

hadley commented 5 months ago

Here's a summary of my current options which we might want to consider as defaults:

{
    "editor.tabSize": 2,
    "editor.scrollBeyondLastLine": false,
    "files.autoSave": "afterDelay",
    "files.hotExit": "onExitAndWindowClose",
    "workbench.quickOpen.closeOnFocusLost": false,
    "git.autofetch": true,
    "git.enableSmartCommit": true,
    "editor.fontLigatures": true,
    "editor.rulers": [
        80
    ],
    "editor.renderWhitespace": "boundary",
    "workbench.editor.empty.hint": "hidden",
    "explorer.confirmDelete": false,
    "editor.autoIndent": "keep",
    "workbench.editor.enablePreview": true,
    "workbench.editor.untitled.labelFormat": "name"
}
DavisVaughan commented 5 months ago
{
    "files.trimTrailingWhitespace": false,
    // because we get one in rstudio, and i like it for manual line wrapping
    // less useful if we have an auto formatter
    "editor.rulers": [ 
        80
    ],
    // should probably turn on both of these for R files at least
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true,
    "editor.comments.ignoreEmptyLines": false,
    "testing.showAllMessages": true,
    "testing.automaticallyOpenPeekView": "never",
    // i think it was not showing some whitespace trimming changes that happened on save
    // but they made diffs on github messy so you want to know when youre pushing these. should be jointly set with `files.trimFinalNewlines`
    "diffEditor.ignoreTrimWhitespace": false,
    // personal pref, idk
    "diffEditor.renderSideBySide": false,
    // i find this useful for getting rid of the git editors on push
    "git.closeDiffOnOperation": true,
    // goes well with our current debugger fallback behavior of auto closing the tab with the fake function source
    "debug.closeReadonlyTabsOnEnd": true,
    // as discussed on slack, prevents quick open (CMD + P) from closing when you move to another window
    "workbench.quickOpen.closeOnFocusLost": false
}

Some more which we could enable for rstudio users, possibly scoped to just R files too if we wanted

jmcphers commented 5 months ago

We might also consider setting workbench.editor.enablePreview to false when RStudio defaults are enabled (rather than all the time). See https://github.com/posit-dev/positron/issues/858

hadley commented 4 months ago

A few more that I've added recently:

    "files.trimTrailingWhitespace": true,
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true,
jmcphers commented 1 month ago

One technical challenge with using an extension-based set of defaults is that we can't ship that extension as a regular built-in (or it will contribute the defaults all the time). This is the same problem we have with the RStudio Keymap. The solution is probably to bundle but not install the extension in some way; see #4254.