Skip to content
Closed
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
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
"schema/*.json"
],
"jupyterlab": {
"extension": true
"extension": true,
"schemaDir": "schema"
},
"dependencies": {
"@jupyterlab/application": "^1.0.1",
"@jupyterlab/codemirror": "^1.0.1",
"@jupyterlab/cells": "^1.0.1",
"@jupyterlab/notebook": "^1.0.1",
"@jupyterlab/coreutils": "^3.0.0",
"@phosphor/commands": "^1.6.3",
"@phosphor/coreutils": "^1.3.1",
"@phosphor/domutils": "^1.1.3",
Expand Down
15 changes: 15 additions & 0 deletions schema/vim.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"jupyter.lab.setting-icon-class": "jp-NotebookIcon",
"jupyter.lab.setting-icon-label": "Notebook",
"title": "Vim Notebook Cell",
"description": "Vim Notebook Cell Settings",
"properties": {
"enable": {
"type": "boolean",
"title": "Enable",
"description": "Whether to enable the extension.",
"default": true
}
},
"type": "object"
}
19 changes: 14 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import {
MarkdownCell
} from '@jupyterlab/cells';

import {
ISettingRegistry
} from '@jupyterlab/coreutils';

import {
CodeMirrorEditor
} from '@jupyterlab/codemirror';
Expand All @@ -38,10 +42,10 @@ const IS_MAC = !!navigator.platform.match(/Mac/i);
* Initialization data for the jupyterlab_vim extension.
*/
const extension: JupyterFrontEndPlugin<void> = {
id: 'jupyterlab_vim',
id: 'jupyterlab_vim:vim',
autoStart: true,
activate: activateCellVim,
requires: [INotebookTracker]
requires: [INotebookTracker, ISettingRegistry]
};

class VimCell {
Expand Down Expand Up @@ -189,10 +193,15 @@ class VimCell {
private _app: JupyterFrontEnd;
}

function activateCellVim(app: JupyterFrontEnd, tracker: INotebookTracker): Promise<void> {
function activateCellVim(app: JupyterFrontEnd, tracker: INotebookTracker, settingRegistry: ISettingRegistry): Promise<void> {
const id = extension.id;
const { commands, shell } = app;

Promise.all([app.restored]).then(([args]) => {
const { commands, shell } = app;
Promise.all([settingRegistry.load(id), app.restored]).then(([settings, args]) => {
const enabled = settings.get('enable').composite as boolean;
if (enabled === false) {
return;
}
function getCurrent(args: ReadonlyJSONObject): NotebookPanel | null {
const widget = tracker.currentWidget;
const activate = args['activate'] !== false;
Expand Down