diff options
| author | adamdottv <[email protected]> | 2025-04-29 08:20:41 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-04-30 07:46:35 -0500 |
| commit | 1e958b62ad0c71331e8a45f7d19ad736ffa52d1c (patch) | |
| tree | 02f083a60eb9efed9bfba2884fa3beff37c82c90 /internal/config | |
| parent | fdf5367f4f7e42e6d42379d2f3894eba545d1e62 (diff) | |
| download | opencode-1e958b62ad0c71331e8a45f7d19ad736ffa52d1c.tar.gz opencode-1e958b62ad0c71331e8a45f7d19ad736ffa52d1c.zip | |
feat: opencode theme (default)
Diffstat (limited to 'internal/config')
| -rw-r--r-- | internal/config/config.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index d7aa60719..8d6ad39d8 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -210,7 +210,7 @@ func configureViper() { func setDefaults(debug bool) { viper.SetDefault("data.directory", defaultDataDirectory) viper.SetDefault("contextPaths", defaultContextPaths) - viper.SetDefault("tui.theme", "catppuccin") + viper.SetDefault("tui.theme", "opencode") if debug { viper.SetDefault("debug", true) @@ -731,7 +731,7 @@ func UpdateTheme(themeName string) error { // Update the in-memory config cfg.TUI.Theme = themeName - + // Get the config file path configFile := viper.ConfigFileUsed() if configFile == "" { @@ -739,19 +739,19 @@ func UpdateTheme(themeName string) error { viper.Set("tui.theme", themeName) return viper.SafeWriteConfig() } - + // Read the existing config file configData, err := os.ReadFile(configFile) if err != nil { return fmt.Errorf("failed to read config file: %w", err) } - + // Parse the JSON var configMap map[string]interface{} if err := json.Unmarshal(configData, &configMap); err != nil { return fmt.Errorf("failed to parse config file: %w", err) } - + // Update just the theme value tuiConfig, ok := configMap["tui"].(map[string]interface{}) if !ok { @@ -762,16 +762,16 @@ func UpdateTheme(themeName string) error { tuiConfig["theme"] = themeName configMap["tui"] = tuiConfig } - + // Write the updated config back to file updatedData, err := json.MarshalIndent(configMap, "", " ") if err != nil { return fmt.Errorf("failed to marshal config: %w", err) } - + if err := os.WriteFile(configFile, updatedData, 0644); err != nil { return fmt.Errorf("failed to write config file: %w", err) } - + return nil } |
