mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-08-17 00:00:26 +03:00
This has helped resolve a few bugs, but has also generated more spam issues than I can keep up with. To be really useful it needs source maps, which are quite bulky. If we want to revive something like this, we should use VS Code's relatively new telemetry API.
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
/**
|
|
* 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 * 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';
|
|
import { Logger } from './src/util/logger';
|
|
|
|
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;
|
|
|
|
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();
|
|
Logger.info('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);
|
|
}
|