]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add the server config "processDiagHandler"
authorAndreas Louv <andreas@louv.dk>
Sat, 20 May 2023 19:38:34 +0000 (21:38 +0200)
committerAndreas Louv <andreas@louv.dk>
Sat, 20 May 2023 19:38:34 +0000 (21:38 +0200)
autoload/lsp/diag.vim
autoload/lsp/lsp.vim
autoload/lsp/lspserver.vim
doc/lsp.txt

index f812c401aaf0e89cd44b82c37bb6df22b10479b3..cf74879b0484c84e57ce3fc88eea69c78e8819d2 100644 (file)
@@ -251,7 +251,7 @@ enddef
 # process a diagnostic notification message from the LSP server
 # Notification: textDocument/publishDiagnostics
 # Param: PublishDiagnosticsParams
-export def DiagNotification(lspserver: dict<any>, uri: string, newDiags: list<dict<any>>): void
+export def DiagNotification(lspserver: dict<any>, uri: string, diags_arg: list<dict<any>>): void
   # Diagnostics are disabled for this server
   if lspserver.features->has_key('diagnostics') && !lspserver.features.diagnostics
     return
@@ -264,6 +264,11 @@ export def DiagNotification(lspserver: dict<any>, uri: string, newDiags: list<di
     return
   endif
 
+  var newDiags: list<dict<any>> = diags_arg
+  if lspserver.processDiagHandler != null_function
+    newDiags = lspserver.processDiagHandler(diags_arg)
+  endif
+
   # TODO: Is the buffer (bnr) always a loaded buffer? Should we load it here?
   var lastlnum: number = bnr->getbufinfo()[0].linecount
 
index b2f6dd3e0bc4bbd57be11389573395d95f4ede18..edecb3ffba1ef3634aef4983e7951db4e3aa34e6 100644 (file)
@@ -612,6 +612,11 @@ export def AddServer(serverList: list<dict<any>>)
       customNotificationHandlers = server.customNotificationHandlers
     endif
 
+    var ProcessDiagHandler: func = null_function
+    if server->has_key('processDiagHandler')
+      ProcessDiagHandler = server.processDiagHandler
+    endif
+
     var features: dict<bool> = {}
     if server->has_key('features')
       features = server.features
@@ -661,6 +666,7 @@ export def AddServer(serverList: list<dict<any>>)
                                                    server.runIfSearch,
                                                    server.runUnlessSearch,
                                                    customNotificationHandlers,
+                                                   ProcessDiagHandler,
                                                    features, server.debug)
 
     var ftypes = server.filetype
index 89501a2c02498566cf1bff55d69e22a35f8c09a8..ccd3c4d2492443287e6a02ca43c92cc84580d20e 100644 (file)
@@ -1505,6 +1505,7 @@ export def NewLspServer(name_arg: string, path_arg: string, args: list<string>,
                        runIfSearchFiles: list<any>,
                        runUnlessSearchFiles: list<any>,
                        customNotificationHandlers: dict<func>,
+                       ProcessDiagHandler: func,
                        features: dict<bool>, debug_arg: bool): dict<any>
   var lspserver: dict<any> = {
     id: GetUniqueServerId(),
@@ -1514,6 +1515,7 @@ export def NewLspServer(name_arg: string, path_arg: string, args: list<string>,
     syncInit: isSync,
     initializationOptions: initializationOptions,
     customNotificationHandlers: customNotificationHandlers,
+    processDiagHandler: ProcessDiagHandler,
     features: features,
     running: false,
     ready: false,
index 7ce342a0a60210b4d96c845355ef86b8681d0a7a..2cf47b728783a6246cde1d86da0c2845161a49f0 100644 (file)
@@ -320,6 +320,13 @@ Additionally the following configurations can be made:
        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".
+                                               *lsp-cfg-processDiagHandler*
+       processDiagHandler
+                       (Optional) A |Funcref| or |lambda| that takes a list of
+                       language server diagnostics and returns a new list of
+                       filtered, or otherwise changed diagnostics.  Can be used
+                       to remove unwanted diagnostics, prefix the diagnostics
+                       text, etc.
                                                *lsp-cfg-syncInit*
        syncInit        (Optional) for language servers (e.g. rust analyzer,
                        gopls, etc.) that take time to initialize and reply to