Add example for how to filter diagnostics
authorAndreas Louv <andreas@louv.dk>
Sat, 20 May 2023 19:39:29 +0000 (21:39 +0200)
committerAndreas Louv <andreas@louv.dk>
Sat, 20 May 2023 21:14:59 +0000 (23:14 +0200)
doc/lsp.txt

index 2cf47b728783a6246cde1d86da0c2845161a49f0..551a35265e43a31ccb0c9aa2b37fa18e9b94d108 100644 (file)
@@ -326,7 +326,22 @@ Additionally the following configurations can be made:
                        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.
+                       text, etc.  The following example will remove all but
+                       errors and warnings: >
+
+               vim9script
+               g:LspAddServer([{
+                       filetype: ['javascript', 'typescript'],
+                       path: '/usr/local/bin/typescript-language-server',
+                       args: ['--stdio'],
+                       processDiagHandler: (diags: list<dict<any>>) => {
+                               # Only include errors and warnings
+                               return diags->filter((diag, ix) => {
+                                       return diag.severity <= 2
+                               })
+                       },
+               }])
+<
                                                *lsp-cfg-syncInit*
        syncInit        (Optional) for language servers (e.g. rust analyzer,
                        gopls, etc.) that take time to initialize and reply to