-
Notifications
You must be signed in to change notification settings - Fork 138
Preview R Markdown files via background process #692
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
Merged
renkun-ken
merged 21 commits into
REditorSupport:master
from
ElianHugh:rmarkdown-preview
Jul 9, 2021
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
20e5096
Initial rmd preview implementation
ElianHugh 7ec5c65
Add custom context for previews
ElianHugh 7a7559d
Show source, refresh, and open external for rmd previews
ElianHugh 2bd4d53
Refactor, bug fix view column, capitalisation
ElianHugh 5631062
Bugfix inf_mr, R to rPath, progress notification
ElianHugh 2dd2410
Rename commands
ElianHugh d62b82f
Error messages, output channel, and more
ElianHugh 36a0466
Bug squashing
ElianHugh 3e1d208
Cancellable knitting, spam prevention
ElianHugh 634384f
Show output on error, misc changes
ElianHugh 1f361f6
Messy implementation of file watcher
ElianHugh e209371
Make extDir global
renkun-ken dc3a9b5
Set -> Map, cache html content, toggle style, ongoing refactor
ElianHugh a5e15d3
Fix lint
ElianHugh d8053b7
Restructure codebase, some bug fixes, styling
ElianHugh 2d6596a
Style changes
ElianHugh f47ad8e
Minor fixes
renkun-ken 30a8eff
Update openExternalBrowser
renkun-ken b55abef
No openPreview if cancelled
renkun-ken 0ff17d0
Add enable/disable auto refresh command
renkun-ken e42d34f
Update toolbar
renkun-ken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
|
|
||
| // interfaces, functions, etc. provided by vscode | ||
| import * as vscode from 'vscode'; | ||
| import * as os from 'os'; | ||
| import path = require('path'); | ||
| import fs = require('fs'); | ||
|
|
||
| // functions etc. implemented in this extension | ||
| import * as preview from './preview'; | ||
|
|
@@ -19,17 +22,28 @@ import * as completions from './completions'; | |
| import * as rShare from './liveshare'; | ||
| import * as httpgdViewer from './plotViewer'; | ||
|
|
||
| import { RMarkdownPreviewManager } from './rmarkdown/preview'; | ||
|
|
||
| // global objects used in other files | ||
| export const extDir: string = path.join(os.homedir(), '.vscode-R'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we give this a slightly longer/more descriptive name? For local variables, these short names are fine, but global variables should be clear without having to "look them up" in a different file |
||
| export const tmpDir: string = path.join(extDir, 'tmp'); | ||
| export let rWorkspace: workspaceViewer.WorkspaceDataProvider | undefined = undefined; | ||
| export let globalRHelp: rHelp.RHelp | undefined = undefined; | ||
| export let extensionContext: vscode.ExtensionContext; | ||
| export let enableSessionWatcher: boolean = undefined; | ||
| export let globalHttpgdManager: httpgdViewer.HttpgdManager | undefined = undefined; | ||
|
|
||
| export let rMarkdownPreview: RMarkdownPreviewManager | undefined = undefined; | ||
|
|
||
| // Called (once) when the extension is activated | ||
| export async function activate(context: vscode.ExtensionContext): Promise<apiImplementation.RExtensionImplementation> { | ||
| if (!fs.existsSync(extDir)) { | ||
| fs.mkdirSync(extDir); | ||
| } | ||
|
|
||
| if (!fs.existsSync(tmpDir)) { | ||
| fs.mkdirSync(tmpDir); | ||
| } | ||
|
|
||
| // create a new instance of RExtensionImplementation | ||
| // is used to export an interface to the help panel | ||
| // this export is used e.g. by vscode-r-debugger to show the help panel from within debug sessions | ||
|
|
@@ -79,6 +93,15 @@ export async function activate(context: vscode.ExtensionContext): Promise<apiImp | |
| 'r.goToNextChunk': rmarkdown.goToNextChunk, | ||
| 'r.runChunks': rTerminal.runChunksInTerm, | ||
|
|
||
| 'r.markdown.showPreviewToSide': () => rMarkdownPreview.previewRmd(vscode.ViewColumn.Beside), | ||
| 'r.markdown.showPreview': (uri: vscode.Uri) => rMarkdownPreview.previewRmd(vscode.ViewColumn.Active, uri), | ||
| 'r.markdown.preview.refresh': () => rMarkdownPreview.refreshPanel(), | ||
| 'r.markdown.preview.openExternal': () => void rMarkdownPreview.openExternalBrowser(), | ||
| 'r.markdown.preview.showSource': () => rMarkdownPreview.showSource(), | ||
| 'r.markdown.preview.toggleStyle': () => rMarkdownPreview.toggleTheme(), | ||
| 'r.markdown.preview.enableAutoRefresh': () => rMarkdownPreview.enableAutoRefresh(), | ||
| 'r.markdown.preview.disableAutoRefresh': () => rMarkdownPreview.disableAutoRefresh(), | ||
|
|
||
| // editor independent commands | ||
| 'r.createGitignore': rGitignore.createGitignore, | ||
| 'r.loadAll': () => rTerminal.runTextInTerm('devtools::load_all()'), | ||
|
|
@@ -136,6 +159,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<apiImp | |
| // initialize the package/help related functions | ||
| globalRHelp = await rHelp.initializeHelp(context, rExtension); | ||
|
|
||
| // init preview provider | ||
| rMarkdownPreview = new RMarkdownPreviewManager(); | ||
| await rMarkdownPreview.init(); | ||
|
|
||
| // register codelens and complmetion providers for r markdown | ||
| vscode.languages.registerCodeLensProvider(['r', 'rmd'], new rmarkdown.RMarkdownCodeLensProvider()); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest using
"category": "R Markdown"for (most of) these commands, otherwise it's not quite obvious what they do, when invoking them from the command palette