From 6e52ca1388b64363d4952e0ac806c1812351fe3d Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Sat, 11 Mar 2023 00:11:49 +0100 Subject: [PATCH] Make it possible to hide disabled code actions with "hideDisabledCodeActions" --- autoload/lsp/codeaction.vim | 8 +++++++- autoload/lsp/options.vim | 4 +++- doc/lsp.txt | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/autoload/lsp/codeaction.vim b/autoload/lsp/codeaction.vim index 5a34d90..ca3d664 100644 --- a/autoload/lsp/codeaction.vim +++ b/autoload/lsp/codeaction.vim @@ -43,7 +43,13 @@ export def HandleCodeAction(lspserver: dict, selAction: dict) endif enddef -export def ApplyCodeAction(lspserver: dict, actions: list>): void +export def ApplyCodeAction(lspserver: dict, actionlist: list>): void + var actions = actionlist + + if opt.lspOptions.hideDisabledCodeActions + actions = actions->filter((ix, act) => !act->has_key('disabled')) + endif + if actions->empty() # no action can be performed util.WarnMsg('No code action is available') diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index 8aa8f8f..c8dc2fb 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -43,7 +43,9 @@ export var lspOptions: dict = { # enable snippet completion support snippetSupport: false, # enable inlay hints - showInlayHints: false + showInlayHints: false, + # hide disabled code actions + hideDisabledCodeActions: false } # set the LSP plugin options from the user provided option values diff --git a/doc/lsp.txt b/doc/lsp.txt index 030d96d..02d270e 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -282,6 +282,7 @@ diagLineHL Highlight used for diagnostic line. echoSignature In insert mode, echo the current symbol signature instead of showing it in a popup. By default this is set to false. +hideDisabledCodeActions Hide all disabled code actions ignoreMissingServer Do not print a missing language server executable. By default this is set to false. keepFocusInReferences Focus on the location list window after -- 2.48.1