-
Notifications
You must be signed in to change notification settings - Fork 130
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
Provide R package-related tasks #59
Comments
@jacob-long Sorry my late reply. |
Hi @jacob-long, I’m following up on some old issues. Are tasks still something you’re keen to see added? |
I think these would be valuable additions to support R package developer workflows. |
@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 Thank you! |
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
}
}
]
} |
based on @crsh's example, I've factored out/expanded this a bit to replicate as much as possible the RStudio build pane. I understand there's a way to make an extension a proper Task provider. I think this might also warrant deprecating the 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"
]
}
]
}
|
@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! |
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 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? |
This comment has been minimized.
This comment has been minimized.
@jolars: I have mapped |
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: |
Nice! I wonder if we can use "problemMatchers" to implement tasks that work on the active document, e.g. "knit". |
@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 |
This is quite a meaty issue now I'm wondering if its worth splitting it into sub issues namely:
|
There are some things added in one of the recent releases that we should consider including as VS Code tasks as well.
In particular, being able to run tests and R CMD check is ideally-suited to tasks.
I wasn't sure whether an extension can provide tasks in this way, but it appears to be possible. I don't know TypeScript well enough to implement, but here's an example of an extension that provides users with tasks: https://github.com/Microsoft/vscode-extension-samples/tree/master/task-provider-sample
I can help in terms of putting together the task definition JSONs since I'm using some in my own projects already.
The text was updated successfully, but these errors were encountered: