folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
5.38k stars 177 forks source link

fix(view): set modifiable flag for view buffer #506

Closed mivort closed 1 year ago

mivort commented 1 year ago

This change provides a fix to somewhat niche use case when user has nomodifiable option enabled globally. Currently, if nomodifiable option is enabled globally it causes plugin to reach unrecoverable state when 'view' window shows nothing and each key press produces only more Lua exceptions.

Enabling modifiable flag on buffer creation ensures the proper state of new scratch buffer, no matter what the current global value is.

Without this change, running :set nomodifiable and then pressing any key produces the following exception:

E5108: Error executing lua .../which-key.nvim/lua/which-key/view.lua:336: Buffer is not 'modifiable'
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        .../which-key.nvim/lua/which-key/view.lua:336: in function 'render'
        .../which-key.nvim/lua/which-key/view.lua:313: in function 'on_keys'
        .../which-key.nvim/lua/which-key/view.lua:255: in function 'open'
        .../which-key.nvim/lua/which-key/init.lua:49: in function 'show'
        [string ":lua"]:1: in main chunk