Wansmer / langmapper.nvim

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

fix: hack `get_keymap` too #12

Closed danilshvalov closed 1 year ago

danilshvalov commented 1 year ago

See https://github.com/Wansmer/langmapper.nvim/issues/8#issuecomment-1529135431

danilshvalov commented 1 year ago

Since the get_keymap method is now being hacked, the tests do not pass. Here are two options that I see. The first is obviously to remove the falling tests. The second is to come up with something more elegant. But nothing comes to mind so far.

danilshvalov commented 1 year ago

Great, I figured out how to fix the tests: use the original functions!

Wansmer commented 1 year ago

Hi! Thanks for your contribution!

I tested this PR and it does not seem to work as expected:

  1. The filter_default_keymaps function always returns an empty table instead of filtered. With my config, this behavior breaks neo-tree. Also, I'm installed which-key for testing, and it breaks showing prompt when I press <leader>. I think, the best way to filter original mappings table - it is to see that mapping.desc does not contain LM (prefix of all mappings handled by langmapper).

  2. I think wrappers for get_keymap should not be hacked by default. Better is to just add it to the API and if users need to hack it, they can do it themselves in their config.

danilshvalov commented 1 year ago

I checked the method with desc and it doesn't work the way I would like. I will try to fix the filtering function. I've changed something, try again, does the above work for you?

danilshvalov commented 1 year ago

I also made them optional. Now you need to activate them as follows:

local langmapper = require("langmapper")
langmapper.setup()
langmapper.hack_get_keymap()
danilshvalov commented 1 year ago

With my config, this behavior breaks neo-tree. Also, I'm installed which-key for testing, and it breaks showing prompt when I press <leader>.

It's strange that which-key and neo-tree don't work for you. Everything works as expected for me. I hope the latest patches will fix the problem.

Wansmer commented 1 year ago

It's strange that which-key and neo-tree don't work for you. Everything works as expected for me. I hope the latest patches will fix the problem.

I'll test again tonight. Not at the computer anymore.

Wansmer commented 1 year ago

Great, now it works! Thanks again!

Fixed #8