folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
5.44k stars 176 forks source link

Triggering if I finish the key combination #29

Closed grecodavide closed 3 years ago

grecodavide commented 3 years ago

I'm sure this is just something I messed up, but I can't understand where is the problem. If I finish a key combination fast enough not to trigger Which Key, it still opens. image This is an example of what I get if I open the file browser, and if I press esc everything works fine. I also tried to to a key combination slow enough to pop the menu immediately, and again everything works fine (same thing with timeoutlen = 0)

folke commented 3 years ago

What is the key combo for opening the file browser?

I also just added :checkhealth which_key, you may want to check that too.

What do you get when doing :map <leader>

grecodavide commented 3 years ago

The key combo is fe, but it does the same thing with every "leader" combination that creates a popup I tried so far. checkhealth which_key gives me that image

As for map i get this image

folke commented 3 years ago

That warning is OK.

Only for <leader> combos, or also for other things like g?

grecodavide commented 3 years ago

No, just tried and this doesn't happen for g. It seems to me that only if I open a popup I have this problem, since also things like comment line (c), packer sync (ps) works fine

folke commented 3 years ago

Can you tell me exactly what happens when you do:

  1. type <leader> and wait till popup, then type f
  2. type <leader>f and wait till popup

For both of the above, is the popup correctly showing the e option?

do you have more mappings under <leader>fe? like <leader>feeeee or something like that?

folke commented 3 years ago

Is the key combo a <plug> by any chance?

grecodavide commented 3 years ago

Yes it shows correctly, and if I do it slowly I don't have any problem at all.

Nop, it's the only mapping under <leader>fe, but also things like <leader>ff, mapped to telescope find files doesn't work, and it isn't a <plug>, this is the mapping vim.api.nvim_set_keymap('n', '<Leader>fe', '<cmd>lua require(\'telescope.builtin\').file_browser({hidden = true})<CR>', {hidden = true, noremap = true})

folke commented 3 years ago

Aha, what is hidden=true 🙂 Need to check that

grecodavide commented 3 years ago

sorry, I typed it wrong, it's a silent = true

I defined a global for the options, so I wrote manually that part and misstyped

grecodavide commented 3 years ago

Don't know if this could help, but I have the same problem if I open something through Dashboard: I have set dashboard_default_executive = 'telescope', and if I try to open from the dashboard screen something like lua require(\'telescope.builtin\').oldfiles({hidden = true, shorten_path = true}) I have the same problem

folke commented 3 years ago

So pressing enter on one of the dashboard links opens the popup?

grecodavide commented 3 years ago

Yes, if I press enter on a dashboard link it behaves as if i instantly completed the key combo, same way as <Leader>fe

folke commented 3 years ago

if the popup triggers and stays open, what does the below give?

:lua print(require("which-key.view").keys)`
folke commented 3 years ago

and this one:

:lua print(vim.inspect(require("which-key.keys").get_tree("n").tree:get("<leader>fe")))
grecodavide commented 3 years ago

For the first one, as soon as I start typing the which key popup closes and i tsrta typing in the telescope popup

the second one gives this output image

folke commented 3 years ago

That's fine. Even if it closes, when you do that first command, it should show the prefix that was used. Can you show it?

grecodavide commented 3 years ago

it gives me just : I guess I'm not doing it right, what I did is: I opened the telescope popup, i pressed double column to enter command mode, but that closes the which key popup

folke commented 3 years ago

I know. Just enter the command after the popup and telescope are closed.

grecodavide commented 3 years ago

Doesn't print anything this way, I'm guessing it prints space?

Also, to check if it was actually printing space, i reset the leader key to \, and everything works fine, I get no problem at all

folke commented 3 years ago

So it only seems to be an issue when leader is set to space?

folke commented 3 years ago

did you set mapleader to <space> instead of a literal space character ?

grecodavide commented 3 years ago

I tried now (vim.g.mapleader = '<Space>', but it didn't change the problem with dashboard and if I tried to do <Space>fe nothing happens, and neovim freezes

folke commented 3 years ago

mapleader should be a literal " " character

grecodavide commented 3 years ago

Oh sorry, it already was a literal space

grecodavide commented 3 years ago

Also, I have a function that does: <cmd>bd!<CR> then checks if the current buffer is empty, and if it is it opens Dashboard

if the function (which is called by <leader>bd) just closes the buffer (meaning I have another buffer opened, and so it simply switches to that second buffer) i have no problem at all, but if the Dashboard screen is opened the which key popup is opened, and again, if I do the same key combo, but slow enough, the which key popup does not show up

folke commented 3 years ago

I just pushed some changes that may be related to that problem, so would be great if you could see if it fixes this

can you also show the full autocommand for that bd check?

folke commented 3 years ago

Just made another change that might be related :)

grecodavide commented 3 years ago

(I'm quite a noob soo probably the function sucks ) image

As for the changes, now even if I do the key combo slowly the popup shows :cry:

folke commented 3 years ago

I want to see the autocmd that triggers that function. Maybe it interfers when the popup closes.

grecodavide commented 3 years ago

no autocmd, it's just a mapping to that function

folke commented 3 years ago

I'm a bit at loss here. Very weird.

As for the changes, now even if I do the key combo slowly the popup shows 😢

So you mean that you type slowly, popup opens, then file broswer launches and popup stays open? Or does it somehow reopen again?

grecodavide commented 3 years ago

yes, the first you said, it opens the popup, but when I finish the key combo it behaves as if I did the key combo qiuckly

folke commented 3 years ago

Just to be sure:

grecodavide commented 3 years ago

the file browser open, and the popup is visible behind. After I enter the key combo, the popup in the back shows the <leader> screen, as if I just pressed my leader key: image those in the background are the prefixes of my leader mappings

grecodavide commented 3 years ago

update: I think the prolem is with the fact that the leader key is space. I tried to change it to , and it worked just fine, without giving me any problem, but I don't understand why the space key doesn't work properly

folke commented 3 years ago

It should work with space for sure. Most people (including myself) set that up as their leader. I have vim.g.mapleader = " "

grecodavide commented 3 years ago

That's what I don't understand. I have that exact same line, and it doesn't work, but if instead of " " i put "," it just works fine

folke commented 3 years ago

Can you try doing :WhichKey <leader>ef and :WhichKey <space>ef? Both should open Telescope without showing the popup.

grecodavide commented 3 years ago

I tried both with space and with , as leader key. :WhichKey <leader>fe didn't show anything in both cases, while with , as leader :WhichKey ,fe worked just fine

with <space> as leader :WhichKey <space>fe didn't show anything

folke commented 3 years ago

mapleader is set to space, before setting those telescope keybindings?

folke commented 3 years ago

That is even weirder. Telescope should at least show

grecodavide commented 3 years ago

yes, the file in which I define the leader key is the first line of the second file i require in my init.lua, before anything

folke commented 3 years ago

There must be something going on with your keybindings somewehre.

grecodavide commented 3 years ago

image output of :map <leader>fe

image output of :map <leader>f

folke commented 3 years ago

I really don't get it. Those mappings look correct. Try doing :set timeoutlen=3000 and then quickly doing typing the combo. There's no reason the popup can even start then, since it will never be hit.

grecodavide commented 3 years ago

I also tried verbose map <Leader> with comma and space set as leader key, but both gave me the same output, set at line 2 from the which key plugin, this is what I got image

folke commented 3 years ago

those mappings all are correct, that's ok

grecodavide commented 3 years ago

If i set timeoutlen to 3000 the popup doesn't show when I press the key combo, but as soon as Telescope popup is opened whichkey popup also opens

folke commented 3 years ago

ok! We're getting somewhere :) Can you share your Telescope config? Do you have any autocmds set there?

grecodavide commented 3 years ago

sure, no autocmds there

Do you prefer me sending the zipped folder containing tele config and keymappings or just screenshots?