From 1ef68e061213b6b170bd979d31d4805da2357272 Mon Sep 17 00:00:00 2001 From: Leo <45218470+ngleo@users.noreply.github.com> Date: Thu, 12 Jun 2025 02:21:54 +0100 Subject: feat: External editor settings (#882) --- .../cli/src/ui/editors/editorSettingsManager.ts | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 packages/cli/src/ui/editors/editorSettingsManager.ts (limited to 'packages/cli/src/ui/editors') 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 = { + 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(); -- cgit v1.2.3