diff options
| author | Leo <[email protected]> | 2025-06-12 02:21:54 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-11 18:21:54 -0700 |
| commit | 1ef68e061213b6b170bd979d31d4805da2357272 (patch) | |
| tree | ddd91ec2a7841e763676e09765adf6f21880c2c3 /packages/cli/src/ui/editors/editorSettingsManager.ts | |
| parent | dd53e5c96aa01708a3bdb675c8a8e0d71be35651 (diff) | |
feat: External editor settings (#882)
Diffstat (limited to 'packages/cli/src/ui/editors/editorSettingsManager.ts')
| -rw-r--r-- | packages/cli/src/ui/editors/editorSettingsManager.ts | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/packages/cli/src/ui/editors/editorSettingsManager.ts b/packages/cli/src/ui/editors/editorSettingsManager.ts new file mode 100644 index 00000000..2c8210e1 --- /dev/null +++ b/packages/cli/src/ui/editors/editorSettingsManager.ts @@ -0,0 +1,60 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { + allowEditorTypeInSandbox, + checkHasEditorType, + type EditorType, +} from '@gemini-cli/core'; + +export interface EditorDisplay { + name: string; + type: EditorType | 'not_set'; + disabled: boolean; +} + +export const EDITOR_DISPLAY_NAMES: Record<EditorType, string> = { + vscode: 'VS Code', + windsurf: 'Windsurf', + cursor: 'Cursor', + vim: 'Vim', +}; + +class EditorSettingsManager { + private readonly availableEditors: EditorDisplay[]; + + constructor() { + const editorTypes: EditorType[] = ['vscode', 'windsurf', 'cursor', 'vim']; + this.availableEditors = [ + { + name: 'None', + type: 'not_set', + disabled: false, + }, + ...editorTypes.map((type) => { + const hasEditor = checkHasEditorType(type); + const isAllowedInSandbox = allowEditorTypeInSandbox(type); + + let labelSuffix = !isAllowedInSandbox + ? ' (Not available in sandbox)' + : ''; + labelSuffix = !hasEditor ? ' (Not installed)' : labelSuffix; + + return { + name: EDITOR_DISPLAY_NAMES[type] + labelSuffix, + type, + disabled: !hasEditor || !isAllowedInSandbox, + }; + }), + ]; + } + + getAvailableEditorDisplays(): EditorDisplay[] { + return this.availableEditors; + } +} + +export const editorSettingsManager = new EditorSettingsManager(); |
