refactor: retire tui.BuiltinThemes in favor of theming.List
Make internal/theming.List the single source of truth for themes:
- Drop tui.BuiltinThemes, tui.ThemeByID, and the NvChadTheme field on
tui.Theme. tui.Theme is now a thin {ID, Name} display value.
- Wizard populates its dropdown from theming.List() and uses
DisplayName for the label.
- neovim.resolvedTheme uses theming.Get (with theming.List()[0] as a
fallback) instead of a caller-supplied []tui.Theme slice.
- neovim.New signature loses the themes []tui.Theme parameter; update
cmd/archduino/main.go and all neovim tests to match.
Break the resulting neovim→theming import cycle (theming previously
imported neovim for WriteChadrc) by inverting the dependency:
theming exposes a ChadrcWriter function hook, and neovim registers
its WriteChadrc into it via package init. The theming test stubs
ChadrcWriter directly to exercise the chadrc-rewrite branch without
pulling neovim in and re-creating the cycle.
Delete the now-obsolete TestBuiltinThemesCarryNvChadName / TestThemeByID*
tests in internal/tui/state_test.go — their coverage lives in the
theming package's own tests.
This commit is contained in:
@@ -17,12 +17,19 @@ import (
|
||||
"github.com/MDietermann/ArduinoArchSetup/internal/config"
|
||||
"github.com/MDietermann/ArduinoArchSetup/internal/module"
|
||||
"github.com/MDietermann/ArduinoArchSetup/internal/platform"
|
||||
"github.com/MDietermann/ArduinoArchSetup/internal/tui"
|
||||
"github.com/MDietermann/ArduinoArchSetup/internal/theming"
|
||||
)
|
||||
|
||||
//go:embed assets/*
|
||||
var assets embed.FS
|
||||
|
||||
// Register WriteChadrc with the theming package so theming.Apply can
|
||||
// rewrite chadrc.lua on theme changes without importing this package
|
||||
// (which would be a cycle: neovim imports theming).
|
||||
func init() {
|
||||
theming.ChadrcWriter = WriteChadrc
|
||||
}
|
||||
|
||||
// assetMap lists each asset and its destination under ~/.config/nvim.
|
||||
// Order matters: Detect iterates in this order and Apply writes in this order.
|
||||
var assetMap = []struct {
|
||||
@@ -40,14 +47,13 @@ var assetMap = []struct {
|
||||
type Module struct {
|
||||
cfg config.NeovimConfig
|
||||
themeID string
|
||||
themes []tui.Theme
|
||||
pm platform.PackageManager
|
||||
git platform.GitClient
|
||||
}
|
||||
|
||||
// New constructs a Neovim Module.
|
||||
func New(cfg config.NeovimConfig, themeID string, themes []tui.Theme, pm platform.PackageManager, git platform.GitClient) Module {
|
||||
return Module{cfg: cfg, themeID: themeID, themes: themes, pm: pm, git: git}
|
||||
func New(cfg config.NeovimConfig, themeID string, pm platform.PackageManager, git platform.GitClient) Module {
|
||||
return Module{cfg: cfg, themeID: themeID, pm: pm, git: git}
|
||||
}
|
||||
|
||||
type state struct {
|
||||
@@ -79,11 +85,11 @@ func nvimCfg() (string, error) {
|
||||
}
|
||||
|
||||
func (m Module) resolvedTheme() string {
|
||||
if t, ok := tui.ThemeByID(m.themes, m.themeID); ok && t.NvChadTheme != "" {
|
||||
if t, ok := theming.Get(m.themeID); ok && t.NvChadTheme != "" {
|
||||
return t.NvChadTheme
|
||||
}
|
||||
if len(m.themes) > 0 {
|
||||
return m.themes[0].NvChadTheme
|
||||
if list := theming.List(); len(list) > 0 && list[0].NvChadTheme != "" {
|
||||
return list[0].NvChadTheme
|
||||
}
|
||||
return "gruvbox"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user