A few small fixes (#8955)

- Fix a typo in the warning message that appears when the .vimrc file fails to open
- Use loadConfiguration` from `extension.ts` instead of `configuration.load
- Use context.globalStorageUri.fsPath instead of context.globalStoragePath which is deprecated
This commit is contained in:
Matteo Planchet 2024-03-26 01:53:48 +01:00 committed by GitHub
parent 771392f9ee
commit 5dd3810926
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 13 deletions

View File

@ -16,11 +16,15 @@ import './src/configuration/validators/neovimValidator';
import './src/configuration/validators/vimrcValidator';
import * as vscode from 'vscode';
import { activate as activateFunc, registerCommand, registerEventListener } from './extensionBase';
import {
activate as activateFunc,
loadConfiguration,
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';
@ -28,18 +32,13 @@ 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;
Globals.extensionStoragePath = context.globalStorageUri.fsPath;
await activateFunc(context);
registerEventListener(context, vscode.workspace.onDidSaveTextDocument, async (document) => {
if (
configuration.vimrc.enable &&
vimrc.vimrcPath &&
path.relative(document.fileName, vimrc.vimrcPath) === ''
) {
// TODO: Should instead probably call `loadConfiguration` (in extensionBase.ts)
await configuration.load();
if (vimrc.vimrcPath && path.relative(document.fileName, vimrc.vimrcPath) === '') {
await loadConfiguration();
Logger.info('Sourced new .vimrc');
}
});
@ -52,7 +51,7 @@ export async function activate(context: vscode.ExtensionContext) {
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.`');
await vscode.window.showWarningMessage('No .vimrc found. Please set `vim.vimrc.path`.');
}
},
false,

View File

@ -71,7 +71,7 @@ export async function getAndUpdateModeHandler(
/**
* Loads and validates the user's configuration
*/
async function loadConfiguration() {
export async function loadConfiguration() {
const validatorResults = await configuration.load();
Logger.debug(`${validatorResults.numErrors} errors found with vim configuration`);

View File

@ -77,7 +77,7 @@ export class VimrcImpl {
? VimrcImpl.expandHome(config.vimrc.path)
: await VimrcImpl.findDefaultVimrc();
if (!_path) {
await window.showWarningMessage('No .vimrc found. Please set `vim.vimrc.path.`');
await window.showWarningMessage('No .vimrc found. Please set `vim.vimrc.path`.');
return;
}
if (!(await fs.existsAsync(_path))) {