forked from swiftlang/vscode-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.ts
139 lines (132 loc) · 5.07 KB
/
configuration.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
//===----------------------------------------------------------------------===//
//
// This source file is part of the VSCode Swift open source project
//
// Copyright (c) 2021 the VSCode Swift project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of VSCode Swift project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import * as vscode from "vscode";
/** sourcekit-lsp configuration */
export interface LSPConfiguration {
/** Path to sourcekit-lsp executable */
readonly serverPath: string;
/** Arguments to pass to sourcekit-lsp executable */
readonly serverArguments: string[];
/** Are inlay hints enabled */
readonly inlayHintsEnabled: boolean;
}
/** build destination configuration */
export interface DestinationConfiguration {
/** Target triple */
target: string | undefined;
/** Path to destination SDK */
sdk: string | undefined;
/** Path to tools directory */
binDir: string | undefined;
/** Extra arguments to pass to Swift compiler */
extraSwiftCFlags: string[] | undefined;
/** Extra arguments to pass to C compiler */
extraCCFlags: string[] | undefined;
/** Extra arguments to pass to C++ compiler */
extraCPPFlags: string[] | undefined;
}
/**
* Type-safe wrapper around configuration settings.
*/
const configuration = {
/** sourcekit-lsp configuration */
get lsp(): LSPConfiguration {
return {
get serverPath(): string {
return vscode.workspace
.getConfiguration("sourcekit-lsp")
.get<string>("serverPath", "");
},
get serverArguments(): string[] {
return vscode.workspace
.getConfiguration("sourcekit-lsp")
.get<string[]>("serverArguments", []);
},
get inlayHintsEnabled(): boolean {
return vscode.workspace
.getConfiguration("sourcekit-lsp")
.get<boolean>("inlayHints.enabled", true);
},
};
},
/** build destination configuration */
get destination(): DestinationConfiguration | string {
const configuration = vscode.workspace
.getConfiguration("swift")
.get<string | DestinationConfiguration>("destination", "");
return configuration;
},
/** Files and directories to exclude from the Package Dependencies view. */
get excludePathsFromPackageDependencies(): string[] {
return vscode.workspace
.getConfiguration("swift")
.get<string[]>("excludePathsFromPackageDependencies", []);
},
/** Folders to exclude from package dependency view */
set excludePathsFromPackageDependencies(value: string[]) {
vscode.workspace
.getConfiguration("swift")
.update("excludePathsFromPackageDependencies", value);
},
/** Path to folder that include swift executable */
get path(): string {
return vscode.workspace.getConfiguration("swift").get<string>("path", "");
},
/** Path to folder that include swift runtime */
get runtimePath(): string {
return vscode.workspace.getConfiguration("swift").get<string>("runtimePath", "");
},
/** swift build arguments */
get buildArguments(): string[] {
return vscode.workspace.getConfiguration("swift").get<string[]>("buildArguments", []);
},
get buildPath(): string {
return vscode.workspace.getConfiguration("swift").get<string>("buildPath", "");
},
/** Environment variables to set when building */
get swiftEnvironmentVariables(): { [key: string]: string } {
return vscode.workspace
.getConfiguration("swift")
.get<{ [key: string]: string }>("swiftEnvironmentVariables", {});
},
/** include build errors in problems view */
get problemMatchCompileErrors(): boolean {
return vscode.workspace
.getConfiguration("swift")
.get<boolean>("problemMatchCompileErrors", true);
},
/** auto-generate launch.json configurations */
get autoGenerateLaunchConfigurations(): boolean {
return vscode.workspace
.getConfiguration("swift")
.get<boolean>("autoGenerateLaunchConfigurations", true);
},
/** background compilation */
get backgroundCompilation(): boolean {
return vscode.workspace
.getConfiguration("swift")
.get<boolean>("backgroundCompilation", false);
},
/** output additional diagnostics */
get diagnostics(): boolean {
return vscode.workspace.getConfiguration("swift").get<boolean>("diagnostics", false);
},
/** Environment variables to set when running tests */
get testEnvironmentVariables(): { [key: string]: string } {
return vscode.workspace
.getConfiguration("swift")
.get<{ [key: string]: string }>("testEnvironmentVariables", {});
},
};
export default configuration;