mvllow / modes.nvim

Prismatic line decorations for the adventurous vim user
550 stars 13 forks source link

<C-c> causes error first time #14

Closed matze closed 2 years ago

matze commented 2 years ago

I use <C-c> to go back to normal mode instead of Escape however the very first time I get this error:

Error executing  vim.on_key Lua callback: vim.lua:498: Error executing 'on_key' with ns_ids '5'
    Messages: Keyboard interrupt
stack traceback:
        [C]: in function 'error'
        vim.lua:498: in function <vim.lua:485>

The following patch fixes it however it breaks getting out of visual mode:

    local on_key = vim.on_key or vim.register_keystroke_callback
    on_key(function(key)
+       if key == util.get_termcode('<C-c>') then
+           return
+       end
+
        local current_mode = vim.fn.mode()
mvllow commented 2 years ago

I think this is fixed in #15, if you or anyone else could use the graceful-error branch and let me know if everything works as expected that'd be much appreciated 😌

matze commented 2 years ago

Yeah, that branch fixes it for me. Thanks!