@@ -62,11 +62,23 @@ func defaultStyles() map[string]lipgloss.Style {
62
62
}
63
63
64
64
func loadStyleConfig () (map [string ]lipgloss.Style , DisplayOptions , DisplayEmojis ) {
65
+ homeDir , err := os .UserHomeDir ()
66
+ if err != nil {
67
+ fmt .Fprintf (os .Stderr , "Error getting user home directory: %v\n " , err )
68
+ // Fallback: just try current dir config only
69
+ paths := []string {"./.pwtree.json" }
70
+ return determineStyleConfig (paths )
71
+ }
72
+
65
73
paths := []string {
66
74
"./.pwtree.json" ,
67
- filepath .Join (os . Getenv ( "HOME" ) , ".config" , "pwtree" , "config.json" ),
75
+ filepath .Join (homeDir , ".config" , "pwtree" , "config.json" ),
68
76
}
69
77
78
+ return determineStyleConfig (paths )
79
+ }
80
+
81
+ func determineStyleConfig (paths []string ) (map [string ]lipgloss.Style , DisplayOptions , DisplayEmojis ) {
70
82
var configData []byte
71
83
for _ , path := range paths {
72
84
if data , err := os .ReadFile (path ); err == nil {
@@ -120,9 +132,9 @@ func loadStyleConfig() (map[string]lipgloss.Style, DisplayOptions, DisplayEmojis
120
132
}
121
133
122
134
emojis := DisplayEmojis {
123
- Root : defaultEmojis . Root ,
124
- File : defaultEmojis . File ,
125
- Suite : defaultEmojis . Suite ,
135
+ Root : "" ,
136
+ File : "" ,
137
+ Suite : "" ,
126
138
}
127
139
128
140
if cfg .EmojiOverrides .Root != nil {
@@ -135,9 +147,11 @@ func loadStyleConfig() (map[string]lipgloss.Style, DisplayOptions, DisplayEmojis
135
147
emojis .Suite = * cfg .EmojiOverrides .Suite
136
148
}
137
149
138
- return styles , DisplayOptions {
150
+ display := DisplayOptions {
139
151
ShowProjects : cfg .ShowProjects == nil || * cfg .ShowProjects ,
140
152
ShowTags : cfg .ShowTags == nil || * cfg .ShowTags ,
141
153
ShowFileLines : cfg .ShowFileLines == nil || * cfg .ShowFileLines ,
142
- }, emojis
154
+ }
155
+
156
+ return styles , display , emojis
143
157
}
0 commit comments