2016-05-28 01:49:35 +03:00
|
|
|
/**
|
|
|
|
* Extension.ts is a lightweight wrapper around ModeHandler. It converts key
|
|
|
|
* events to their string names and passes them on to ModeHandler via
|
|
|
|
* handleKeyEvent().
|
|
|
|
*/
|
2020-06-30 22:58:03 +03:00
|
|
|
import './src/actions/include-main';
|
|
|
|
import './src/actions/include-plugins';
|
2015-11-17 09:14:48 +03:00
|
|
|
|
2019-12-03 06:48:40 +03:00
|
|
|
/**
|
2020-06-30 22:58:03 +03:00
|
|
|
* Load configuration validator
|
2019-12-03 06:48:40 +03:00
|
|
|
*/
|
2019-01-29 07:21:56 +03:00
|
|
|
|
2020-06-30 22:58:03 +03:00
|
|
|
import './src/configuration/validators/inputMethodSwitcherValidator';
|
|
|
|
import './src/configuration/validators/remappingValidator';
|
|
|
|
import './src/configuration/validators/neovimValidator';
|
|
|
|
import './src/configuration/validators/vimrcValidator';
|
2018-06-15 20:59:48 +03:00
|
|
|
|
2020-06-30 22:58:03 +03:00
|
|
|
import * as vscode from 'vscode';
|
2024-03-26 03:53:48 +03:00
|
|
|
import {
|
|
|
|
activate as activateFunc,
|
|
|
|
loadConfiguration,
|
|
|
|
registerCommand,
|
|
|
|
registerEventListener,
|
|
|
|
} from './extensionBase';
|
2020-06-30 22:58:03 +03:00
|
|
|
import { Globals } from './src/globals';
|
2020-11-21 05:23:37 +03:00
|
|
|
import { Register } from './src/register/register';
|
2022-02-18 20:12:05 +03:00
|
|
|
import { vimrc } from './src/configuration/vimrc';
|
|
|
|
import * as path from 'path';
|
2023-02-16 07:22:59 +03:00
|
|
|
import { Logger } from './src/util/logger';
|
2019-01-31 22:07:47 +03:00
|
|
|
|
2020-06-30 22:58:03 +03:00
|
|
|
export { getAndUpdateModeHandler } from './extensionBase';
|
2018-05-09 20:23:28 +03:00
|
|
|
|
2020-06-30 22:58:03 +03:00
|
|
|
export async function activate(context: vscode.ExtensionContext) {
|
2019-10-27 08:01:49 +03:00
|
|
|
// Set the storage path to be used by history files
|
2024-03-26 03:53:48 +03:00
|
|
|
Globals.extensionStoragePath = context.globalStorageUri.fsPath;
|
2019-10-27 08:01:49 +03:00
|
|
|
|
2022-02-18 20:12:05 +03:00
|
|
|
await activateFunc(context);
|
|
|
|
|
|
|
|
registerEventListener(context, vscode.workspace.onDidSaveTextDocument, async (document) => {
|
2024-03-26 03:53:48 +03:00
|
|
|
if (vimrc.vimrcPath && path.relative(document.fileName, vimrc.vimrcPath) === '') {
|
|
|
|
await loadConfiguration();
|
2023-02-16 07:22:59 +03:00
|
|
|
Logger.info('Sourced new .vimrc');
|
2022-02-18 20:12:05 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
registerCommand(
|
|
|
|
context,
|
|
|
|
'vim.editVimrc',
|
|
|
|
async () => {
|
|
|
|
if (vimrc.vimrcPath) {
|
|
|
|
const document = await vscode.workspace.openTextDocument(vimrc.vimrcPath);
|
|
|
|
await vscode.window.showTextDocument(document);
|
|
|
|
} else {
|
2024-03-26 03:53:48 +03:00
|
|
|
await vscode.window.showWarningMessage('No .vimrc found. Please set `vim.vimrc.path`.');
|
2022-02-18 20:12:05 +03:00
|
|
|
}
|
|
|
|
},
|
2023-09-10 02:57:26 +03:00
|
|
|
false,
|
2022-02-18 20:12:05 +03:00
|
|
|
);
|
2016-09-03 10:36:44 +03:00
|
|
|
}
|
2020-11-21 05:23:37 +03:00
|
|
|
|
|
|
|
export async function deactivate() {
|
2020-12-07 20:18:49 +03:00
|
|
|
await Register.saveToDisk(true);
|
2020-11-21 05:23:37 +03:00
|
|
|
}
|