Skip to content

Commit 6252d0a

Browse files
committed
commit work on starting settings
1 parent bbd9ce8 commit 6252d0a

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';
@@ -38,7 +42,7 @@ const extension: JupyterLabPlugin<void> = {
3842
id: 'jupyterlab_vim',
3943
autoStart: true,
4044
activate: activateCellVim,
41-
requires: [INotebookTracker]
45+
requires: [INotebookTracker, ISettingRegistry]
4246
};
4347

4448
class VimCell {
@@ -77,8 +81,7 @@ class VimCell {
7781
lvim.defineEx('quit', 'q', function(cm: any) {
7882
commands.execute('notebook:enter-command-mode');
7983
});
80-
81-
(CodeMirror as any).Vim.handleKey(editor.editor, '<Esc>');
84+
lvim.handleKey(editor.editor, '<Esc>');
8285
lvim.defineMotion('moveByLinesOrCell', (cm: any, head: any, motionArgs: any, vim: any) => {
8386
let cur = head;
8487
let endCh = cur.ch;
@@ -186,10 +189,11 @@ class VimCell {
186189
private _app: JupyterLab;
187190
}
188191

189-
function activateCellVim(app: JupyterLab, tracker: INotebookTracker): Promise<void> {
192+
function activateCellVim(app: JupyterLab, tracker: INotebookTracker, settingRegistry: ISettingRegistry): Promise<void> {
193+
const id = plugin.id;
194+
const { commands, shell } = app;
190195

191-
Promise.all([app.restored]).then(([args]) => {
192-
const { commands, shell } = app;
196+
Promise.all([settingRegistry.load(id), app.restored]).then(([settings, args]) => {
193197
function getCurrent(args: ReadonlyJSONObject): NotebookPanel | null {
194198
const widget = tracker.currentWidget;
195199
const activate = args['activate'] !== false;

0 commit comments

Comments
 (0)