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

Enhance R markdown support #429

Merged
merged 16 commits into from
Oct 30, 2020
Merged

Conversation

renkun-ken
Copy link
Member

@renkun-ken renkun-ken commented Oct 24, 2020

What problem did you solve?

Close #428, #49, #261

  • Run chunk and Run above command
  • Highlight code chunks
  • Respect chunk options (Run above should skip chunks with eval=FALSE)
  • Command to run current chunk
  • Completions for chunk options

(If you have)Screenshot

Kapture 2020-10-28 at 22 25 08

How to test:

  1. Create a Rmd document with a number of code chunks (using r chunk snippet)
  2. Above each chunk there are two CodeLens items: Run Chunk and Run Above.
  3. Each chunk has background highlighting.
  4. Click Run Chunk and the chunk code is sent to terminal
  5. Click Run Above and the code above the chunk is combined and sent to terminal
  6. If a chunk has option eval=FALSE then Run Above will not include such chunks.
  7. Put cursor in a chunk and run R: Run Current Chunk and the chunk is sent to terminal.8
  8. If cursor is outside any chunk, run R: Run Current Chunk and nothing happens.
  9. Pressing Ctrl+shift+enter should trigger R: Run Current Chunk by default (same as RStudio).
  10. Editing chunk header will trigger chunk options completion and selecting an item will insert {label}= to the editor.

@renkun-ken renkun-ken changed the title WIP: Enhance R markdown support Enhance R markdown support Oct 28, 2020
@renkun-ken
Copy link
Member Author

@Ikuyadeu @andycraig

I'm wondering if we already have a shortcut/command/snippet to insert an R code chunk like the following?

```{r}

```

I tried adding a snippet to snippets/markdown.json but it seems that changing (even removing all content from) the file does not have any effect at all.

@MilesMcBain
Copy link
Collaborator

I like the background highlighting, looks great.

Would you consider an option to disable the text links?

I like a really minimal editor layout, with things driven by keybindings. I usually program in 'zen mode'.

Of course this is my selfish personal preference. I know many users would appreciate the links.

@renkun-ken
Copy link
Member Author

Would you consider an option to disable the text links?

By text links, do you mean the "Run Chunk" and "Run Above" CodeLens commands? You could disable CodeLens globally with the following settings:

"editor.codeLens": false

or just disable it for Rmd:

"[rmd]": {
  "editor.codeLens": false
}

@Ikuyadeu
Copy link
Member

Ikuyadeu commented Oct 29, 2020

@renkun-ken

I tried adding a snippet to snippets/markdown.json but it seems that changing (even removing all content from) the file does not have any effect at all.

Currently, we are using r markdown snippets by using markdown snippets and our snippets file is not working.
We can use our own snippets by just deleting
https://github.com/Ikuyadeu/vscode-R/blob/master/package.json#L143

@renkun-ken
Copy link
Member Author

@Ikuyadeu Thanks!

I've switched to our own snippets for rmd and it is much easier to insert an R chunk now.

Kapture 2020-10-29 at 22 56 33

@Ikuyadeu Ikuyadeu merged commit 4fd1fc9 into REditorSupport:master Oct 30, 2020
@andycraig
Copy link
Collaborator

@renkun-ken People (including me) have wanted these features for ages - thank you very much for this PR!

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.

Enhance R Markdown support
4 participants