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 dedicated RStudio keymap #2067

Merged
merged 14 commits into from
Jan 16, 2024
Merged

Add dedicated RStudio keymap #2067

merged 14 commits into from
Jan 16, 2024

Conversation

jmcphers
Copy link
Collaborator

@jmcphers jmcphers commented Jan 12, 2024

This change adds an RStudio keymap to Positron, and implements all of the keybindings that have been specifically requested by alpha users. Namely:

  • Ctrl + 1 to focus Source
  • Ctrl + 2 to focus Console
  • Cmd + . to go to symbol
  • Cmd + Shift + C to comment/uncomment a line
  • Cmd + Shift + N to create a new R file
  • F2 to go to definition
  • Cmd + I to reindent selection
  • Cmd + Shift + A to reformat selection
  • Alt + Shift + I to insert a new Quarto/R Markdown cell
  • Cmd + D to delete the current line

There are a lot more keybindings we'll probably end up adding, but these seem to be causing the most friction.

Note that most of the bindings mentioned in #669 are already implemented in the R extension; we felt it was okay to take most of these bindings when the user is editing an R package.

The keymaps are implemented in a new extension which is currently codeless, but will probably have code later so we can add custom RStudio-like logic for other keys/commands. As there is no way to see or disable built-in or bundled extensions, we gate all the extension's bindings on a setting that can be toggled here:

image

Turning on this setting activates the keybindings (no restart necessary!).

Addresses #669.

@jmcphers
Copy link
Collaborator Author

As there is no way to see or disable built-in or bundled extensions, we gate all the extension's bindings on a setting that can be toggled

Another way to do this might be to have the extension activate on a command. That would be a little more complicated to implement (a setting in a different extension might have to run the command? dynamically loading it at startup when enabled might be harder?), but it would make things cleaner from a user perspective -- right now you always see the RStudio Keymap items in the Keyboard Shortcuts dialog (with the config flag); if we enabled on a command then you'd only see them if the keymap was actually turned on.

@jmcphers
Copy link
Collaborator Author

Another way to do this might be to have the extension activate on a command

I just tried this (e1552bc) and it doesn't work the way I thought. It appears based on my testing that the keybindings contributions are active even if the extension isn't activated. So just installing the extension is enough to turn on the keybindings, and since this extension is always installed, they're always active.

Copy link
Contributor

@softwarenerd softwarenerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG!

@jmcphers jmcphers merged commit f271d35 into main Jan 16, 2024
1 check passed
@wesm wesm deleted the feature/rstudio-keymap branch March 15, 2024 20:43
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.

None yet

2 participants