]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/settings.go
Fix crash
[micro.git] / cmd / micro / settings.go
index 2e409f54957c55c667a3f23bb7845cbb35deb63c..a9b1d35851cd6ec89f75867cf0eddaf0560a26d0 100644 (file)
@@ -55,17 +55,34 @@ func WriteSettings(filename string) error {
        return err
 }
 
+// AddOption creates a new option. This is meant to be called by plugins to add options.
+func AddOption(name string, value interface{}) {
+       settings[name] = value
+       err := WriteSettings(configDir + "/settings.json")
+       if err != nil {
+               TermMessage("Error writing settings.json file: " + err.Error())
+       }
+}
+
+// GetOption returns the specified option. This is meant to be called by plugins to add options.
+func GetOption(name string) interface{} {
+       return settings[name]
+}
+
 // DefaultSettings returns the default settings for micro
 func DefaultSettings() map[string]interface{} {
        return map[string]interface{}{
                "colorscheme":  "default",
                "tabsize":      float64(4),
+               "indentchar":   " ",
+               "ignorecase":   false,
                "autoindent":   true,
                "syntax":       true,
-               "tabsToSpaces": false,
+               "tabstospaces": false,
                "ruler":        true,
-               "gofmt":        false,
-               "goimports":    false,
+               "statusline":   true,
+               "scrollmargin": float64(3),
+               "scrollspeed":  float64(2),
        }
 }
 
@@ -105,6 +122,10 @@ func SetOption(view *View, args []string) {
                        view.Buf.UpdateRules()
                }
 
+               if option == "statusline" {
+                       view.Resize(screen.Size())
+               }
+
                err := WriteSettings(filename)
                if err != nil {
                        messenger.Error("Error writing to settings.json: " + err.Error())