]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Make it possible to disable diagnostics for a specific server
authorAndreas Louv <andreas@louv.dk>
Fri, 14 Apr 2023 21:39:30 +0000 (23:39 +0200)
committerAndreas Louv <andreas@louv.dk>
Sat, 15 Apr 2023 05:47:04 +0000 (07:47 +0200)
autoload/lsp/diag.vim
doc/lsp.txt

index 2e7c2166e3bf96ddfc92d8f8227a1782a043cd6b..1d28a40e0d00200cf94cd4adb89663a855fdbbc2 100644 (file)
@@ -211,6 +211,11 @@ enddef
 # Notification: textDocument/publishDiagnostics
 # Param: PublishDiagnosticsParams
 export def DiagNotification(lspserver: dict<any>, uri: string, newDiags: list<dict<any>>): 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
index 203f2e4fb37ed24154a2f807fbe81a5a90455219..828bfd468c8a1fe6ffe34d63deb1c1df7c12395e 100644 (file)
@@ -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*