diff --git a/config/colors.go b/config/colors.go index 2bc92b3..86a9061 100644 --- a/config/colors.go +++ b/config/colors.go @@ -147,7 +147,7 @@ type Palette struct { DeepPurple Color // #865ad6 — fallback for burndown gradient // Content area - ContentBackgroundColor Color // canvas background (dark: black, light: transparent/default) + ContentBackgroundColor Color // canvas background (transparent/default — inherits terminal bg) // Statusline (Nord palette) NordPolarNight1 Color // #2e3440 @@ -187,7 +187,7 @@ func DarkPalette() Palette { DeepSkyBlue: NewColorRGB(0, 191, 255), DeepPurple: NewColorRGB(134, 90, 214), - ContentBackgroundColor: NewColor(tcell.ColorBlack), + ContentBackgroundColor: DefaultColor(), // transparent — inherit terminal background NordPolarNight1: NewColorHex("#2e3440"), NordPolarNight2: NewColorHex("#3b4252"), diff --git a/config/loader.go b/config/loader.go index e5b15fb..a6e9631 100644 --- a/config/loader.go +++ b/config/loader.go @@ -155,7 +155,7 @@ func setDefaults() { // Appearance defaults viper.SetDefault("appearance.theme", "auto") viper.SetDefault("appearance.gradientThreshold", 256) - viper.SetDefault("appearance.codeBlock.theme", "nord") + // code block theme resolved dynamically in GetCodeBlockTheme() } // bindFlags binds supported command line flags to viper so they can override config values. @@ -389,9 +389,16 @@ func GetGradientThreshold() int { return threshold } -// GetCodeBlockTheme returns the chroma syntax highlighting theme for code blocks +// GetCodeBlockTheme returns the chroma syntax highlighting theme for code blocks. +// defaults to "nord" (dark) or "github" (light) when not explicitly configured. func GetCodeBlockTheme() string { - return viper.GetString("appearance.codeBlock.theme") + if t := viper.GetString("appearance.codeBlock.theme"); t != "" { + return t + } + if GetEffectiveTheme() == "light" { + return "github" + } + return "nord" } // GetCodeBlockBackground returns the background color for code blocks diff --git a/config/loader_test.go b/config/loader_test.go index 3743729..383bdc5 100644 --- a/config/loader_test.go +++ b/config/loader_test.go @@ -182,9 +182,13 @@ func TestLoadConfigCodeBlockDefaults(t *testing.T) { t.Fatalf("LoadConfig failed: %v", err) } - // codeBlock.theme defaults to "nord"; background and border have no defaults - if cfg.Appearance.CodeBlock.Theme != "nord" { - t.Errorf("expected default codeBlock.theme 'nord', got '%s'", cfg.Appearance.CodeBlock.Theme) + // codeBlock.theme is empty in config (resolved dynamically by GetCodeBlockTheme) + if cfg.Appearance.CodeBlock.Theme != "" { + t.Errorf("expected empty default codeBlock.theme, got '%s'", cfg.Appearance.CodeBlock.Theme) + } + // GetCodeBlockTheme resolves to "nord" for dark (default) theme + if got := GetCodeBlockTheme(); got != "nord" { + t.Errorf("expected GetCodeBlockTheme() 'nord' for dark theme, got '%s'", got) } if cfg.Appearance.CodeBlock.Background != "" { t.Errorf("expected empty default codeBlock.background, got '%s'", cfg.Appearance.CodeBlock.Background) diff --git a/go.mod b/go.mod index 0c4c37a..8f49da8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.25.0 require ( github.com/alecthomas/participle/v2 v2.1.4 - github.com/boolean-maybe/navidown v0.4.16 + github.com/boolean-maybe/navidown v0.4.17 github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 github.com/charmbracelet/bubbletea v1.3.10 github.com/charmbracelet/huh v0.8.0 diff --git a/go.sum b/go.sum index 2bb976d..5317467 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3v github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/boolean-maybe/navidown v0.4.16 h1:KfanPIG6vm26+Y7rjT5ztrERkZa6FDiSZ6Z0e0wfZeI= -github.com/boolean-maybe/navidown v0.4.16/go.mod h1:uF4Z/5uTnEtC6ZWyfKRv5Qw8Nir1nfp4kUraggTRfrk= +github.com/boolean-maybe/navidown v0.4.17 h1:5xlXhgd6/nzjrmQAi0puSuD6p+rbDFJlcJbKhEnU/Nc= +github.com/boolean-maybe/navidown v0.4.17/go.mod h1:uF4Z/5uTnEtC6ZWyfKRv5Qw8Nir1nfp4kUraggTRfrk= github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY= github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws= diff --git a/internal/bootstrap/init.go b/internal/bootstrap/init.go index c9ac552..347e28e 100644 --- a/internal/bootstrap/init.go +++ b/internal/bootstrap/init.go @@ -297,9 +297,14 @@ func InitColorAndGradientSupport(cfg *config.Config) *sysinfo.SystemInfo { "wideGradients", config.UseWideGradients) } - // set tview global background so all primitives inherit the theme background + // set tview global styles so all primitives inherit the theme colors. + // PrimaryTextColor must be set for light theme — tview defaults to white, + // which is invisible on light backgrounds. colors := config.GetColors() tview.Styles.PrimitiveBackgroundColor = colors.ContentBackgroundColor.TCell() + if config.GetEffectiveTheme() == "light" { + tview.Styles.PrimaryTextColor = colors.ContentTextColor.TCell() + } return systemInfo }