v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-27 21:11:11 -07:00

fix: theme importing should before reading config file

This commit is contained in:
eeeXun 2023-05-12 18:44:18 +08:00
parent fd4dab9217
commit 5b2d955eb8

View File

@ -50,6 +50,19 @@ func configInit() {
config.AddConfigPath("$HOME/.config/gtt")
themeConfig.AddConfigPath("$HOME/.config/gtt")
// import theme if file exists
if err := themeConfig.ReadInConfig(); err == nil {
var (
palate = make(map[string]int32)
colors = []string{"bg", "fg", "gray", "red", "green", "yellow", "blue", "purple", "cyan", "orange"}
)
for name := range themeConfig.AllSettings() {
for _, color := range colors {
palate[color] = themeConfig.GetInt32(fmt.Sprintf("%s.%s", name, color))
}
style.NewTheme(name, palate)
}
}
// Create config file if it does not exist
// Otherwise check if config value is missing
if err := config.ReadInConfig(); err != nil {
@ -82,19 +95,6 @@ func configInit() {
config.WriteConfig()
}
}
// import theme if file exists
if err := themeConfig.ReadInConfig(); err == nil {
var (
palate = make(map[string]int32)
colors = []string{"bg", "fg", "gray", "red", "green", "yellow", "blue", "purple", "cyan", "orange"}
)
for name := range themeConfig.AllSettings() {
for _, color := range colors {
palate[color] = themeConfig.GetInt32(fmt.Sprintf("%s.%s", name, color))
}
style.NewTheme(name, palate)
}
}
// Setup
for _, name := range translate.AllTranslator {