diff --git a/src/components/config_function.go b/src/components/config_function.go index de2097f6..7f6be636 100644 --- a/src/components/config_function.go +++ b/src/components/config_function.go @@ -6,9 +6,7 @@ import ( "path/filepath" "github.com/barasher/go-exiftool" - "github.com/pelletier/go-toml/v2" - "github.com/spf13/viper" -) + "github.com/pelletier/go-toml/v2") func initialConfig(dir string) (toggleDotFileBool bool, firstFilePanelDir string) { var err error @@ -22,15 +20,8 @@ func initialConfig(dir string) (toggleDotFileBool bool, firstFilePanelDir string loadHotkeysFile() - data, err := os.ReadFile(SuperFileMainDir + themeFolder + "/" + Config.Theme + ".toml") - if err != nil { - log.Fatalf("Theme file doesn't exist: %v", err) - } + loadThemeFile() - err = toml.Unmarshal(data, &theme) - if err != nil { - log.Fatalf("Error while decoding theme json( Your theme file may have errors ): %v", err) - } toggleDotFileData, err := os.ReadFile(SuperFileDataDir + toggleDotFile) if err != nil { outPutLog("Error while reading toggleDotFile data error:", err) @@ -60,33 +51,35 @@ func initialConfig(dir string) (toggleDotFileBool bool, firstFilePanelDir string } func loadConfigFile() { - viperConfig := viper.New() - viperConfig.SetConfigName("config") - viperConfig.SetConfigType("toml") - viperConfig.SetConfigFile(SuperFileMainDir + configFile) - err := viperConfig.ReadInConfig() + data, err := os.ReadFile(SuperFileMainDir + configFile) if err != nil { log.Fatalf("Config file doesn't exist: %v", err) } - err = viperConfig.Unmarshal(&Config) + err = toml.Unmarshal(data, &Config) if err != nil { - log.Fatalf("Error decoding config file( your config file may have misconfigured ): %v", err) + log.Fatalf("Error decoding config file ( your config file may have misconfigured ): %v", err) } } func loadHotkeysFile() { - - viperHotkeys := viper.New() - viperHotkeys.SetConfigName("hotkeys") - viperHotkeys.SetConfigType("toml") - viperHotkeys.SetConfigFile(SuperFileMainDir + hotkeysFile) - - err := viperHotkeys.ReadInConfig() + data, err := os.ReadFile(SuperFileMainDir + hotkeysFile) if err != nil { log.Fatalf("Config file doesn't exist: %v", err) } - err = viperHotkeys.Unmarshal(&hotkeys) + err = toml.Unmarshal(data, &hotkeys) + if err != nil { + log.Fatalf("Error decoding config file ( your config file may have misconfigured ): %v", err) + } +} + +func loadThemeFile() { + data, err := os.ReadFile(SuperFileMainDir + themeFolder + "/" + Config.Theme + ".toml") + if err != nil { + log.Fatalf("Theme file doesn't exist: %v", err) + } + + err = toml.Unmarshal(data, &theme) if err != nil { - log.Fatalf("Error decoding hotkeys file( your config file may have misconfigured ): %v", err) + log.Fatalf("Error while decoding theme file( Your theme file may have errors ): %v", err) } } diff --git a/src/components/config_type.go b/src/components/config_type.go index d86d3f9e..0628b8c9 100644 --- a/src/components/config_type.go +++ b/src/components/config_type.go @@ -131,7 +131,7 @@ type HotkeysType struct { CompressFile []string `mapstructure:"compress_file"` ToggleDotFile []string `mapstructure:"toggle_dot_file"` - OpenFileWithEditor []string `mapstructure:"oepn_file_with_editor` + OpenFileWithEditor []string `mapstructure:"oepn_file_with_editor"` OpenCurrentDirectoryWithEditor []string `mapstructure:"open_current_directory_with_editor"` Cancel []string `mapstructure:"cancel"` diff --git a/src/components/key_function.go b/src/components/key_function.go index e90a40c9..e10638d8 100644 --- a/src/components/key_function.go +++ b/src/components/key_function.go @@ -84,7 +84,7 @@ func mainKey(msg string, m model, cmd tea.Cmd) (model, tea.Cmd) { }() case hotkeys.OpenFileWithEditor[0], hotkeys.OpenFileWithEditor[1]: cmd = openFileWithEditor(m) - case hotkeys.OpenCurrentDirectoryWithEditor[0], hotkeys.OpenFileWithEditor[1]: + case hotkeys.OpenCurrentDirectoryWithEditor[0], hotkeys.OpenCurrentDirectoryWithEditor[1]: cmd = openDirectoryWithEditor(m) default: m = normalAndBrowserModeKey(msg, m)