Wansmer / langmapper.nvim

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

Which-key trick not working anymore and folds are broken (za, etc.) #33

Open julien-h opened 2 weeks ago

julien-h commented 2 weeks ago

Hello I am using LazyVim and a simple langmap to switch z with another letter w. The folding is completely broken. I am trying to fix it with this plugin but it is not working.

My investigation led me to think that the problem comes from which-key, the hack in the description does not work anymore.

julien-h commented 2 weeks ago

Still haven't found how to fix it :/

Wansmer commented 2 weeks ago

Hi! As far as I know, which-key has been rewritten recently. Since I don't use it personally, I haven't had time to look into it and update the documentation yet.

Try adding such a construct somewhere at the beginning of your init.lua (before calling which-key):

local orig_getcharstr = vim.fn.getcharstr
vim.fn.getcharstr = function() ---@diagnostic disable-line: duplicate-set-field
  local char = orig_getcharstr()
  local ok, lm = pcall(require, "langmapper.utils")
  if not ok then
    return char
  end
  return lm.translate_keycode(char, "default", "ru") -- change ru for your second layout if it not ru
end