]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Merge branch 'main' into process-diags
authorYegappan Lakshmanan <4298407+yegappan@users.noreply.github.com>
Sun, 21 May 2023 19:35:28 +0000 (12:35 -0700)
committerGitHub <noreply@github.com>
Sun, 21 May 2023 19:35:28 +0000 (12:35 -0700)
1  2 
autoload/lsp/lsp.vim
autoload/lsp/lspserver.vim
doc/lsp.txt

index 4b13403f758e6ea6196b669a9cadb67b2706a6c6,5e309df9de49dac1b1c12f33c5bcf1331ad15a5d..bb204e3572a2f0efe76d62bcdcb11b8e42cbdb09
@@@ -612,16 -612,11 +612,20 @@@ export def AddServer(serverList: list<d
        customNotificationHandlers = server.customNotificationHandlers
      endif
  
 +    var ProcessDiagHandler: func = null_function
 +    if server->has_key('processDiagHandler')
 +      if server.processDiagHandler->type() != v:t_func
 +        util.ErrMsg($'Setting of processDiagHandler {server.processDiagHandler} is not a Funcref nor lambda')
 +        return
 +      endif
 +      ProcessDiagHandler = server.processDiagHandler
 +    endif
 +
+     var customRequestHandlers: dict<func> = {}
+     if server->has_key('customRequestHandlers')
+       customRequestHandlers = server.customRequestHandlers
+     endif
      var features: dict<bool> = {}
      if server->has_key('features')
        features = server.features
                                                    server.runIfSearch,
                                                    server.runUnlessSearch,
                                                    customNotificationHandlers,
-                                                   ProcessDiagHandler,
+                                                   customRequestHandlers,
++                                                  ProcessDiagHandler,
                                                    features, server.debug)
  
      var ftypes = server.filetype
index ccd3c4d2492443287e6a02ca43c92cc84580d20e,031106e35a05bb85ad8cdff010600b9ca7048fd4..8988cada3a13427527f7137775800c489a87ab58
@@@ -1505,7 -1505,7 +1505,8 @@@ export def NewLspServer(name_arg: strin
                        runIfSearchFiles: list<any>,
                        runUnlessSearchFiles: list<any>,
                        customNotificationHandlers: dict<func>,
-                       ProcessDiagHandler: func,
+                       customRequestHandlers: dict<func>,
++                      ProcessDiagHandler: func,      
                        features: dict<bool>, debug_arg: bool): dict<any>
    var lspserver: dict<any> = {
      id: GetUniqueServerId(),
      syncInit: isSync,
      initializationOptions: initializationOptions,
      customNotificationHandlers: customNotificationHandlers,
+     customRequestHandlers: customRequestHandlers,
 +    processDiagHandler: ProcessDiagHandler,
      features: features,
      running: false,
      ready: false,
diff --cc doc/lsp.txt
index 0a621b4aae68329f8551bbe5eb439ca965a0d483,875685f662ff32b79ccf6a5120c88f1a0ad28ffe..cabc041ca02c12846465973538395172b0d6c191
@@@ -318,46 -327,8 +327,46 @@@ Additionally the following configuratio
                        |lsp-features| for more information.
                                                *lsp-cfg-omnicompl*
        omnicompl       (Optional) a boolean value that enables (true)
--                      or disables (false) omni-completion for this file
 -                      types. By default this is set to "true".
++                      or disables (false) omni-completion for these 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.  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
 +                              })
 +                      },
 +              }])
 +<
 +                      And this example will prefix the diagnostic message with
 +                      the string "TypeScript: ": >
 +
 +              vim9script
 +              g:LspAddServer([{
 +                      filetype: ['javascript', 'typescript'],
 +                      path: '/usr/local/bin/typescript-language-server',
 +                      args: ['--stdio'],
 +                      processDiagHandler: (diags: list<dict<any>>) => {
 +                              return diags->map((diag, ix) => {
 +                                      diag.message = $'TypeScript: {diag.message}'
 +                                      return diag
 +                              })
 +                      },
 +              }])
 +<
                                                *lsp-cfg-syncInit*
        syncInit        (Optional) for language servers (e.g. rust analyzer,
                        gopls, etc.) that take time to initialize and reply to