Skip to content

Commit c92f73d

Browse files
committed
Make preference keys more structured
1 parent 41472e3 commit c92f73d

File tree

1 file changed

+102
-122
lines changed

1 file changed

+102
-122
lines changed

Core/Sources/Preferences/Keys.swift

Lines changed: 102 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,7 @@ public protocol UserDefaultPreferenceKey {
99
public struct UserDefaultPreferenceKeys {
1010
public init() {}
1111

12-
// MARK: - Realtime Suggestion
13-
14-
public struct RealtimeSuggestionToggle: UserDefaultPreferenceKey {
15-
public let defaultValue: Bool = true
16-
public let key = "RealtimeSuggestionToggle"
17-
}
18-
19-
public var realtimeSuggestionToggle: RealtimeSuggestionToggle { .init() }
20-
21-
// MARK: - Suggestion Feature Provider
22-
23-
public struct SuggestionFeatureProviderKey: UserDefaultPreferenceKey {
24-
public let defaultValue: SuggestionFeatureProvider = .gitHubCopilot
25-
public let key = "SuggestionFeatureProvider"
26-
}
27-
28-
public var suggestionFeatureProvider: SuggestionFeatureProviderKey { .init() }
29-
30-
// MARK: - Realtime Suggestion Debounce
31-
32-
public struct RealtimeSuggestionDebounce: UserDefaultPreferenceKey {
33-
public let defaultValue: Double = 1
34-
public let key = "RealtimeSuggestionDebounce"
35-
}
36-
37-
public var realtimeSuggestionDebounce: RealtimeSuggestionDebounce { .init() }
38-
39-
// MARK: - Quit XPC Service On Xcode And App Quit
12+
// MARK: Quit XPC Service On Xcode And App Quit
4013

4114
public struct QuitXPCServiceOnXcodeAndAppQuit: UserDefaultPreferenceKey {
4215
public let defaultValue = true
@@ -45,16 +18,7 @@ public struct UserDefaultPreferenceKeys {
4518

4619
public var quitXPCServiceOnXcodeAndAppQuit: QuitXPCServiceOnXcodeAndAppQuit { .init() }
4720

48-
// MARK: - Suggestion Presentation Mode
49-
50-
public struct SuggestionPresentationMode: UserDefaultPreferenceKey {
51-
public let defaultValue = PresentationMode.floatingWidget
52-
public let key = "SuggestionPresentationMode"
53-
}
54-
55-
public var suggestionPresentationMode: SuggestionPresentationMode { .init() }
56-
57-
// MARK: - Automatically Check For Update
21+
// MARK: Automatically Check For Update
5822

5923
public struct AutomaticallyCheckForUpdate: UserDefaultPreferenceKey {
6024
public let defaultValue = false
@@ -63,7 +27,7 @@ public struct UserDefaultPreferenceKeys {
6327

6428
public var automaticallyCheckForUpdate: AutomaticallyCheckForUpdate { .init() }
6529

66-
// MARK: - Suggestion Widget Position Mode
30+
// MARK: Suggestion Widget Position Mode
6731

6832
public struct SuggestionWidgetPositionModeKey: UserDefaultPreferenceKey {
6933
public let defaultValue = SuggestionWidgetPositionMode.fixedToBottom
@@ -72,7 +36,7 @@ public struct UserDefaultPreferenceKeys {
7236

7337
public var suggestionWidgetPositionMode: SuggestionWidgetPositionModeKey { .init() }
7438

75-
// MARK: - Widget Color Scheme
39+
// MARK: Widget Color Scheme
7640

7741
public struct WidgetColorSchemeKey: UserDefaultPreferenceKey {
7842
public let defaultValue = WidgetColorScheme.dark
@@ -81,38 +45,7 @@ public struct UserDefaultPreferenceKeys {
8145

8246
public var widgetColorScheme: WidgetColorSchemeKey { .init() }
8347

84-
// MARK: - Accept Suggestion with Accessibility API
85-
86-
public struct AcceptSuggestionWithAccessibilityAPI: UserDefaultPreferenceKey {
87-
public let defaultValue = false
88-
public let key = "AcceptSuggestionWithAccessibilityAPI"
89-
}
90-
91-
public var acceptSuggestionWithAccessibilityAPI: AcceptSuggestionWithAccessibilityAPI {
92-
.init()
93-
}
94-
95-
// MARK: - Use Global Chat
96-
97-
public struct UseGlobalChat: UserDefaultPreferenceKey {
98-
public let defaultValue = true
99-
public let key = "UseGlobalChat"
100-
}
101-
102-
public var useGlobalChat: UseGlobalChat { .init() }
103-
104-
// MARK: - Hide Common Preceding Spaces in Suggestion
105-
106-
public struct HideCommonPrecedingSpacesInSuggestion: UserDefaultPreferenceKey {
107-
public let defaultValue = true
108-
public let key = "HideCommonPrecedingSpacesInSuggestion"
109-
}
110-
111-
public var hideCommonPrecedingSpacesInSuggestion: HideCommonPrecedingSpacesInSuggestion {
112-
.init()
113-
}
114-
115-
// MARK: - Force Order Widget to Front
48+
// MARK: Force Order Widget to Front
11649

11750
public struct ForceOrderWidgetToFront: UserDefaultPreferenceKey {
11851
public let defaultValue = true
@@ -123,51 +56,7 @@ public struct UserDefaultPreferenceKeys {
12356
.init()
12457
}
12558

126-
// MARK: - Disable Suggestion Feature Globally
127-
128-
public struct DisableSuggestionFeatureGlobally: UserDefaultPreferenceKey {
129-
public let defaultValue = false
130-
public let key = "DisableSuggestionFeatureGlobally"
131-
}
132-
133-
public var disableSuggestionFeatureGlobally: DisableSuggestionFeatureGlobally {
134-
.init()
135-
}
136-
137-
// MARK: - Suggestion Feature Enabled Project List
138-
139-
public struct SuggestionFeatureEnabledProjectList: UserDefaultPreferenceKey {
140-
public let defaultValue: [String] = []
141-
public let key = "SuggestionFeatureEnabledProjectList"
142-
}
143-
144-
public var suggestionFeatureEnabledProjectList: SuggestionFeatureEnabledProjectList {
145-
.init()
146-
}
147-
148-
// MARK: - Suggestion Feature Disabled Language List
149-
150-
public struct SuggestionFeatureDisabledLanguageList: UserDefaultPreferenceKey {
151-
public let defaultValue: [String] = []
152-
public let key = "SuggestionFeatureDisabledLanguageList"
153-
}
154-
155-
public var suggestionFeatureDisabledLanguageList: SuggestionFeatureDisabledLanguageList {
156-
.init()
157-
}
158-
159-
// MARK: - Prompt to Code Feature Provider
160-
161-
public struct PromptToCodeFeatureProviderKey: UserDefaultPreferenceKey {
162-
public let defaultValue: PromptToCodeFeatureProvider = .openAI
163-
public let key = "PromptToCodeFeatureProvider"
164-
}
165-
166-
public var promptToCodeFeatureProvider: PromptToCodeFeatureProviderKey {
167-
.init()
168-
}
169-
170-
// MARK: - Prefer Widget to Stay Inside Editor When Width Greater Than
59+
// MARK: Prefer Widget to Stay Inside Editor When Width Greater Than
17160

17261
public struct PreferWidgetToStayInsideEditorWhenWidthGreaterThan: UserDefaultPreferenceKey {
17362
public let defaultValue = 1400 as Double
@@ -242,17 +131,13 @@ public extension UserDefaultPreferenceKeys {
242131

243132
var gitHubCopilotVerboseLog: GitHubCopilotVerboseLog { .init() }
244133

245-
// MARK: - Node Path
246-
247134
struct NodePath: UserDefaultPreferenceKey {
248135
public let defaultValue: String = ""
249136
public let key = "NodePath"
250137
}
251138

252139
var nodePath: NodePath { .init() }
253140

254-
// MARK: - Run Node With
255-
256141
struct RunNodeWithKey: UserDefaultPreferenceKey {
257142
public let defaultValue = NodeRunner.bash
258143
public let key = "RunNodeWith"
@@ -272,7 +157,18 @@ public extension UserDefaultPreferenceKeys {
272157
var codeiumVerboseLog: CodeiumVerboseLog { .init() }
273158
}
274159

160+
// MARK: - Prompt to Code
161+
275162
public extension UserDefaultPreferenceKeys {
163+
struct PromptToCodeFeatureProviderKey: UserDefaultPreferenceKey {
164+
public let defaultValue: PromptToCodeFeatureProvider = .openAI
165+
public let key = "PromptToCodeFeatureProvider"
166+
}
167+
168+
var promptToCodeFeatureProvider: PromptToCodeFeatureProviderKey {
169+
.init()
170+
}
171+
276172
struct PromptToCodeGenerateDescription: UserDefaultPreferenceKey {
277173
public let defaultValue = true
278174
public let key = "PromptToCodeGenerateDescription"
@@ -290,16 +186,93 @@ public extension UserDefaultPreferenceKeys {
290186
}
291187
}
292188

293-
// MARK: - UI
189+
// MARK: - Suggestion
294190

295191
public extension UserDefaultPreferenceKeys {
192+
struct SuggestionFeatureProviderKey: UserDefaultPreferenceKey {
193+
public let defaultValue: SuggestionFeatureProvider = .gitHubCopilot
194+
public let key = "SuggestionFeatureProvider"
195+
}
196+
197+
var suggestionFeatureProvider: SuggestionFeatureProviderKey { .init() }
198+
199+
struct RealtimeSuggestionToggle: UserDefaultPreferenceKey {
200+
public let defaultValue: Bool = true
201+
public let key = "RealtimeSuggestionToggle"
202+
}
203+
204+
var realtimeSuggestionToggle: RealtimeSuggestionToggle { .init() }
205+
296206
struct SuggestionCodeFontSize: UserDefaultPreferenceKey {
297207
public let defaultValue = 13 as Double
298208
public let key = "SuggestionCodeFontSize"
299209
}
300210

301211
var suggestionCodeFontSize: SuggestionCodeFontSize { .init() }
302212

213+
struct DisableSuggestionFeatureGlobally: UserDefaultPreferenceKey {
214+
public let defaultValue = false
215+
public let key = "DisableSuggestionFeatureGlobally"
216+
}
217+
218+
var disableSuggestionFeatureGlobally: DisableSuggestionFeatureGlobally {
219+
.init()
220+
}
221+
222+
struct SuggestionFeatureEnabledProjectList: UserDefaultPreferenceKey {
223+
public let defaultValue: [String] = []
224+
public let key = "SuggestionFeatureEnabledProjectList"
225+
}
226+
227+
var suggestionFeatureEnabledProjectList: SuggestionFeatureEnabledProjectList {
228+
.init()
229+
}
230+
231+
struct SuggestionFeatureDisabledLanguageList: UserDefaultPreferenceKey {
232+
public let defaultValue: [String] = []
233+
public let key = "SuggestionFeatureDisabledLanguageList"
234+
}
235+
236+
var suggestionFeatureDisabledLanguageList: SuggestionFeatureDisabledLanguageList {
237+
.init()
238+
}
239+
240+
struct HideCommonPrecedingSpacesInSuggestion: UserDefaultPreferenceKey {
241+
public let defaultValue = true
242+
public let key = "HideCommonPrecedingSpacesInSuggestion"
243+
}
244+
245+
var hideCommonPrecedingSpacesInSuggestion: HideCommonPrecedingSpacesInSuggestion {
246+
.init()
247+
}
248+
249+
struct AcceptSuggestionWithAccessibilityAPI: UserDefaultPreferenceKey {
250+
public let defaultValue = false
251+
public let key = "AcceptSuggestionWithAccessibilityAPI"
252+
}
253+
254+
var acceptSuggestionWithAccessibilityAPI: AcceptSuggestionWithAccessibilityAPI {
255+
.init()
256+
}
257+
258+
struct SuggestionPresentationMode: UserDefaultPreferenceKey {
259+
public let defaultValue = PresentationMode.floatingWidget
260+
public let key = "SuggestionPresentationMode"
261+
}
262+
263+
var suggestionPresentationMode: SuggestionPresentationMode { .init() }
264+
265+
struct RealtimeSuggestionDebounce: UserDefaultPreferenceKey {
266+
public let defaultValue: Double = 1
267+
public let key = "RealtimeSuggestionDebounce"
268+
}
269+
270+
var realtimeSuggestionDebounce: RealtimeSuggestionDebounce { .init() }
271+
}
272+
273+
// MARK: - Chat
274+
275+
public extension UserDefaultPreferenceKeys {
303276
struct ChatFontSize: UserDefaultPreferenceKey {
304277
public let defaultValue = 12 as Double
305278
public let key = "ChatFontSize"
@@ -313,6 +286,13 @@ public extension UserDefaultPreferenceKeys {
313286
}
314287

315288
var chatCodeFontSize: ChatCodeFontSize { .init() }
289+
290+
struct UseGlobalChat: UserDefaultPreferenceKey {
291+
public let defaultValue = true
292+
public let key = "UseGlobalChat"
293+
}
294+
295+
var useGlobalChat: UseGlobalChat { .init() }
316296
}
317297

318298
// MARK: - Custom Commands

0 commit comments

Comments
 (0)