mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-28 22:08:12 +09:00
Have go plugin create its own options
This commit is contained in:
@@ -195,7 +195,6 @@ func main() {
|
||||
LoadSyntaxFiles()
|
||||
// Load the help files
|
||||
LoadHelp()
|
||||
LoadPlugins()
|
||||
|
||||
buf := NewBuffer(string(input), filename)
|
||||
|
||||
@@ -219,6 +218,10 @@ func main() {
|
||||
L.SetGlobal("view", luar.New(L, view))
|
||||
L.SetGlobal("settings", luar.New(L, &settings))
|
||||
L.SetGlobal("messenger", luar.New(L, messenger))
|
||||
L.SetGlobal("GetOption", luar.New(L, GetOption))
|
||||
L.SetGlobal("AddOption", luar.New(L, AddOption))
|
||||
|
||||
LoadPlugins()
|
||||
|
||||
for {
|
||||
// Display everything
|
||||
|
||||
@@ -55,6 +55,20 @@ 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{}{
|
||||
@@ -64,8 +78,6 @@ func DefaultSettings() map[string]interface{} {
|
||||
"syntax": true,
|
||||
"tabsToSpaces": false,
|
||||
"ruler": true,
|
||||
"gofmt": false,
|
||||
"goimports": false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user