Skip to content

Instantly share code, notes, and snippets.

@strengejacke
Last active November 9, 2024 09:43
Show Gist options
  • Save strengejacke/2a785f8e096d94bc84fb6b877aad4fb1 to your computer and use it in GitHub Desktop.
Save strengejacke/2a785f8e096d94bc84fb6b877aad4fb1 to your computer and use it in GitHub Desktop.
Positron-Setup
Positron Version: 2024.11.0 (system setup) build 140
Code - OSS Version: 1.93.0
Commit: e0d844b031f95acbf89f234a2cce2af9b6721f6c
Date: 2024-10-31T14:14:22.699Z
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631
@strengejacke
Copy link
Author

strengejacke commented Jul 1, 2024

settings.json

{
  // this is the settings.json file

  // file behaviour
  "files.hotExit": "onExitAndWindowClose",
  "files.defaultLanguage": "r",
  "files.insertFinalNewline": true,
  "files.trimFinalNewlines": true,
  "files.trimTrailingWhitespace": true,

  // editor settings
  "editor.fontFamily": "'Fira Code', Consolas, 'Courier New', monospace",
  "editor.fontLigatures": true,
  "editor.guides.bracketPairs": "active",
  "editor.guides.indentation": false,
  "editor.cursorBlinking": "phase",
  "editor.renderWhitespace": "trailing",
  "editor.rulers": [
    {
      "column": 80,
      "color": "#5a5a5a80"
    }, // right rule
    {
      "column": 95,
      "color": "#5a5a5a30"
    }, // right rule
    {
      "column": 120,
      "color": "#5a5a5a40"
    } // extra right rule
  ],
  "security.workspace.trust.untrustedFiles": "open",
  "positron.r.diagnostics.enable": false,

  // todo tree
  "todo-tree.highlights.customHighlight": {
    "TODO": {
      "background": "#F5910044",
      "foreground": "#fffc00FF"
    },
    "BUG": {
      "icon": "bug",
      "background": "#D3262655",
      "foreground": "#FF3300FF"
    },
    "HACK": {
      "icon": "tools"
    },
    "FIXME": {
      "icon": "flame",
      "background": "#00996844",
      "foreground": "#25D366FF"
    }
  },

  // git settings
  "git.autofetch": true,
  "git.confirmSync": false,
  "git.suggestSmartCommit": false,

  // github settings
  "githubPullRequests.fileListLayout": "tree",
  "githubPullRequests.defaultMergeMethod": "squash",
  "githubPullRequests.pullBranch": "never",
  "githubIssues.queries": [
    {
      "label": "My Issues",
      "query": "is:open assignee:${user} repo:${owner}/${repository}",
      "groupBy": [
        "milestone"
      ]
    },
    {
      "label": "Created Issues",
      "query": "author:${user} state:open repo:${owner}/${repository} sort:created-desc"
    },
    {
      "label": "Recent Issues",
      "query": "state:open repo:${owner}/${repository} sort:created-desc"
    }
  ],

  // Codesnap
  "codesnap.boxShadow": "rgba(0, 0, 0, 0.55) 0px 20px 60px",
  "codesnap.backgroundColor": "#6090a0",
  "codesnap.containerPadding": "1em",
  "codesnap.showWindowControls": false,
  "codesnap.shutterAction": "copy",

  // Wrap at 80 columns with the "Rewrap" extension
  "rewrap.wrappingColumn": 80,

  // Debugger
  "debug.toolBarLocation": "docked",
  "chatgpt.lang": "en",
  "workbench.colorTheme": "Default Positron Dark",
  "diffEditor.ignoreTrimWhitespace": true,
  "editor.defaultFormatter": "vscode.positron-r"
}

@strengejacke
Copy link
Author

strengejacke commented Jul 16, 2024

Keybindings

// Place your key bindings in this file to override the defaults
[

    // Install R package (for developers)
    {
        "description": "R Install Package",
        "key": "ctrl+shift+i",
        "command": "workbench.action.executeCode.console",
        "args": "devtools::install(quick = TRUE, upgrade = FALSE)",
        "when": "isPackage || ((editorTextFocus || positronConsoleFocused) && editorLangId == 'r')"
    },
    // build source package
    {
        "description": "R Build Source Package",
        "key": "ctrl+shift+b",
        "command": "r.packageBuild",
        "when": "isRPackage"
    },
    // Update packages
    {
        "description": "R Update Packages",
        "key": "ctrl+shift+u",
        "command": "workbench.action.executeCode.console",
        "args": "vsCodeSnippets::update_R_packages()",
        "when": "editorTextFocus || positronConsoleFocused"
    },
    // create reprex from selection
    {
        "description": "R Create Reprex from Selection",
        "key": "ctrl+shift+x",
        "command": "workbench.action.executeCode.console",
        "when": "editorTextFocus",
        "args": {
            "langId": "r",
            "code": "reprex::reprex_selection()",
            "focus": true
        }
    },
    // Compile report (knit R Script)
    {
        "description": "R Compile Report",
        "key": "ctrl+shift+r",
        "command": "workbench.action.executeCode.console",
        "args": "rmarkdown::render(input=rstudioapi::getSourceEditorContext()$path)",
        "when": "editorLangId == 'r'"
    },
    // workspace/workbench shortcuts
    {
        "key": "ctrl+oem_period",
        "command": "workbench.action.showAllSymbols"
    },
    {
        "key": "ctrl+2",
        "command": "workbench.action.positronConsole.focusConsole"
    },
    {
        "key": "ctrl+3",
        "command": "workbench.action.positron.togglePlots"
    },
    {
        "key": "ctrl+4",
        "command": "workbench.action.positron.togglePreview",
        "when": "workbench.panel.positronPreview.active"
    },
    {
        "key": "ctrl+shift+j",
        "command": "workbench.action.toggleAuxiliaryBar"
    },
    // editor shortcuts
    {
        "key": "ctrl+shift+c",
        "command": "editor.action.commentLine",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+a",
        "command": "editor.action.formatSelection",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+oem_5",
        "command": "editor.action.jumpToBracket",
        "when": "editorTextFocus"
    },
    // remove preset keybindings
    {
        "key": "ctrl+shift+n",
        "command": "-r.createNewFile",
        "when": "config.rstudio.keymap.enable"
    },
    {
        "key": "ctrl+shift+i",
        "command": "-positron.insertCodeCell",
        "when": "editorTextFocus && positron.supportsCodeCells && !findInputFocussed && !replaceInputFocussed"
    },
    {
        "key": "ctrl+oem_period",
        "command": "-workbench.action.showAllSymbols",
        "when": "config.rstudio.keymap.enable"
    },
    {
        "key": "ctrl+t",
        "command": "-workbench.action.showAllSymbols"
    },
    {
        "key": "ctrl+shift+x",
        "command": "-workbench.view.extensions",
        "when": "viewContainer.workbench.view.extensions.enabled"
    },
    {
        "key": "ctrl+shift+b",
        "command": "-r.packageInstall",
        "when": "isRPackage"
    },
    {
        "key": "ctrl+2",
        "command": "-workbench.action.focusSecondEditorGroup"
    },
    {
        "key": "ctrl+2",
        "command": "-workbench.action.positronConsole.focusConsole",
        "when": "config.rstudio.keymap.enable"
    },
    {
        "key": "ctrl+shift+a",
        "command": "-editor.action.formatSelection",
        "when": "config.rstudio.keymap.enable && editorTextFocus"
    },
    {
        "key": "ctrl+shift+a",
        "command": "-notification.acceptPrimaryAction",
        "when": "notificationFocus || notificationToastsVisible"
    },
    {
        "key": "ctrl+shift+c",
        "command": "-editor.action.commentLine",
        "when": "config.rstudio.keymap.enable && editorTextFocus"
    },
    {
        "key": "ctrl+shift+c",
        "command": "-workbench.action.terminal.openNativeConsole",
        "when": "!terminalFocus"
    },
    {
        "key": "f2",
        "command": "-editor.action.revealDefinition",
        "when": "config.rstudio.keymap.enable && editorHasDefinitionProvider && editorTextFocus"
    },
    {
        "key": "ctrl+shift+u",
        "command": "-workbench.action.output.toggleOutput",
        "when": "workbench.panel.output.active"
    },
    {
        "key": "ctrl+shift+u",
        "command": "-workbench.action.output.toggleOutput",
        "when": "workbench.panel.output.active"
    },
    {
        "key": "ctrl+shift+j",
        "command": "-workbench.action.search.toggleQueryDetails",
        "when": "inSearchEditor || searchViewletFocus"
    },
    {
        "key": "ctrl+oem_5",
        "command": "-workbench.action.splitEditor"
    },
    {
        "key": "ctrl+shift+oem_5",
        "command": "-editor.action.jumpToBracket",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+r",
        "command": "-r.insertSection",
        "when": "config.rstudio.keymap.enable && editorTextFocus && editorLangId == 'r'"
    },
    {
        "key": "ctrl+shift+r",
        "command": "-editor.action.refactor",
        "when": "editorHasCodeActionsProvider && textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+shift+i",
        "command": "-workbench.action.toggleDevTools",
        "when": "isDevelopment"
    },
    {
        "key": "ctrl+4",
        "command": "-workbench.action.focusFourthEditorGroup"
    },
    {
        "key": "ctrl+3",
        "command": "-workbench.action.focusThirdEditorGroup"
    },
    {
        "key": "ctrl+shift+h",
        "command": "-workbench.action.positron.togglePreview"
    },
    {
        "key": "ctrl+alt+b",
        "command": "-workbench.action.toggleAuxiliaryBar"
    }
]

@strengejacke
Copy link
Author

strengejacke commented Jul 17, 2024

Layout

I prefer 3-column layout, with editor in the center, output/console on the right, and a small left sidebar for files/navigation etc. If required, the bottom panel with variables ("Environment") can be shown/hidden via shortcut.

positron-layout.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment