Add tabsToSpaces option

This commit is contained in:
Zachary Yedidia
2016-04-18 13:01:39 -04:00
parent fa7808b4ae
commit c7f8584d84
4 changed files with 37 additions and 13 deletions

View File

@@ -12,14 +12,15 @@ import (
var settings Settings
// All the possible settings
var possibleSettings = []string{"colorscheme", "tabsize", "autoindent", "syntax"}
var possibleSettings = []string{"colorscheme", "tabsize", "autoindent", "syntax", "tabsToSpaces"}
// The Settings struct contains the settings for micro
type Settings struct {
Colorscheme string `json:"colorscheme"`
TabSize int `json:"tabsize"`
AutoIndent bool `json:"autoindent"`
Syntax bool `json:"syntax"`
Colorscheme string `json:"colorscheme"`
TabSize int `json:"tabsize"`
AutoIndent bool `json:"autoindent"`
Syntax bool `json:"syntax"`
TabsToSpaces bool `json:"tabsToSpaces"`
}
// InitSettings initializes the options map and sets all options to their default values
@@ -55,10 +56,11 @@ func WriteSettings(filename string) error {
// DefaultSettings returns the default settings for micro
func DefaultSettings() Settings {
return Settings{
Colorscheme: "default",
TabSize: 4,
AutoIndent: true,
Syntax: true,
Colorscheme: "default",
TabSize: 4,
AutoIndent: true,
Syntax: true,
TabsToSpaces: false,
}
}
@@ -92,6 +94,15 @@ func SetOption(view *View, args []string) {
}
LoadSyntaxFiles()
view.buf.UpdateRules()
} else if option == "tabsToSpaces" {
if value == "on" {
settings.TabsToSpaces = true
} else if value == "off" {
settings.TabsToSpaces = false
} else {
messenger.Error("Invalid value for " + option)
return
}
}
err := WriteSettings(filename)
if err != nil {