-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfiguration.ts
More file actions
82 lines (73 loc) · 2.24 KB
/
configuration.ts
File metadata and controls
82 lines (73 loc) · 2.24 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import * as vscode from 'vscode';
import { ExtensionConfig, LogLevel } from './types';
import { CONFIGURATION_BASENAME } from './utils';
/**
* Configuration manager for the PowerShell Localization extension
*/
export class ConfigurationManager {
/**
* Gets the current extension configuration
*/
public static getConfiguration(): ExtensionConfig {
const config = vscode.workspace.getConfiguration(CONFIGURATION_BASENAME);
return {
enableInlineValues: config.get<boolean>('enableInlineValues', false), // Disabled by default since we're using decorations now
enableDecorations: config.get<boolean>('enableDecorations', true),
searchExclude: config.get<string[]>('searchExclude', [
'**/node_modules/**',
'**/out/**',
'**/dist/**',
'**/.git/**'
]),
logLevel: config.get<LogLevel>('logLevel', 'info'),
uiCulture: config.get<string>('uiCulture', 'en-US')
};
}
/**
* Checks if inline values are enabled
*/
public static isInlineValuesEnabled(): boolean {
return this.getConfiguration().enableInlineValues;
}
/**
* Checks if decorations are enabled
*/
public static isDecorationEnabled(): boolean {
return this.getConfiguration().enableDecorations;
}
/**
* Gets the search exclude patterns
*/
public static getSearchExcludePatterns(): string[] {
return this.getConfiguration().searchExclude;
}
/**
* Gets the current log level
*/
public static getLogLevel(): LogLevel {
return this.getConfiguration().logLevel;
}
/**
* Gets the current UI culture
*/
public static getUICulture(): string {
return this.getConfiguration().uiCulture;
}
/**
* Sets the UI culture
*/
public static async setUICulture(culture: string): Promise<void> {
const config = vscode.workspace.getConfiguration(CONFIGURATION_BASENAME);
await config.update('uiCulture', culture, vscode.ConfigurationTarget.Global);
}
/**
* Registers configuration change listener
*/
public static onConfigurationChanged(callback: () => void): vscode.Disposable {
return vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration(CONFIGURATION_BASENAME)) {
callback();
}
});
}
}