Faking enter-user-mode / dismiss info box


I am trying to come up with a nice way of allowing kak-lsp to send a message to kak, and have the user respond. Initially I wanted to do this with user-mode, but because I need to vary the message in the info box and you can’t delete or modify a user mode once declared this seems like a dead end. I have been trying to fake a user mode by using info + on-key. It works pretty well aside from I want the info box to be cleared on keypress and there doesn’t seem to be a command to dismiss the info box (at least not that I can discover).

EDIT: extra context


I did declare-user-mode zzz and then map buffer zzz z '<esc>:echo 1<ret>' -docstring '1', tried it with enter-user-mode zzz and then undefined the mapping with unmap buffer zzz z and defined another one with map buffer zzz x '<esc>:echo 2<ret>' -docstring '2' — it seems to be working.

You can’t un-declare user mode, but it shouldn’t be a big problem, let’s have a single one dedicated to showMessageRequest, something like lsp-show-message-request, and just map keys on demand and unmap them after a user makes a choice.


Sure, it’s not the dynamic nature of the keybindings it’s that message requests have two parts: the message + the actions. If we just bind the actions to key bindings then you might get a popup that just says “y: yes / n: no” with no clue as to what you are agreeing to. You could also stuff the message into each keybinding or perhaps into just the first.


Or just some no-op fake keybinding which always comes first (as bindings are shown sorted iirc).