Skip to content

Commit 48cb752

Browse files
Adding lockbindings option for disallowing lua to modify bindings at all
1 parent 83241d6 commit 48cb752

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

internal/action/bindings.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,11 @@ func eventsEqual(e1 Event, e2 Event) bool {
262262
}
263263

264264
// TryBindKeyPlug tries to bind key for the plugin without writing to bindings.json.
265+
// This operation can be rejected by lockbindings to prevent unexpected actions by the user.
265266
func TryBindKeyPlug(k, v string, overwrite bool) (bool, error) {
267+
if l, ok := config.GlobalSettings["lockbindings"]; ok && l.(bool) {
268+
return false, errors.New("bindings is locked by the user")
269+
}
266270
return TryBindKey(k, v, overwrite, false)
267271
}
268272

internal/config/settings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ var DefaultGlobalOnlySettings = map[string]any{
118118
"helpsplit": "hsplit",
119119
"infobar": true,
120120
"keymenu": false,
121+
"lockbindings": false,
121122
"mouse": true,
122123
"multiopen": "tab",
123124
"parsecursor": false,

runtime/help/options.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ Here are the available options:
231231

232232
default value: `false`
233233

234+
* `lockbindings`: disable plugins and lua scripts for binding any keys.
235+
Any custom actions must be binded manually either via commands like `bind`
236+
or by modifying the `bindings.json` file.
237+
238+
default value: `false`
239+
234240
* `matchbrace`: show matching braces for '()', '{}', '[]' when the cursor
235241
is on a brace character or (if `matchbraceleft` is enabled) next to it.
236242

0 commit comments

Comments
 (0)