NStefan002 / screenkey.nvim

Screencast your keys in Neovim
MIT License
291 stars 5 forks source link

Display a Keymap as some other Keymap #50

Closed amesaine closed 2 weeks ago

amesaine commented 3 weeks ago
-- Option 1
keys = 
    ["<HOME>"] = "_",
    ["<C-Home>"] = "gg",
}

-- Option 2
keys = {
    ["<HOME>"] = true,
    ["<C-Home>"] = true,
}

I remapped the basic vim motions and It would be nice if there was a way to represent the original keymaps still. This could either be done by specifying the keymap or enable displaying the original keymap through a provided option.

Then if someone were to see my screenkey, they wouldn't be confused with all the remaps.

NStefan002 commented 2 weeks ago

Hi! First of all, I'm not sure I understand what you mean. You want the screenkey to display some key combos as some other key combos? Let me know if I got that right. And if I did get that right, here is an example of how you could do this without me introducing a new (possibly very complicated) feature:

return {
    "NStefan002/screenkey.nvim",
    lazy = false,
    version = "*",
    opts = {
        filter = function(keys)
            for i, key in ipairs(keys) do
                if key.key == "Home" then
                    keys[i].key = "G"
                end
            end
            return keys
        end,
    },
}

For more info on the filter function, see readme.md of this repository or :h screenkey.nvim.txt, and take a look at #38.

amesaine commented 2 weeks ago

You want the screenkey to display some key combos as some other key

Yes. The code snippet works exactly as what I wanted thank you! I'll change the title to be clearer.