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

Expose "Open as a Jupyter Notebook" in more places #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A [Visual Studio Code](https://code.visualstudio.com/) [extension](https://marke
* Please install VS Code Insiders (stable is not yet supported)
* Install this extension
* Launch VS Code with the following command line `code-insiders --enable-proposed-api=donjayamanne.vscode-jupytext`
* Right click a file and select `Open as a Jupyter Notebook`
* Run the `Open as a Jupyter Notebook` from the context menu or editor title menu bar for a `*.py` file
* Start executing code against Jupyter Kernels, save changes to notebook will result in the corresponding script file getting updated.


Expand Down
53 changes: 15 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"theme": "dark"
},
"activationEvents": [
"onCommand:jupyter.openAsPairedNotebook",
"onNotebook:jupyter-notebook",
"onFileSystem:jupytext"
"onStartupFinished"
],
"main": "./dist/extension.js",
"capabilities": {
Expand Down Expand Up @@ -57,47 +55,26 @@
"explorer/context": [
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == python"
},
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == r"
},
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == julia"
},
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == fsharp"
},
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == csharp"
},
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == java"
},
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == powershell"
},
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == typescript"
},
"when": "resourceLangId in vscode-jupytext.resourceLangIds"
}
],
"editor/context": [
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == javascript"
},
"when": "resourceLangId in vscode-jupytext.resourceLangIds"
}
],
"editor/title": [
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == markdown"
},
"when": "resourceLangId in vscode-jupytext.resourceLangIds",
"group": "navigation"
Copy link
Author

@congyiwu congyiwu Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI "group": "navigation" makes the command show up next to the icons to the right of the file tabs. Since I didn't add an icon, it just shows the full "Open as Jupyter Notebook" command text

}
],
"editor/title/context": [
{
"command": "jupyter.openAsPairedNotebook",
"when": "resourceLangId == rust"
"when": "resourceLangId in vscode-jupytext.resourceLangIds"
}
]
}
Expand Down
17 changes: 17 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ import { JupyterNotebookView, jupytextScheme } from './constants';
import { convertToNotebook } from './conversion';

export function initialize() {
commands.executeCommand(
'setContext',
'vscode-jupytext.resourceLangIds',
[
'csharp',
'fsharp',
'java',
'javascript',
'julia',
'markdown',
'powershell',
'python',
'r',
'rust',
'typescript'
]);

commands.registerCommand('jupyter.openAsPairedNotebook', async (uri?: Uri) => {
uri = uri || window.activeTextEditor?.document.uri ;
if (!uri){
Expand Down