From 698271a2355d4a57f1bca465b1d00ced1cf916a7 Mon Sep 17 00:00:00 2001 From: MDietermann Date: Tue, 14 Apr 2026 13:42:58 +0200 Subject: [PATCH] fix(theming): restore gruvbox as default via Default() helper --- internal/modules/neovim/neovim.go | 7 ++----- internal/modules/neovim/neovim_test.go | 7 +++---- internal/theming/theming.go | 15 +++++++++++++++ internal/theming/theming_test.go | 6 ++++++ internal/tui/state.go | 5 +---- internal/tui/state_test.go | 2 +- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/internal/modules/neovim/neovim.go b/internal/modules/neovim/neovim.go index 2a3f5a1..fc1dbd4 100644 --- a/internal/modules/neovim/neovim.go +++ b/internal/modules/neovim/neovim.go @@ -85,13 +85,10 @@ func nvimCfg() (string, error) { } 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 } - if list := theming.List(); len(list) > 0 && list[0].NvChadTheme != "" { - return list[0].NvChadTheme - } - return "gruvbox" + return theming.Default().NvChadTheme } // WriteChadrc renders chadrc.lua for the given NvChad theme name and writes diff --git a/internal/modules/neovim/neovim_test.go b/internal/modules/neovim/neovim_test.go index bd43a96..7c91180 100644 --- a/internal/modules/neovim/neovim_test.go +++ b/internal/modules/neovim/neovim_test.go @@ -160,7 +160,7 @@ func TestPlanAfterApplyIsEmpty(t *testing.T) { } } -func TestUnknownThemeFallsBackToFirst(t *testing.T) { +func TestUnknownThemeFallsBackToDefault(t *testing.T) { home := t.TempDir() t.Setenv("HOME", home) r := &fakeRunner{installed: map[string]bool{"neovim": true}} @@ -171,9 +171,8 @@ func TestUnknownThemeFallsBackToFirst(t *testing.T) { t.Fatal(err) } chadrc, _ := os.ReadFile(filepath.Join(home, ".config", "nvim", "lua", "chadrc.lua")) - // Unknown theme IDs fall back to the first entry of theming.List(), - // which is sorted alphabetically by ID (currently "catppuccin"). - if !strings.Contains(string(chadrc), `theme = "catppuccin"`) { + // Unknown theme IDs fall back to theming.Default(), which is gruvbox. + if !strings.Contains(string(chadrc), `theme = "gruvbox"`) { t.Fatalf("fallback theme not applied: %s", chadrc) } } diff --git a/internal/theming/theming.go b/internal/theming/theming.go index 904a2c1..3cb961b 100644 --- a/internal/theming/theming.go +++ b/internal/theming/theming.go @@ -97,6 +97,21 @@ func List() []Theme { 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. func Get(id string) (Theme, bool) { for _, t := range discovered { diff --git a/internal/theming/theming_test.go b/internal/theming/theming_test.go index 57785a4..ee04c62 100644 --- a/internal/theming/theming_test.go +++ b/internal/theming/theming_test.go @@ -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) + } +} diff --git a/internal/tui/state.go b/internal/tui/state.go index a75380b..710ec84 100644 --- a/internal/tui/state.go +++ b/internal/tui/state.go @@ -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 }) - var theme string - if list := theming.List(); len(list) > 0 { - theme = list[0].ID - } + theme := theming.Default().ID if override, ok := cfg.ThemeOverrides["__active"]; ok && override != "" { theme = override } diff --git a/internal/tui/state_test.go b/internal/tui/state_test.go index c212492..a9307a2 100644 --- a/internal/tui/state_test.go +++ b/internal/tui/state_test.go @@ -35,7 +35,7 @@ func TestNewWizardStatePreTicksAllByDefault(t *testing.T) { 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) } }