diff --git a/README.md b/README.md index abc5c40..9a8c1df 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index cec847b..197dfec 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,7 @@ "theme": "dark" }, "activationEvents": [ - "onCommand:jupyter.openAsPairedNotebook", - "onNotebook:jupyter-notebook", - "onFileSystem:jupytext" + "onStartupFinished" ], "main": "./dist/extension.js", "capabilities": { @@ -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" + } + ], + "editor/title/context": [ { "command": "jupyter.openAsPairedNotebook", - "when": "resourceLangId == rust" + "when": "resourceLangId in vscode-jupytext.resourceLangIds" } ] } diff --git a/src/commands.ts b/src/commands.ts index 9425a41..4f6094f 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -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){