feat(config): add Neovim and Renode typed inputs

This commit is contained in:
MDietermann
2026-04-14 10:01:40 +02:00
parent e830e4dfda
commit e2637bc093
3 changed files with 66 additions and 0 deletions

View File

@@ -45,6 +45,22 @@ type ShellConfigSection struct {
Blocks []ShellConfigBlock `yaml:"blocks"` Blocks []ShellConfigBlock `yaml:"blocks"`
} }
type NeovimConfig struct {
NvChadStarterRepo string `yaml:"nvchad_starter_repo"`
}
type RenodePlatform struct {
Name string `yaml:"name"`
ReplPath string `yaml:"repl_path"`
Machine string `yaml:"machine"`
}
type RenodeConfig struct {
WokwiVersion string `yaml:"wokwi_version"`
WokwiURL string `yaml:"wokwi_url"`
Platforms []RenodePlatform `yaml:"platforms"`
}
// Config is the fully-resolved runtime configuration. // Config is the fully-resolved runtime configuration.
type Config struct { type Config struct {
Version int `yaml:"version"` Version int `yaml:"version"`
@@ -58,6 +74,8 @@ type Config struct {
Zellij ZellijConfig `yaml:"zellij"` Zellij ZellijConfig `yaml:"zellij"`
Themes ThemesConfig `yaml:"themes"` Themes ThemesConfig `yaml:"themes"`
ShellConfig ShellConfigSection `yaml:"shell_config"` ShellConfig ShellConfigSection `yaml:"shell_config"`
Neovim NeovimConfig `yaml:"neovim"`
Renode RenodeConfig `yaml:"renode"`
} }
const currentVersion = 1 const currentVersion = 1
@@ -137,5 +155,11 @@ func merge(base, over Config) Config {
if len(over.ShellConfig.Blocks) > 0 { if len(over.ShellConfig.Blocks) > 0 {
out.ShellConfig = over.ShellConfig out.ShellConfig = over.ShellConfig
} }
if over.Neovim.NvChadStarterRepo != "" {
out.Neovim = over.Neovim
}
if over.Renode.WokwiVersion != "" || len(over.Renode.Platforms) > 0 {
out.Renode = over.Renode
}
return out return out
} }

View File

@@ -73,6 +73,31 @@ func TestDefaultsCarryModuleInputs(t *testing.T) {
} }
} }
func TestDefaultsCarryPlan3bInputs(t *testing.T) {
cfg, err := Load("/nonexistent/overlay.yaml")
if err != nil {
t.Fatal(err)
}
if cfg.Neovim.NvChadStarterRepo == "" {
t.Error("Neovim.NvChadStarterRepo empty")
}
if cfg.Renode.WokwiVersion == "" {
t.Error("Renode.WokwiVersion empty")
}
if cfg.Renode.WokwiURL == "" {
t.Error("Renode.WokwiURL empty")
}
if len(cfg.Renode.Platforms) == 0 {
t.Error("Renode.Platforms empty")
}
want := map[string]string{"stm32f4": "STM32F4_Discovery", "rp2040": "RP2040", "nrf52840": "nRF52840"}
for _, p := range cfg.Renode.Platforms {
if want[p.Name] != p.Machine {
t.Errorf("platform %q: machine=%q want %q", p.Name, p.Machine, want[p.Name])
}
}
}
func TestLoadRejectsUnknownVersion(t *testing.T) { func TestLoadRejectsUnknownVersion(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
path := filepath.Join(dir, "overlay.yaml") path := filepath.Join(dir, "overlay.yaml")

View File

@@ -80,3 +80,20 @@ shell_config:
alias v="nvim" alias v="nvim"
alias y="yazi" alias y="yazi"
alias theme="archduino-theme" alias theme="archduino-theme"
neovim:
nvchad_starter_repo: "https://github.com/NvChad/starter"
renode:
wokwi_version: "0.28.1"
wokwi_url: "https://github.com/wokwi/wokwi-cli/releases/download/v0.28.1/wokwi-cli-linuxstatic-x64"
platforms:
- name: stm32f4
repl_path: "platforms/boards/stm32f4_discovery.repl"
machine: "STM32F4_Discovery"
- name: rp2040
repl_path: "platforms/cpus/rp2040.repl"
machine: "RP2040"
- name: nrf52840
repl_path: "platforms/cpus/nrf52840.repl"
machine: "nRF52840"