Wansmer / langmapper.nvim

A plugin that makes Neovim more friendly to non-English input methods 🤝
MIT License
128 stars 7 forks source link

fix(get_keymap): case insensitive compare #14

Closed danilshvalov closed 1 year ago

danilshvalov commented 1 year ago

Without this fix when using the command line (via q:) an error occurs when nvim-cmp is enabled:

Error executing vim.schedule lua callback: ....local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:29: E11: Invalid in command-line window;
<CR> executes, CTRL-C quits
stack traceback:
        [C]: in function 'nvim_buf_delete'
        ....local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:29: in function 'normalize'
        ...valov/.local/share/nvim/lazy/nvim-cmp/lua/cmp/config.lua:175: in function 'normalize'
        ...valov/.local/share/nvim/lazy/nvim-cmp/lua/cmp/config.lua:126: in function 'callback'
        .../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/cache.lua:38: in function 'get'
        ...valov/.local/share/nvim/lazy/nvim-cmp/lua/cmp/config.lua:134: in function 'enabled'
        ...shvalov/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:300: in function 'callback'
        .../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/async.lua:165: in function <.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/async.lu
a:163>

As I understand it, the fact is that some mappings are set in uppercase (for example, C-Z instead of C-z). Therefore, the following condition is not met (see code):

if lhs == get_default_translation(lhs) then
  table.insert(filtered, mapping)
end

This patch makes the check case-insensitive.

Wansmer commented 1 year ago

Thanks for contributing!