Skip to content

Commit 33db9aa

Browse files
committed
commit work on starting settings
1 parent 5211b1d commit 33db9aa

File tree

2 files changed

+63
-6
lines changed

2 files changed

+63
-6
lines changed

schema/plugin.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"jupyter.lab.setting-icon-class": "jp-NotebookIcon",
3+
"jupyter.lab.setting-icon-label": "Notebook",
4+
"title": "Vim Notebook Cell",
5+
"description": "Vim Notebook Cell Settings",
6+
"definitions": {
7+
"editorConfig": {
8+
"properties": {
9+
"autoClosingBrackets": {
10+
"type": "boolean"
11+
},
12+
"lineNumbers": {
13+
"type": "boolean"
14+
},
15+
"lineWrap": {
16+
"type": "boolean"
17+
},
18+
"matchBrackets": {
19+
"type": "boolean"
20+
},
21+
"readOnly": {
22+
"type": "boolean"
23+
},
24+
"insertSpaces": {
25+
"type": "boolean"
26+
},
27+
"tabSize": {
28+
"type": "number"
29+
}
30+
},
31+
"additionalProperties": false,
32+
"type": "object"
33+
}
34+
},
35+
"properties": {
36+
"editorConfig": {
37+
"title": "Editor Configuration",
38+
"description": "The configuration for all text editors.",
39+
"$ref": "#/definitions/editorConfig",
40+
"default": {
41+
"autoClosingBrackets": true,
42+
"lineNumbers": true,
43+
"lineWrap": true,
44+
"matchBrackets": true,
45+
"readOnly": false,
46+
"insertSpaces": true,
47+
"tabSize": 4
48+
}
49+
}
50+
},
51+
"additionalProperties": false,
52+
"type": "object"
53+
}

src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import {
1212
MarkdownCell
1313
} from '@jupyterlab/cells';
1414

15+
import {
16+
ISettingRegistry
17+
} from '@jupyterlab/coreutils';
18+
1519
import {
1620
CodeMirrorEditor
1721
} from '@jupyterlab/codemirror';
@@ -29,7 +33,7 @@ const extension: JupyterLabPlugin<void> = {
2933
id: 'jupyterlab_vim',
3034
autoStart: true,
3135
activate: activateCellVim,
32-
requires: [INotebookTracker]
36+
requires: [INotebookTracker, ISettingRegistry]
3337
};
3438

3539
class VimCell {
@@ -66,8 +70,7 @@ class VimCell {
6670
lvim.defineEx('quit', 'q', function(cm: any) {
6771
commands.execute('notebook:enter-command-mode');
6872
});
69-
70-
(CodeMirror as any).Vim.handleKey(editor.editor, '<Esc>');
73+
lvim.handleKey(editor.editor, '<Esc>');
7174
lvim.defineMotion('moveByLinesOrCell', (cm: any, head: any, motionArgs: any, vim: any) => {
7275
let cur = head;
7376
let endCh = cur.ch;
@@ -162,10 +165,11 @@ class VimCell {
162165
private _app: JupyterLab;
163166
}
164167

165-
function activateCellVim(app: JupyterLab, tracker: INotebookTracker): Promise<void> {
168+
function activateCellVim(app: JupyterLab, tracker: INotebookTracker, settingRegistry: ISettingRegistry): Promise<void> {
169+
const id = plugin.id;
170+
const { commands, shell } = app;
166171

167-
Promise.all([app.restored]).then(([args]) => {
168-
const { commands, shell } = app;
172+
Promise.all([settingRegistry.load(id), app.restored]).then(([settings, args]) => {
169173
function getCurrent(args: ReadonlyJSONObject): NotebookPanel | null {
170174
const widget = tracker.currentWidget;
171175
const activate = args['activate'] !== false;

0 commit comments

Comments
 (0)