-
Notifications
You must be signed in to change notification settings - Fork 510
/
Copy pathsettings.ts
165 lines (143 loc) · 5.45 KB
/
settings.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
"use strict";
import vscode = require("vscode");
import utils = require("./utils");
enum CodeFormattingPreset {
Custom,
Allman,
OTBS,
Stroustrup,
}
export class HelpCompletion {
public static readonly Disabled: string = "Disabled";
public static readonly BlockComment: string = "BlockComment";
public static readonly LineComment: string = "LineComment";
}
export interface IPowerShellAdditionalExePathSettings {
versionName: string;
exePath: string;
}
export interface IBugReportingSettings {
project: string;
}
export interface ICodeFormattingSettings {
preset: CodeFormattingPreset;
openBraceOnSameLine: boolean;
newLineAfterOpenBrace: boolean;
newLineAfterCloseBrace: boolean;
whitespaceBeforeOpenBrace: boolean;
whitespaceBeforeOpenParen: boolean;
whitespaceAroundOperator: boolean;
whitespaceAfterSeparator: boolean;
ignoreOneLineBlock: boolean;
alignPropertyValuePairs: boolean;
}
export interface IScriptAnalysisSettings {
enable?: boolean;
settingsPath: string;
}
export interface IDebuggingSettings {
createTemporaryIntegratedConsole?: boolean;
}
export interface IDeveloperSettings {
featureFlags?: string[];
powerShellExePath?: string;
bundledModulesPath?: string;
editorServicesLogLevel?: string;
editorServicesWaitForDebugger?: boolean;
powerShellExeIsWindowsDevBuild?: boolean;
}
export interface ISettings {
powerShellAdditionalExePaths?: IPowerShellAdditionalExePathSettings[];
powerShellDefaultVersion?: string;
powerShellExePath?: string;
startAutomatically?: boolean;
useX86Host?: boolean;
enableProfileLoading?: boolean;
helpCompletion: string;
scriptAnalysis?: IScriptAnalysisSettings;
debugging?: IDebuggingSettings;
developer?: IDeveloperSettings;
codeFormatting?: ICodeFormattingSettings;
integratedConsole?: IIntegratedConsoleSettings;
bugReporting?: IBugReportingSettings;
}
export interface IIntegratedConsoleSettings {
showOnStartup?: boolean;
focusConsoleOnExecute?: boolean;
}
export function load(): ISettings {
const configuration: vscode.WorkspaceConfiguration =
vscode.workspace.getConfiguration(
utils.PowerShellLanguageId);
const defaultBugReportingSettings: IBugReportingSettings = {
project: "https://github.com/PowerShell/vscode-powershell",
};
const defaultScriptAnalysisSettings: IScriptAnalysisSettings = {
enable: true,
settingsPath: "",
};
const defaultDebuggingSettings: IDebuggingSettings = {
createTemporaryIntegratedConsole: false,
};
const defaultDeveloperSettings: IDeveloperSettings = {
featureFlags: [],
powerShellExePath: undefined,
bundledModulesPath: undefined,
editorServicesLogLevel: "Normal",
editorServicesWaitForDebugger: false,
powerShellExeIsWindowsDevBuild: false,
};
const defaultCodeFormattingSettings: ICodeFormattingSettings = {
preset: CodeFormattingPreset.Custom,
openBraceOnSameLine: true,
newLineAfterOpenBrace: true,
newLineAfterCloseBrace: true,
whitespaceBeforeOpenBrace: true,
whitespaceBeforeOpenParen: true,
whitespaceAroundOperator: true,
whitespaceAfterSeparator: true,
ignoreOneLineBlock: true,
alignPropertyValuePairs: true,
};
const defaultIntegratedConsoleSettings: IIntegratedConsoleSettings = {
showOnStartup: true,
focusConsoleOnExecute: true,
};
return {
startAutomatically:
configuration.get<boolean>("startAutomatically", true),
powerShellAdditionalExePaths:
configuration.get<IPowerShellAdditionalExePathSettings[]>("powerShellAdditionalExePaths", undefined),
powerShellDefaultVersion:
configuration.get<string>("powerShellDefaultVersion", undefined),
powerShellExePath:
configuration.get<string>("powerShellExePath", undefined),
useX86Host:
configuration.get<boolean>("useX86Host", false),
enableProfileLoading:
configuration.get<boolean>("enableProfileLoading", false),
helpCompletion:
configuration.get<string>("helpCompletion", HelpCompletion.BlockComment),
scriptAnalysis:
configuration.get<IScriptAnalysisSettings>("scriptAnalysis", defaultScriptAnalysisSettings),
debugging:
configuration.get<IDebuggingSettings>("debugging", defaultDebuggingSettings),
developer:
configuration.get<IDeveloperSettings>("developer", defaultDeveloperSettings),
codeFormatting:
configuration.get<ICodeFormattingSettings>("codeFormatting", defaultCodeFormattingSettings),
integratedConsole:
configuration.get<IIntegratedConsoleSettings>("integratedConsole", defaultIntegratedConsoleSettings),
bugReporting:
configuration.get<IBugReportingSettings>("bugReporting", defaultBugReportingSettings),
};
}
export function change(settingName: string, newValue: any, global: boolean = false): Thenable<void> {
const configuration: vscode.WorkspaceConfiguration =
vscode.workspace.getConfiguration(
utils.PowerShellLanguageId);
return configuration.update(settingName, newValue, global);
}