Wansmer / langmapper.nvim

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

idea: create a wiki with hacks for plugins #10

Closed danilshvalov closed 1 year ago

danilshvalov commented 1 year ago

TL;DR: I suggest creating a community-driven wiki where users will share their improvements of various plugins using langmapper.nvim.

Hi! A lot of plugins need to be modified one way or another so that they work as expected. For example, leap.nvim. By default, leap.nvim reads characters using getcharstr, so remap won't help here. Since leap.nvim uses English characters for labels, it is logical that the characters entered should be transformed into English. After analysis the leap.nvim code, I realized that get-input is only used to get the label, not to get the source text. So I was able to apply the following hack:

require("leap.util")["get-input"] = function()
  local ok, ch = pcall(vim.fn.getcharstr)
  if ok and ch ~= vim.api.nvim_replace_termcodes("<esc>", true, false, true) then
    return require("langmapper.utils").translate_keycode(ch, "default", "ru")
  end
end

This is an example of how the hack works:

https://user-images.githubusercontent.com/57654917/232829861-0861b163-f1fa-468b-837f-92df2841bbb1.mp4

Why am I doing this? It would be useful for all langmapper.nvim users to collect a knowledge base on how to modify a particular plugin for different layouts. I suggest creating a community-driven wiki.

Wansmer commented 1 year ago

This is a great idea! But I think it's better to use Discussions marked 🙌 Show and tell for this. Now I have opened Discussions.

Using Wiki with editing from all GitHub users seems to me insecure in terms of the information provided.

danilshvalov commented 1 year ago

Created a new topic in discussions (see #11).