mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-28 22:08:12 +09:00
Auto prefix for plugin functions
YOu no longer have to prefix all functions in a plugin with the plugin name (linter_onSave). This will now be done automatically using lua's setfenv. When passing a function as a callback to a editor function, make sure to prefix the plugin name (linter.onExit, or go.goimports) so that micro knows which plugin to call the function from.
This commit is contained in:
@@ -312,7 +312,7 @@ func (v *View) HandleEvent(event tcell.Event) {
|
||||
relocate = action(v) || relocate
|
||||
for _, pl := range loadedPlugins {
|
||||
funcName := strings.Split(runtime.FuncForPC(reflect.ValueOf(action).Pointer()).Name(), ".")
|
||||
err := Call(pl+"_on"+funcName[len(funcName)-1], nil)
|
||||
err := Call(pl+".on"+funcName[len(funcName)-1], nil)
|
||||
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
|
||||
TermMessage(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user