Skip to content

Commit

Permalink
document keybinding addition in Positron (closes simonpcouch#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Oct 17, 2024
1 parent cb08170 commit 57bad05
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
23 changes: 23 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ pak::pak("simonpcouch/pal")

Then, ensure that you have an [`ANTHROPIC_API_KEY`](https://console.anthropic.com/) environment variable set, and you're ready to go. If you'd like to use an LLM other than Anthropic's Claude 3.5 Sonnet—like OpenAI's ChatGPT—to power the pal, see the [Getting started with pal](https://simonpcouch.github.io/pal/articles/pal.html) vignette.

Pals are interfaced with the via the pal addin. For easiest access, we recommend registering the pal addin to a keyboard shortcut.

**In RStudio**, navigate to `Tools > Modify Keyboard Shortcuts > Search "Pal"`—we suggest `Ctrl+Alt+P` (or `Ctrl+Cmd+P` on macOS).

**In Positron**, you'll need to open the command palette, run "Open Keyboard Shortcuts (JSON)", and paste the following into your `keybindings.json`:

```json
{
"key": "Ctrl+Cmd+P",
"command": "workbench.action.executeCode.console",
"when": "editorTextFocus",
"args": {
"langId": "r",
"code": "pal::.init_addin()",
"focus": true
}
}
```

The analogous keybinding on non-macOS is `Ctrl+Alt+P`. That said, change the `"key"` entry to any keybinding you wish!

Once those steps are completed, you're ready to use pals with a keyboard shortcut.

## Example

Pals are created automatically when users interact with the pal addin. Just highlight some code, open the addin, begin typing the "role" of your pal and press "Return", and watch your code be rewritten:
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,36 @@ than Anthropic’s Claude 3.5 Sonnet—like OpenAI’s ChatGPT—to power the
pal, see the [Getting started with
pal](https://simonpcouch.github.io/pal/articles/pal.html) vignette.

Pals are interfaced with the via the pal addin. For easiest access, we
recommend registering the pal addin to a keyboard shortcut.

**In RStudio**, navigate to
`Tools > Modify Keyboard Shortcuts > Search "Pal"`—we suggest
`Ctrl+Alt+P` (or `Ctrl+Cmd+P` on macOS).

**In Positron**, you’ll need to open the command palette, run “Open
Keyboard Shortcuts (JSON)”, and paste the following into your
`keybindings.json`:

``` json
{
"key": "Ctrl+Cmd+P",
"command": "workbench.action.executeCode.console",
"when": "editorTextFocus",
"args": {
"langId": "r",
"code": "pal::.init_addin()",
"focus": true
}
}
```

The analogous keybinding on non-macOS is `Ctrl+Alt+P`. That said, change
the `"key"` entry to any keybinding you wish!

Once those steps are completed, you’re ready to use pals with a keyboard
shortcut.

## Example

Pals are created automatically when users interact with the pal addin.
Expand Down
23 changes: 22 additions & 1 deletion vignettes/pal.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,28 @@ Just:

![](https://raw.githubusercontent.com/simonpcouch/pal/refs/heads/main/inst/figs/addin.gif)

For easiest access, the pal addin can be registered with a keyboard shortcut. To do so in RStudio, navigate to `Tools > Modify Keyboard Shortcuts > Search "Pal"`—we suggest `Ctrl+Alt+P` (or `Ctrl+Cmd+P` on macOS).
Pals are interfaced with the via the pal addin. For easiest access, we recommend registering the pal addin to a keyboard shortcut.

**In RStudio**, navigate to `Tools > Modify Keyboard Shortcuts > Search "Pal"`—we suggest `Ctrl+Alt+P` (or `Ctrl+Cmd+P` on macOS).

**In Positron**, you'll need to open the command palette, run "Open Keyboard Shortcuts (JSON)", and paste the following into your `keybindings.json()`:

```json
{
"key": "Ctrl+Cmd+P",
"command": "workbench.action.executeCode.console",
"when": "editorTextFocus",
"args": {
"langId": "r",
"code": "pal::.init_addin()",
"focus": true
}
}
```

The analogous keybinding on non-macOS is `Ctrl+Alt+P`. That said, change the `"key"` entry to any keybinding you wish!

Once those steps are completed, you're ready to use pals with a keyboard shortcut.

## Adding custom pals

Expand Down

0 comments on commit 57bad05

Please sign in to comment.