Files
gemini-cli/packages/cli/src/ui/editors/editorSettingsManager.ts

72 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-06-12 02:21:54 +01:00
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {
allowEditorTypeInSandbox,
checkHasEditorType,
type EditorType,
} from '@google/gemini-cli-core';
2025-06-12 02:21:54 +01:00
export interface EditorDisplay {
name: string;
type: EditorType | 'not_set';
disabled: boolean;
}
export const EDITOR_DISPLAY_NAMES: Record<EditorType, string> = {
2025-06-23 23:32:09 -07:00
zed: 'Zed',
2025-06-12 02:21:54 +01:00
vscode: 'VS Code',
vscodium: 'VSCodium',
2025-06-12 02:21:54 +01:00
windsurf: 'Windsurf',
cursor: 'Cursor',
vim: 'Vim',
neovim: 'Neovim',
2025-06-12 02:21:54 +01:00
};
class EditorSettingsManager {
private readonly availableEditors: EditorDisplay[];
constructor() {
2025-06-23 23:32:09 -07:00
const editorTypes: EditorType[] = [
'zed',
'vscode',
'vscodium',
2025-06-23 23:32:09 -07:00
'windsurf',
'cursor',
'vim',
'neovim',
2025-06-23 23:32:09 -07:00
];
2025-06-12 02:21:54 +01:00
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();