forked from VSCodeVim/Vim
-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.ts
66 lines (55 loc) · 2.05 KB
/
extension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Extension.ts is a lightweight wrapper around ModeHandler. It converts key
* events to their string names and passes them on to ModeHandler via
* handleKeyEvent().
*/
import './src/actions/include-main';
import './src/actions/include-plugins';
/**
* Load configuration validator
*/
import './src/configuration/validators/inputMethodSwitcherValidator';
import './src/configuration/validators/remappingValidator';
import './src/configuration/validators/neovimValidator';
import './src/configuration/validators/vimrcValidator';
import { install as installSourceMapSupport } from 'source-map-support';
import * as vscode from 'vscode';
import { activate as activateFunc, registerCommand, registerEventListener } from './extensionBase';
import { Globals } from './src/globals';
import { Register } from './src/register/register';
import { vimrc } from './src/configuration/vimrc';
import { configuration } from './src/configuration/configuration';
import * as path from 'path';
export { getAndUpdateModeHandler } from './extensionBase';
export async function activate(context: vscode.ExtensionContext) {
// Set the storage path to be used by history files
Globals.extensionStoragePath = context.globalStoragePath;
installSourceMapSupport();
await activateFunc(context);
registerEventListener(context, vscode.workspace.onDidSaveTextDocument, async (document) => {
if (
configuration.vimrc.enable &&
vimrc.vimrcPath &&
path.relative(document.fileName, vimrc.vimrcPath) === ''
) {
await configuration.load();
vscode.window.showInformationMessage('Sourced new .vimrc');
}
});
registerCommand(
context,
'vim.editVimrc',
async () => {
if (vimrc.vimrcPath) {
const document = await vscode.workspace.openTextDocument(vimrc.vimrcPath);
await vscode.window.showTextDocument(document);
} else {
await vscode.window.showWarningMessage('No .vimrc found. Please set `vim.vimrc.path.`');
}
},
false
);
}
export async function deactivate() {
await Register.saveToDisk(true);
}