You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@jacob-long Great! It sounds like you might already have some task definition JSON files that you can share? If so, that would be very useful.
I structure most of my projects as packages and use a workflow based around devtools::load_all() and devtools::test(), but I’ve never submitted a package to CRAN, used R CMD, or used VSCode tasks. Would you be able to provide a list of desired tasks and what they should do? I’m happy to help out on the implementation side of things.
based on @crsh's example, I've factored out/expanded this a bit to replicate as much as possible the RStudio build pane.
(Corresponding keymaps are in #551).
I understand there's a way to make an extension a proper Task provider.
I think this might also warrant deprecating the R: Document shortcuts in the command picker now, since a task is arguably the proper way to do this.
In particular, the tasks run in their own R session, which makes sense for devtools::document().
I'm not knowledgeable about TypeScript (?), let alone VSCode extensions, otherwise I'd be happy to make PR, but I can help curate the tasks (rmarkdown, shiny, etc).
Good idea, and thanks for the task configs. To really emulate the functionality from R Studio, it would be nice if it was possible to restart the R Session (and run library(<package>), just like the Install and Restart function does in R Studio.
I've fiddled a bit with the tasks, but I'm not sure how to do this properly. It's of course easy to start up R as part of the task, but then the R extension does not recognize the new console as the "main" R terminal, and sends commands to either a new terminal or the old one (if it was already opened).
What I'd like to achieve is to have the task reuse the standard R terminal. Does anyone know how to achieve this?
@jolars: I have mapped workbench.action.terminal.relaunch to Ctrl + Shift + F10 to restart the active terminal if the active language is R. Works for me.
Enhance existing tasks (currently we have the most basic implementation devtools::document() it might be worth updating them in line with Provide R package-related tasks #59 (comment))
Activity
Ikuyadeu commentedon Apr 15, 2018
@jacob-long Sorry my late reply.
Good idea! if you have a task JSON files, could you share it?
andycraig commentedon Nov 25, 2019
Hi @jacob-long, I’m following up on some old issues. Are tasks still something you’re keen to see added?
jacob-long commentedon Nov 27, 2019
I think these would be valuable additions to support R package developer workflows.
andycraig commentedon Nov 27, 2019
@jacob-long Great! It sounds like you might already have some task definition JSON files that you can share? If so, that would be very useful.
I structure most of my projects as packages and use a workflow based around
devtools::load_all()anddevtools::test(), but I’ve never submitted a package to CRAN, used R CMD, or used VSCode tasks. Would you be able to provide a list of desired tasks and what they should do? I’m happy to help out on the implementation side of things.Thank you!
crsh commentedon Jun 28, 2020
Sorry, to barge in. I'm only just getting started using VS Code, but in case it helps, my set up looks as follows:
{ "version": "2.0.0", "tasks": [ { "label": "Build package", "type": "shell", "command": "RScript -e 'devtools::install(upgrade = \"never\")'", "presentation": { "reveal": "always" }, "problemMatcher": [], "group": { "kind": "build", "isDefault": true } }, { "label": "Run unit tests", "type": "shell", "command": "RScript -e 'devtools::test()'", "presentation": { "reveal": "always" }, "problemMatcher": [], "group": { "kind": "test", "isDefault": true } }, { "label": "Run R CMD checks", "type": "shell", "command": "RScript -e 'devtools::check()'", "presentation": { "reveal": "always" }, "problemMatcher": [], "group": { "kind": "test", "isDefault": false } } ] }maxheld83 commentedon Feb 9, 2021
based on @crsh's example, I've factored out/expanded this a bit to replicate as much as possible the RStudio build pane.
(Corresponding keymaps are in #551).
I understand there's a way to make an extension a proper Task provider.
I think this might also warrant deprecating the
R: Documentshortcuts in the command picker now, since a task is arguably the proper way to do this.In particular, the tasks run in their own R session, which makes sense for
devtools::document().I'm not knowledgeable about TypeScript (?), let alone VSCode extensions, otherwise I'd be happy to make PR, but I can help curate the tasks (rmarkdown, shiny, etc).
Here's what I got:
{ "version": "2.0.0", "options": { "shell": { "executable": "Rscript", "args": [ "-e" ] } }, "presentation": { "reveal": "always", "panel": "shared", "showReuseMessage": false, "group": "build" }, "type": "shell", "problemMatcher": [], "tasks": [ { "label": "Document", "command": "devtools::document(roclets = c('rd', 'collate', 'namespace'))", "problemMatcher": [] }, { "label": "Install", "command": "devtools::install(quick = TRUE, upgrade = 'never')", "group": "build", "dependsOn": "Document" }, { "label": "Test", "command": "devtools::test()", "group": "test", "problemMatcher": [] }, { "label": "Check", "command": "devtools::check(error_on = 'warning')", "group": { "kind": "test", "isDefault": true }, "dependsOn": "Document" }, { "label": "Pkgdown", "command": "muggle::build_site2()", "group": { "kind": "build", "isDefault": true }, "dependsOn": "Document", "problemMatcher": [] }, { "label": "Build and Test", "dependsOn": [ "Pkgdown", "Check" ] } ] }andycraig commentedon Feb 11, 2021
@crsh Thank you for posting that info, and apologies for not responding! I completely missed the notification.
@maxheld83 Thank you for the followup on this issue. This isn't something I'm going to pursue any time soon, but contributions are very welcome!
jolars commentedon Feb 26, 2021
Good idea, and thanks for the task configs. To really emulate the functionality from R Studio, it would be nice if it was possible to restart the R Session (and run
library(<package>), just like the Install and Restart function does in R Studio.I've fiddled a bit with the tasks, but I'm not sure how to do this properly. It's of course easy to start up R as part of the task, but then the R extension does not recognize the new console as the "main" R terminal, and sends commands to either a new terminal or the old one (if it was already opened).
What I'd like to achieve is to have the task reuse the standard R terminal. Does anyone know how to achieve this?
maxheld83 commentedon Feb 26, 2021
krlmlr commentedon Mar 17, 2021
@jolars: I have mapped
workbench.action.terminal.relaunchto Ctrl + Shift + F10 to restart the active terminal if the active language is R. Works for me.andycraig commentedon Apr 4, 2021
I've added tasks for Check, Document, Install and Test.
It should be fairly easy to add new tasks by copy-pasting the code for these tasks, which is here:
https://github.com/Ikuyadeu/vscode-R/blob/17a7d69423d3a4377211e83f39ebc3bceba6ab69/src/extension.ts#L147-L154
krlmlr commentedon Apr 5, 2021
Nice! I wonder if we can use "problemMatchers" to implement tasks that work on the active document, e.g. "knit".
andycraig commentedon Apr 5, 2021
@krlmlr I think problem matchers work on the output of tasks. For tasks that use the active file, we might be able to use variable substitution: https://code.visualstudio.com/docs/editor/variables-reference
gowerc commentedon Feb 16, 2022
This is quite a meaty issue now I'm wondering if its worth splitting it into sub issues namely:
devtools::document()it might be worth updating them in line with Provide R package-related tasks #59 (comment))ThomasSoeiro commentedon Sep 26, 2026
#1474 (now closed) specifically asked support for
devtools::test_active_file()ThomasSoeiro commentedon Sep 27, 2026
@eitsupi @Fred-Wu @grantmcdermott Perhaps it can be converted to discussion?