plugins: Add capability to dis-/enable them per buffer (#2836)

This commit is contained in:
Jöran Karl
2023-06-06 02:38:33 +02:00
committed by GitHub
parent 1b4f6ecb12
commit c46467b5b9
7 changed files with 50 additions and 16 deletions

View File

@@ -55,7 +55,26 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
buf.HighlightSearch = nativeValue.(bool)
}
}
}
} else {
for _, pl := range config.Plugins {
if option == pl.Name {
if nativeValue.(bool) {
if !pl.Loaded {
pl.Load()
}
_, err := pl.Call("init")
if err != nil && err != config.ErrNoSuchFunction {
screen.TermMessage(err)
}
} else if !nativeValue.(bool) && pl.Loaded {
_, err := pl.Call("deinit")
if err != nil && err != config.ErrNoSuchFunction {
screen.TermMessage(err)
}
}
}
}
}
if b.OptionCallback != nil {
b.OptionCallback(option, nativeValue)