autoload/lsp/codeaction.vim | 8 +++++++- autoload/lsp/options.vim | 4 +++- doc/lsp.txt | 14 +++++++++----- diff --git a/autoload/lsp/codeaction.vim b/autoload/lsp/codeaction.vim index 229523039a59fe73108d1885ed29e397a9f08517..81994946c5c5af0a9b7c950d46d52da55a4b6e6c 100644 --- a/autoload/lsp/codeaction.vim +++ b/autoload/lsp/codeaction.vim @@ -43,7 +43,13 @@ DoCommand(lspserver, selAction) endif enddef -export def ApplyCodeAction(lspserver: dict, actions: list>, query: string): void +export def ApplyCodeAction(lspserver: dict, actionlist: list>, query: string): 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 8aa8f8f8a58feaa169decd2ad8cae302dd4b8408..c8dc2fbd5a696fe98822c1ccc1c2a229fc44291f 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -43,7 +43,9 @@ usePopupInCodeAction: false, # 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 0cecbe75adf154e6b119841e2a2b0dd91ce30d68..bf4cfade70aeee8a3171c3461ec91f267bd2fd47 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -208,6 +208,8 @@ call LspAddServer(lspServers) < To add a language server, the following information is needed: + path complete path to the language server executable + (without any arguments). args a list of command-line arguments passed to the language server. Each argument is a separate List item. @@ -220,6 +222,9 @@ additional initialization options may be required or useful for initialization. Those can be provided in this dictionary and if present will be transmitted to the lsp server. + +Aditionally the following configurations can be made: + customNotificationHandlers (Optional) some lsp servers (e.g. typescript-language-server) will send additional @@ -229,8 +234,6 @@ reference to the 'lspserver' and the 'reply'. omnicompl (Optional) a boolean value that enables (true) or disables (false) omni-completion for this file types. By default this is set to 'v:true'. - path complete path to the language server executable - (without any arguments). syncInit (Optional) for language servers (e.g. rust analyzer, gopls, etc.) that take time to initialize and reply to a 'initialize' request message this should be set to @@ -273,9 +276,13 @@ default this is set to true. autoPopulateDiags Automatically populate the location list with diagnostics from the language server. By default this is set to false. +diagLineHL Highlight used for diagnostic line. + By default uses `Cursor`. + Use `NONE` to disable. 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 @@ -283,9 +290,6 @@ LspShowReferences. By default this is set to false. noDiagHoverOnLine Suppress diagnostic hover from appearing when the mouse is over the line instead of the signature. By default this is set to true. -diagLineHL Highlight used for diagnostic line. - By default uses `Cursor`. - Use `NONE` to disable. noNewlineInCompletion Suppress adding a new line on completion selection with . By default this is set to false.