Closed miroshQa closed 6 days ago
Hi, sorry for the late reply. I like the idea, do you mind checking out the filter branch to try out this new feature before I release it?
If you're using lazy, put this snippet in your config:
{
"NStefan002/screenkey.nvim",
lazy = false,
branch = "filter",
opts = {
filter = function(keys)
return vim.iter(keys)
:filter(function(k)
return k ~= "j" and k ~= "k"
end)
:totable()
end,
},
}
Note: Currently, filter()
takes all of the queued keys as an argument of type string[]
and returns a filtered array (type string[]
).
Note2: Currently, filter()
by default does nothing (returns original keys), in the example I provided it filters out j
and k
, you can use this example to write the filter
function according to your needs.
Thanks! It works well for me.
Perhaps there is only a small problem that it also filters shortcuts with j and k. For example, leader + j is displayed as just leader without j
vim.keymap.set("n", "<leader>j", ":lua print('hello world')<CR>")
@miron2363 makes sense. How about this:
filter = function(keys)
return vim.iter(keys)
:filter(function(k)
return (k.key ~= "j" and k.key ~= "k") or k.is_mapping
end)
:totable()
end,
In this variation, variable keys
is the array of elements that look like this:
{ key = "j", is_mapping = false }
where is_mapping
indicates whether or not is the key
part of the mapping. So in the example you provided, keys
would look like this (if group_mappings
is set to false
):
{
{ key = "<leader>", is_mapping = true },
{ key = "j", is_mapping = true },
}
Note: I discovered some bug while looking into this, so if you have
Edit: fixed<leader>J
for example as a mapping in your config and do not have <leader>j
as a mapping, screenkey
will recongnise both of those as a mapping. It should be fixed soon but until then you can check out the filter
branch.
Thanks for all the help!
This feature has been added to the 2.3.0 release, but I'll leave this issue open since the feature is still experimental.
Problem
I want to be able to hide the display of some keys
Expected behavior
Add the appropriate settings to the configuration to disable some keys. I find this useful because I don't see the point in tracking the 'hjkl' keys, they only create noise.