fix(theming): restore gruvbox as default via Default() helper

This commit is contained in:
MDietermann
2026-04-14 13:42:58 +02:00
parent 4f7411ca95
commit 698271a235
6 changed files with 28 additions and 14 deletions

View File

@@ -85,13 +85,10 @@ func nvimCfg() (string, error) {
} }
func (m Module) resolvedTheme() string { func (m Module) resolvedTheme() string {
if t, ok := theming.Get(m.themeID); ok && t.NvChadTheme != "" { if t, ok := theming.Get(m.themeID); ok {
return t.NvChadTheme return t.NvChadTheme
} }
if list := theming.List(); len(list) > 0 && list[0].NvChadTheme != "" { return theming.Default().NvChadTheme
return list[0].NvChadTheme
}
return "gruvbox"
} }
// WriteChadrc renders chadrc.lua for the given NvChad theme name and writes // WriteChadrc renders chadrc.lua for the given NvChad theme name and writes

View File

@@ -160,7 +160,7 @@ func TestPlanAfterApplyIsEmpty(t *testing.T) {
} }
} }
func TestUnknownThemeFallsBackToFirst(t *testing.T) { func TestUnknownThemeFallsBackToDefault(t *testing.T) {
home := t.TempDir() home := t.TempDir()
t.Setenv("HOME", home) t.Setenv("HOME", home)
r := &fakeRunner{installed: map[string]bool{"neovim": true}} r := &fakeRunner{installed: map[string]bool{"neovim": true}}
@@ -171,9 +171,8 @@ func TestUnknownThemeFallsBackToFirst(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
chadrc, _ := os.ReadFile(filepath.Join(home, ".config", "nvim", "lua", "chadrc.lua")) chadrc, _ := os.ReadFile(filepath.Join(home, ".config", "nvim", "lua", "chadrc.lua"))
// Unknown theme IDs fall back to the first entry of theming.List(), // Unknown theme IDs fall back to theming.Default(), which is gruvbox.
// which is sorted alphabetically by ID (currently "catppuccin"). if !strings.Contains(string(chadrc), `theme = "gruvbox"`) {
if !strings.Contains(string(chadrc), `theme = "catppuccin"`) {
t.Fatalf("fallback theme not applied: %s", chadrc) t.Fatalf("fallback theme not applied: %s", chadrc)
} }
} }

View File

@@ -97,6 +97,21 @@ func List() []Theme {
return out return out
} }
// Default returns the archduino default theme. Used by the wizard's fresh-
// install default and by callers that resolve an unknown theme ID.
// The identity here is stable policy: gruvbox is the project's long-standing
// default (carried over from the pre-Go installer). Changing this changes
// the out-of-box experience on fresh systems.
func Default() Theme {
if t, ok := Get("gruvbox"); ok {
return t
}
if len(discovered) > 0 {
return discovered[0]
}
return Theme{ID: "gruvbox", DisplayName: "Gruvbox Dark", NvChadTheme: "gruvbox"}
}
// Get returns the theme with the given ID, if present. // Get returns the theme with the given ID, if present.
func Get(id string) (Theme, bool) { func Get(id string) (Theme, bool) {
for _, t := range discovered { for _, t := range discovered {

View File

@@ -192,3 +192,9 @@ func TestApplyEachThemeWritesStarship(t *testing.T) {
}) })
} }
} }
func TestDefaultIsGruvbox(t *testing.T) {
if got := Default(); got.ID != "gruvbox" {
t.Fatalf("Default().ID = %q, want gruvbox", got.ID)
}
}

View File

@@ -54,10 +54,7 @@ func NewWizardState(cfg config.Config, reg *module.Registry) WizardState {
} }
sort.Slice(choices, func(i, j int) bool { return choices[i].ID < choices[j].ID }) sort.Slice(choices, func(i, j int) bool { return choices[i].ID < choices[j].ID })
var theme string theme := theming.Default().ID
if list := theming.List(); len(list) > 0 {
theme = list[0].ID
}
if override, ok := cfg.ThemeOverrides["__active"]; ok && override != "" { if override, ok := cfg.ThemeOverrides["__active"]; ok && override != "" {
theme = override theme = override
} }

View File

@@ -35,7 +35,7 @@ func TestNewWizardStatePreTicksAllByDefault(t *testing.T) {
t.Errorf("%s not selected", m.ID) t.Errorf("%s not selected", m.ID)
} }
} }
if s.ThemeID != theming.List()[0].ID { if s.ThemeID != theming.Default().ID {
t.Errorf("theme = %q", s.ThemeID) t.Errorf("theme = %q", s.ThemeID)
} }
} }