2

I'm currently using Emacs with LSP mode for writing TypeScript code and it works pretty well.

The only annoyance that I currently have is that each time I need to reach to mouse to click to complete suggested actions like

Add async modifier to containing function

or

Add 'fooFunc' to existing import declaration from 'some/dep'

The only commands that I noticed in (view-lossage) were:

<down-mouse-1> [evil-mouse-drag-region]
<mouse-1> <down-mouse-1> [evil-mouse-drag-region]
<mouse-1> <mouse-1> [mouse-set-point]
<down-mouse-1> [anonymous-command]
<drag-mouse-1> [mouse-set-region]

Ideally it should have some kind of up/down navigation using a keyboard to select the needed option/action.

Is there a way to do it?

A screenshot with an example has been added enter image description here

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
  • Not sure if i understand the question. Are you seeing in the minibuffer a list of possible code actions and you want to know how to select one with the keyboard? I am assuming it is using `completing-read` and since i have `icomplete` setup it uses the up/down keyboard keys i have defined for that. If you don't have something like `icomplete`, `ido`, `helm` or `ivy` setup then at least I'd think you can hit `TAB` which wil l open the completion buffer and you can navigate to it, to the item you want and hit `RET` which should then select the item. – verdammelt Jan 08 '21 at 02:45
  • @verdammelt thanks for your comment. I've just added a screenshot with an example. I'm using a pretty standard Spacemacs distro which uses helm afaik. But these auto-suggested actions don't seem to be using helm... they are displayed along the code, not in a separate minibuf. – BinaryButterfly Jan 08 '21 at 03:18
  • @verdammelt actually you gave me an idea, perhaps this is related to evil-mode that I'm using and it prevents me from using up/down arrows for action selection. In evil-mode up/down arrow just moves to the upper/lower line and therefore loses the focus. – BinaryButterfly Jan 08 '21 at 03:19
  • Ah, i see you are using the lsp-ui stuff (i don't use that) so I can't help you more I guess :| I thought you were using the code action function (default binding is `s-l a a`). – verdammelt Jan 08 '21 at 04:10

1 Answers1

3

Turns out that was surprisingly easy.

lsp-execute-code-action is the function you might be looking for if have the same issue.

In spacemacs the shortcut for it is SPC a a

lsp-execute-code-action

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91