diff --git a/internal/action/bindings.go b/internal/action/bindings.go index af187d43..9a5cb86f 100644 --- a/internal/action/bindings.go +++ b/internal/action/bindings.go @@ -262,7 +262,11 @@ func eventsEqual(e1 Event, e2 Event) bool { } // TryBindKeyPlug tries to bind a key for the plugin without writing to bindings.json. +// This operation can be rejected by lockbindings to prevent unexpected actions by the user. func TryBindKeyPlug(k, v string, overwrite bool) (bool, error) { + if l, ok := config.GlobalSettings["lockbindings"]; ok && l.(bool) { + return false, errors.New("bindings is locked by the user") + } return TryBindKey(k, v, overwrite, false) } diff --git a/internal/config/settings.go b/internal/config/settings.go index 52d45752..93b0ab21 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -118,6 +118,7 @@ var DefaultGlobalOnlySettings = map[string]any{ "helpsplit": "hsplit", "infobar": true, "keymenu": false, + "lockbindings": false, "mouse": true, "multiopen": "tab", "parsecursor": false, diff --git a/runtime/help/options.md b/runtime/help/options.md index 39090478..ef3fa46f 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -231,6 +231,12 @@ Here are the available options: default value: `false` +* `lockbindings`: prevent plugins and lua scripts from binding any keys. + Any custom actions must be binded manually either via commands like `bind` + or by modifying the `bindings.json` file. + + default value: `false` + * `matchbrace`: show matching braces for '()', '{}', '[]' when the cursor is on a brace character or (if `matchbraceleft` is enabled) next to it. diff --git a/runtime/help/plugins.md b/runtime/help/plugins.md index 4e35b8c3..11170507 100644 --- a/runtime/help/plugins.md +++ b/runtime/help/plugins.md @@ -178,6 +178,8 @@ The packages and their contents are listed below (in Go type signatures): bind the key `k` to the string `v`. If `overwrite` is true, this will overwrite any existing binding to key `k`. Returns true if the binding was made, and a possible error. + This operation can be rejected by `lockbindings` to prevent undesired + actions by the user. - `Reload()`: reload configuration files.