-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register readable prefix for grouped keymap settings #1134
Conversation
IMO it's better to register prefix for |
It's up to you. I'm just making a suggestion. |
OK. The reason why current approach doesn't work for keymappings binded to buffer may causes from the absense of the |
It seems better that @Cyberczy give the authority of your fork to @Cheny-chui as the GitHub Docs says: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/committing-changes-to-a-pull-request-branch-created-from-a-fork |
Ok, I've just given you modification access. @Cheny-chui |
@CharlesChiuGit Could you please review this PR? |
ok, let me take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz remove lazy-lock
Current prefix settings are not enough and needed to be added manually. I'm thinking automatically setting whether is a better idea. Though this requires keymap setup to keep align with it. |
What is the general rationale behind the current key mapping? |
Signed-off-by: ayamir <[email protected]>
Current keymap settings are mixed but a little confusing due to history reasons. |
@ayamir @Jint-lzxy |
IMO it's better to refactor it. |
LGTM!!! |
The right half of which-key seems a bit empty. Perhaps we can add a bit of padding. |
IMO it is unnecessary. |
Alright, it's just a suggestion |
Sorry for the delay! My sched's been a bit tight recently. But I'll probably review this in the next day or two lol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! This PR is awesome lmao
(idk if this is related) But I'm wondering if the real issue might lie in the implementation of which-key.nvim, as I used a different approach to handle keymap registration, but it seems that (only recently) which-key sometimes displays +prefix
even for named groups (like <leader>h
, see the screenshot below):
Then I did a git bisect, and the issue seems to originate from this commit (strangely tho, this means that which-key thinks some of my keymap groups don't have a valid name, but obviously I did give them names). For some reason, in this call, the (to be processed) group still has a name, but immediately in the next line, that name disappears. Based on this, IMO a simpler solution 'might' be to revert 8503c0
(I can create a fork just like we made a temporary fix for lsp-signature
), and then wait for folke's response (I'll open an issue for this); or just merge this PR. What do you guys think @ayamir @CharlesChiuGit?
Signed-off-by: ayamir <[email protected]>
I didn't view settings about |
Ah, I think this probably isn't related. Sorry for the noise here! (I didn't notice that our impl is kinda like an event loop 🙈) Here's a similar issue with more details: folke/which-key.nvim#482. @ayamir With that being said, I'm still a bit puzzled as to why we need to register these mappings dynamically. I feel like just statically registering them using |
It's b/c the statical way only registers the group name once when init and doesn't work for our lsp-related keymaps are binded with buffer after return function()
local icons = {
ui = require("modules.utils.icons").get("ui"),
misc = require("modules.utils.icons").get("misc"),
git = require("modules.utils.icons").get("git", true),
cmp = require("modules.utils.icons").get("cmp", true),
}
require("which-key").register({
["<leader>"] = {
b = {
name = icons.ui.Buffer .. " Buffer",
},
d = {
name = icons.ui.Bug .. " Debug",
},
f = {
name = icons.ui.Telescope .. " Fuzzy Find",
},
g = {
name = icons.git.Git .. "Git",
},
l = {
name = icons.misc.LspAvailable .. " Lsp",
},
n = {
name = icons.ui.FolderOpen .. " Nvim Tree",
},
p = {
name = icons.ui.Package .. " Package",
},
s = {
name = icons.cmp.tmux .. "Session",
},
},
})
require("modules.utils").load_plugin("which-key", {
plugins = {
presets = {
operators = false,
motions = false,
text_objects = false,
windows = false,
nav = false,
z = true,
g = true,
},
},
icons = {
breadcrumb = icons.ui.Separator,
separator = icons.misc.Vbar,
group = "",
},
window = {
border = "none",
position = "bottom",
margin = { 1, 0, 1, 0 },
padding = { 1, 1, 1, 1 },
winblend = 0,
},
})
end |
So, should we stick with statically registering them, or should we maintain the current state by dynamically registering them? |
It seems to me now that the statical way is better. |
Signed-off-by: ayamir <[email protected]>
* Use Nerd Font to replace the +prefix (It's just a demo) * Move insert registration into bind. * Fix unexpected shadow. * format code. * For tab instead of space. * chore(ci): fix linting * fix: works for buffer-related keymap by registering prefix immediately. Signed-off-by: ayamir <[email protected]> * chore(which-key): add more nerdfont for which-key prefix * fix: works for <space> as prefix. * refactor: update keymaps and defer register operation to shorten startup time. * clean up. * fixup: remove redundant code. * perf: reduce number of register queue insertion. Signed-off-by: ayamir <[email protected]> * refactor: use the statical way to set group names. * clean files. Signed-off-by: ayamir <[email protected]> --------- Signed-off-by: ayamir <[email protected]> Co-authored-by: Chui <[email protected]> Co-authored-by: CharlesChiuGit <[email protected]> Co-authored-by: ayamir <[email protected]>
No description provided.