Search code examples
typescriptemacslanguage-server-protocol

Emacs LSP mode - is it possible to avoid mouse click to complete suggested actions?


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


Solution

  • 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