(context: vscode.ExtensionContext)
| 40 | |
| 41 | // Called (once) when the extension is activated |
| 42 | export async function activate(context: vscode.ExtensionContext): Promise<apiImplementation.RExtensionImplementation> { |
| 43 | if (vscode.extensions.getExtension('mikhail-arkhipov.r')) { |
| 44 | void vscode.window.showInformationMessage('The R Tools (Mikhail-Arkhipov.r) extension is enabled and will have conflicts with vscode-R. To use vscode-R, please disable or uninstall the extension.'); |
| 45 | void vscode.commands.executeCommand('workbench.extensions.search', '@installed R Tools'); |
| 46 | } |
| 47 | |
| 48 | // create a new instance of RExtensionImplementation |
| 49 | // is used to export an interface to the help panel |
| 50 | // this export is used e.g. by vscode-r-debugger to show the help panel from within debug sessions |
| 51 | const rExtension = new apiImplementation.RExtensionImplementation(); |
| 52 | |
| 53 | // assign extension context to global variable |
| 54 | extensionContext = context; |
| 55 | |
| 56 | // assign session watcher setting to global variable |
| 57 | enableSessionWatcher = util.config().get<boolean>('sessionWatcher') ?? false; |
| 58 | rmdPreviewManager = new rmarkdown.RMarkdownPreviewManager(); |
| 59 | rmdKnitManager = new rmarkdown.RMarkdownKnitManager(); |
| 60 | |
| 61 | |
| 62 | // register commands specified in package.json |
| 63 | const commands = { |
| 64 | // create R terminal |
| 65 | 'r.createRTerm': rTerminal.createRTerm, |
| 66 | |
| 67 | // run code from editor in terminal |
| 68 | 'r.nrow': () => rTerminal.runSelectionOrWord(['nrow']), |
| 69 | 'r.length': () => rTerminal.runSelectionOrWord(['length']), |
| 70 | 'r.head': () => rTerminal.runSelectionOrWord(['head']), |
| 71 | 'r.thead': () => rTerminal.runSelectionOrWord(['t', 'head']), |
| 72 | 'r.names': () => rTerminal.runSelectionOrWord(['names']), |
| 73 | 'r.view': () => rTerminal.runSelectionOrWord(['View']), |
| 74 | 'r.runSource': () => { void rTerminal.runSource(false); }, |
| 75 | 'r.runSelection': (code?: string) => { code ? void rTerminal.runTextInTerm(code) : void rTerminal.runSelection(); }, |
| 76 | 'r.runFromLineToEnd': rTerminal.runFromLineToEnd, |
| 77 | 'r.runFromBeginningToLine': rTerminal.runFromBeginningToLine, |
| 78 | 'r.runSelectionRetainCursor': rTerminal.runSelectionRetainCursor, |
| 79 | 'r.runCommandWithSelectionOrWord': rTerminal.runCommandWithSelectionOrWord, |
| 80 | 'r.runCommandWithEditorPath': rTerminal.runCommandWithEditorPath, |
| 81 | 'r.runCommand': rTerminal.runCommand, |
| 82 | 'r.runSourcewithEcho': () => { void rTerminal.runSource(true); }, |
| 83 | |
| 84 | // chunk related |
| 85 | 'r.selectCurrentChunk': rmarkdown.selectCurrentChunk, |
| 86 | 'r.runCurrentChunk': rmarkdown.runCurrentChunk, |
| 87 | 'r.runCurrentChunkAndMove': rmarkdown.runCurrentChunkAndMove, |
| 88 | 'r.runPreviousChunk': rmarkdown.runPreviousChunk, |
| 89 | 'r.runNextChunk': rmarkdown.runNextChunk, |
| 90 | 'r.runAboveChunks': rmarkdown.runAboveChunks, |
| 91 | 'r.runCurrentAndBelowChunks': rmarkdown.runCurrentAndBelowChunks, |
| 92 | 'r.runBelowChunks': rmarkdown.runBelowChunks, |
| 93 | 'r.runAllChunks': rmarkdown.runAllChunks, |
| 94 | 'r.goToPreviousChunk': rmarkdown.goToPreviousChunk, |
| 95 | 'r.goToNextChunk': rmarkdown.goToNextChunk, |
| 96 | 'r.runChunks': rTerminal.runChunksInTerm, |
| 97 | |
| 98 | // rmd related |
| 99 | 'r.knitRmd': () => { void rmdKnitManager?.knitRmd(false, undefined); }, |
nothing calls this directly
no test coverage detected