From: shane.xb.qian Date: Mon, 7 Nov 2022 07:18:54 +0000 (+0800) Subject: feat: make code action popup can be selected by item num, and 'h/l' to close popup... X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=45f704017ceb6240e6e2d8520bf75288ed03b62a;p=vim-lsp.git feat: make code action popup can be selected by item num, and 'h/l' to close popup as well. --- diff --git a/autoload/lsp/codeaction.vim b/autoload/lsp/codeaction.vim index 862c4ac..d739064 100644 --- a/autoload/lsp/codeaction.vim +++ b/autoload/lsp/codeaction.vim @@ -77,16 +77,26 @@ export def ApplyCodeAction(lspserver: dict, actions: list>): void mapping: 0, wrap: 0, title: 'Code action', - callback: (_, id) => { + callback: (_, result) => { # Invalid item selected or closed the popup - if id <= 0 || id > text->len() + if result <= 0 || result > text->len() return endif # Do the code action - HandleCodeAction(lspserver, actions[id - 1]) + HandleCodeAction(lspserver, actions[result - 1]) }, - filter: 'popup_filter_menu' + filter: (winid, key) => { + if key == 'h' || key == 'l' + popup_close(winid, -1) + elseif str2nr(key) > 0 + # supposed would not over 9 items + popup_close(winid, str2nr(key)) + else + return popup_filter_menu(winid, key) + endif + return 1 + }, }) else choice = inputlist(["Code action:"] + text)