From 1d8977accda5a27bfb997f51a51d3ead5a6da8dd Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Fri, 14 Apr 2023 23:39:30 +0200 Subject: [PATCH] Make it possible to disable diagnostics for a specific server --- autoload/lsp/diag.vim | 5 +++++ doc/lsp.txt | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index 2e7c216..1d28a40 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -211,6 +211,11 @@ enddef # Notification: textDocument/publishDiagnostics # Param: PublishDiagnosticsParams export def DiagNotification(lspserver: dict, uri: string, newDiags: list>): void + # Diagnostics are disabled for this server + if lspserver.features->has_key('diagnostics') && !lspserver.features.diagnostics + return + endif + var fname: string = util.LspUriToFile(uri) var bnr: number = fname->bufnr() if bnr == -1 diff --git a/doc/lsp.txt b/doc/lsp.txt index 203f2e4..828bfd4 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -1398,6 +1398,23 @@ typescript-language-server for everything else: > } ]) < +Another way is to disable the unwanted features: for example if you don't want +diagnostics from the typescript-language-server, but want to use it for +everything else: > + + vim9script + + g:LspAddServer([ + { + filetype: ['javascript', 'typescript'], + path: '/usr/local/bin/typescript-language-server', + args: ['--stdio'], + features: { + diagnostics: false + } + }, + ]) +< ============================================================================== 17. Language Server Features *lsp-features* @@ -1417,6 +1434,12 @@ declaration Used by |:LspGotoDeclaration|, and *lsp-features-definition* definition Used by |:LspGotoDefinition|, and |:LspPeekDefinition| + *lsp-features-diagnostics* +diagnostics Used to disable diagnostics for a single + language server, by default diagnostics are + combined from all running servers, by setting + this to |v:false| you can ignore diagnostics + from a specific server. *lsp-features-documentFormatting* documentFormatting Used by |:LspFormat|, and 'formatexpr' *lsp-features-documentHighlight* -- 2.50.0