Go plugin should disable tabstospaces if the file is go

This commit is contained in:
Zachary Yedidia
2016-08-19 18:47:37 -07:00
parent d409c3a031
commit f9cb99b35f
4 changed files with 28 additions and 13 deletions

View File

@@ -172,7 +172,7 @@ func Set(args []string) {
option := strings.TrimSpace(args[0])
value := strings.TrimSpace(args[1])
SetOption(option, value)
SetOptionAndSettings(option, value)
}
// Bind creates a new keybinding

View File

@@ -431,7 +431,7 @@ func runtimePluginsAutocloseAutocloseLua() (*asset, error) {
return a, nil
}
var _runtimePluginsGoGoLua = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xa4\x52\xcd\x8a\xd5\x30\x14\xde\xe7\x29\x0e\x01\x21\xd1\x5a\x66\x5d\xe8\x42\x07\x9c\x95\x8c\xa8\xb8\x11\x85\xd8\x9c\xdc\x06\xd3\xa4\x24\xa7\x8e\x22\xbe\xbb\xa4\xcd\xad\x6d\xef\x15\x51\xb3\x69\x9b\x7c\xe7\xfb\x6b\xac\x81\x3b\xa4\xfb\x91\x6c\xf0\x82\x9f\x82\x1d\xc6\x10\x29\x71\x09\x6d\x0b\xde\x3a\xa0\x1e\x3d\x03\x00\x78\xa6\xf5\x25\xac\x02\xa3\x5c\x42\xc9\xd0\x6b\x76\xe4\x32\x03\xfd\x89\x27\x43\x2a\xa0\x38\x15\x0a\xf6\x52\x7d\xc6\xdb\x30\x0c\xca\xeb\xbd\x0e\x3f\x85\x7a\xfb\x7d\x23\x8f\xd8\x85\x6b\xc1\x2d\xef\x37\x92\x31\x33\xf9\x2e\xab\x41\xf0\x6f\xd4\x17\x14\x72\x36\x61\x0d\xdc\x4e\xf1\x9d\xc5\x07\x21\xeb\xe7\x93\xa9\x5f\x58\x87\x6f\xbf\x8d\x98\xed\xf2\xbb\xc0\x7f\xf9\x2d\xf0\xdf\xb4\xb4\x83\xe5\xb5\x1e\x16\xa5\xbc\xd0\x25\xbc\x5e\xce\x95\x71\x33\xd0\x76\xd4\x6b\x76\x7e\xce\x05\xad\x79\xb6\xc8\x35\x4b\x33\x67\x2c\xff\x24\x9f\xb8\xd0\x29\x07\xbd\xf2\xda\x21\xb4\x60\x43\x3d\x86\x11\xcf\x0e\xe0\xe9\x03\x70\xa8\xeb\x43\x19\xaf\x14\xf5\xdb\xf1\x88\x69\x72\x04\x6d\xe1\x69\x22\x2a\x2d\xf8\x63\xc5\x17\x50\xd9\xed\x5c\x48\xb9\xdf\x83\xa3\xd7\x78\x9f\x05\xe5\x85\xfd\x7d\x4f\xff\x14\xa1\x50\xfc\x6d\x8c\x34\x3a\x4b\xe2\x22\x4c\x05\xbc\xf9\x9f\x48\x0b\x6d\xa2\x58\x41\xc2\xf1\xaa\xf2\xf7\x1f\xbb\xdd\x13\x7e\x85\x16\x04\x17\xef\x3f\x3e\x4a\x1f\x9e\x48\x2e\x1b\x13\xe2\xa0\x48\xac\x04\x26\x44\x40\xd5\xf5\x60\x3d\x24\x8a\xcd\x69\x50\xd4\xf5\x62\x9e\x95\xa0\xc3\x7a\x53\x48\x7d\x72\x58\x5b\x9f\x30\x92\x58\x04\xab\x79\x52\xb2\xed\x45\x8a\x48\x53\xf4\xc5\xd1\x1c\xe0\x67\x00\x00\x00\xff\xff\x4a\x0f\xaf\x0f\x03\x04\x00\x00")
var _runtimePluginsGoGoLua = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xa4\x52\xcd\x8a\xd5\x30\x14\x5e\xdb\xa7\x38\x04\x84\x44\x6b\x99\x75\xa1\x0b\x1d\x70\x56\x32\xe2\x88\x1b\x51\xc8\xb4\x27\xb7\xc1\x34\xa7\x24\xa7\x8e\x22\xbe\xbb\xa4\xcd\xad\xbd\xbd\x57\xfc\xcb\xa6\x6d\xf2\x9d\xef\xaf\xb1\x06\x6e\x90\x6f\x47\xb6\xe4\xa5\x38\x90\x1d\x46\x0a\x1c\x85\x82\xa6\x01\x6f\x1d\x70\x8f\xbe\x00\x00\x78\xde\x75\xe7\xb0\x12\x8c\x76\x11\x55\x81\xbe\x2b\xf6\x5c\x66\xe0\xdf\xf1\x24\x48\x09\x1c\xa6\x4c\x91\x38\xae\xa7\xf0\xce\xe2\x83\x54\xd5\x8b\xc9\x54\x2f\xad\xc3\xb7\x5f\x47\x4c\x3c\xe2\x86\xc4\x42\xf4\xe8\xee\xa7\x10\xeb\xfb\xc8\x14\x47\xdd\x62\x32\x24\xc8\x18\x91\xd9\x5e\xe9\x4f\x78\x4d\xc3\xa0\x7d\x77\xea\x5a\x1c\xa8\xda\x7e\x5f\xa9\x3d\x76\x71\xb6\xe0\x96\xf7\x2b\x55\x14\x66\xf2\x6d\x52\x05\xf2\x77\xfa\x33\x4a\x35\x47\xfa\x43\xd3\x90\xd7\xaf\x3b\x3f\x81\xa5\xb5\x1e\x66\xa5\xb4\xd0\x45\xbc\x5c\xf5\x85\x71\x33\xf0\x76\xd4\x77\xc5\xf1\x39\x17\xb4\xe6\xd9\x22\xd7\x2c\xf5\x9c\x31\xff\xe1\x74\xe2\xa8\xd5\x0e\x7a\xed\x3b\x87\xd0\x80\xa5\x6a\xa4\x11\x8f\x0e\xe0\xd9\x03\x08\xa8\xaa\x5d\x19\xaf\x35\xf7\xdb\xf1\x80\x71\x72\x0c\x4d\xe6\xa9\x03\xea\x4e\x8a\x27\x5a\x2c\xa0\xbc\xdb\x3a\x8a\xa9\xdf\x9d\xa3\x37\x78\x9b\x04\xd5\x99\xfd\xd3\x9e\xfe\x29\x42\xa6\xf8\xdb\x18\x71\x74\x96\xe5\x59\x98\x12\x44\xfd\x3f\x91\x16\xda\xc8\xa1\x84\x88\xe3\x45\xe5\x6f\xdf\x4f\x76\x0f\xf8\x05\x1a\x90\x42\xbe\xff\xf8\x38\x7e\x78\xaa\x84\xaa\x0d\x85\x41\xb3\x5c\x09\x0c\x05\x40\xdd\xf6\x60\x3d\x44\x0e\xf5\x61\xd0\xdc\xf6\x72\x9e\x55\xd0\xd1\x7a\x53\x58\xdf\x3b\xac\xac\x8f\x18\x58\x2e\x82\xe5\x3c\xa9\x8a\xed\x45\x0a\xc8\x53\xf0\xd9\xd1\x1c\xe0\x47\x00\x00\x00\xff\xff\x02\x21\xed\x7a\x51\x04\x00\x00")
func runtimePluginsGoGoLuaBytes() ([]byte, error) {
return bindataRead(
@@ -446,7 +446,7 @@ func runtimePluginsGoGoLua() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "runtime/plugins/go/go.lua", size: 1027, mode: os.FileMode(420), modTime: time.Unix(1471461104, 0)}
info := bindataFileInfo{name: "runtime/plugins/go/go.lua", size: 1105, mode: os.FileMode(420), modTime: time.Unix(1471657593, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}

View File

@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"errors"
"io/ioutil"
"os"
"reflect"
@@ -88,20 +89,17 @@ func DefaultSettings() map[string]interface{} {
}
}
// SetOption prompts the user to set an option and checks that the response is valid
func SetOption(option, value string) {
filename := configDir + "/settings.json"
// SetOption attempts to set the given option to the value
func SetOption(option, value string) error {
if _, ok := settings[option]; !ok {
messenger.Error(option + " is not a valid option")
return
return errors.New("Invalid option")
}
kind := reflect.TypeOf(settings[option]).Kind()
if kind == reflect.Bool {
b, err := ParseBool(value)
if err != nil {
messenger.Error("Invalid value for " + option)
return
return errors.New("Invalid value")
}
settings[option] = b
} else if kind == reflect.String {
@@ -109,8 +107,7 @@ func SetOption(option, value string) {
} else if kind == reflect.Float64 {
i, err := strconv.Atoi(value)
if err != nil {
messenger.Error("Invalid value for " + option)
return
return errors.New("Invalid value")
}
settings[option] = float64(i)
}
@@ -138,7 +135,21 @@ func SetOption(option, value string) {
}
}
err := WriteSettings(filename)
return nil
}
// SetOptionAndSettings sets the given option and saves the option setting to the settings config file
func SetOptionAndSettings(option, value string) {
filename := configDir + "/settings.json"
err := SetOption(option, value)
if err != nil {
messenger.Message(err.Error())
return
}
err = WriteSettings(filename)
if err != nil {
messenger.Error("Error writing to settings.json: " + err.Error())
return

View File

@@ -5,6 +5,10 @@ if GetOption("gofmt") == nil then
AddOption("gofmt", true)
end
if CurView().Buf.FileType == "Go" then
SetOption("tabstospaces", "off")
end
MakeCommand("goimports", "go.goimports", 0)
MakeCommand("gofmt", "go.gofmt", 0)