]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Not able to set language server trace level during initialization
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 18 Jun 2023 01:26:16 +0000 (18:26 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 18 Jun 2023 01:26:16 +0000 (18:26 -0700)
autoload/lsp/handlers.vim
autoload/lsp/lsp.vim
autoload/lsp/lspserver.vim
doc/lsp.txt

index 9a04cb6feb9ca4db5bf0c556219bf7dd878e422a..428fdd4f2900ca19c773a540a5f39d50ecea91c8 100644 (file)
@@ -206,8 +206,9 @@ export def ProcessRequest(lspserver: dict<any>, request: dict<any>)
   # Explicitly ignored requests
   var lspIgnoredRequestHandlers: list<string> =
     [
-      # Eclipse java language server sends the 'workspace/executeClientCommand' 
-      # request (to reload bundles) which is not in the LSP specification.
+      # Eclipse java language server sends the
+      # 'workspace/executeClientCommand' request (to reload bundles) which is
+      # not in the LSP specification.
       'workspace/executeClientCommand',
     ]
 
index b66d9f3eaa57f718f3d3196d3fb9465d5192a5f5..a2d7bede2fd332cb434d4b52a07722cf93dd7dbe 100644 (file)
@@ -600,42 +600,41 @@ export def AddServer(serverList: list<dict<any>>)
       endif
       continue
     endif
-    var args: list<string> = []
     if server->has_key('args')
       if server.args->type() != v:t_list
         util.ErrMsg($'Arguments for LSP server {server.args} is not a List')
         continue
       endif
-      args = server.args
+    else
+      server.args = []
     endif
 
-    var initializationOptions: dict<any> = {}
-    if server->has_key('initializationOptions')
-      initializationOptions = server.initializationOptions
+    if !server->has_key('initializationOptions')
+       || server.initializationOptions->type() != v:t_dict
+      server.initializationOptions = {}
     endif
 
-    var customNotificationHandlers: dict<func> = {}
-    if server->has_key('customNotificationHandlers')
-      customNotificationHandlers = server.customNotificationHandlers
+    if !server->has_key('customNotificationHandlers')
+       || server.customNotificationHandlers->type() != v:t_dict
+      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')
         continue
       endif
-      ProcessDiagHandler = server.processDiagHandler
+    else
+      server.processDiagHandler = null_function
     endif
 
-    var customRequestHandlers: dict<func> = {}
-    if server->has_key('customRequestHandlers')
-      customRequestHandlers = server.customRequestHandlers
+    if !server->has_key('customRequestHandlers')
+       || server.customRequestHandlers->type() != v:t_dict
+      server.customRequestHandlers = {}
     endif
 
-    var features: dict<bool> = {}
-    if server->has_key('features')
-      features = server.features
+    if !server->has_key('features') || server.features->type() != v:t_dict
+      server.features = {}
     endif
 
     if server.omnicompl->type() != v:t_bool
@@ -648,7 +647,7 @@ export def AddServer(serverList: list<dict<any>>)
     endif
 
     if !server->has_key('name') || server.name->type() != v:t_string
-                                                       || server.name->empty()
+       || server.name->empty()
       # Use the executable name (without the extension) as the language server
       # name.
       server.name = server.path->fnamemodify(':t:r')
@@ -658,7 +657,15 @@ export def AddServer(serverList: list<dict<any>>)
       server.debug = false
     endif
 
+    if !server->has_key('traceLevel')
+       || server->type() != v:t_string
+       || (server.traceLevel != 'off' && server.traceLevel != 'debug'
+           && server.traceLevel != 'verbose')
+      server.traceLevel = 'off'
+    endif
+
     if !server->has_key('workspaceConfig')
+       || server.workspaceConfig->type() != v:t_dict
       server.workspaceConfig = {}
     endif
 
@@ -666,25 +673,17 @@ export def AddServer(serverList: list<dict<any>>)
       server.rootSearch = []
     endif
 
-    if !server->has_key('runIfSearch') || server.runIfSearch->type() != v:t_list
+    if !server->has_key('runIfSearch') ||
+       server.runIfSearch->type() != v:t_list
       server.runIfSearch = []
     endif
 
-    if !server->has_key('runUnlessSearch') || server.runUnlessSearch->type() != v:t_list
+    if !server->has_key('runUnlessSearch') ||
+       server.runUnlessSearch->type() != v:t_list
       server.runUnlessSearch = []
     endif
 
-    var lspserver: dict<any> = lserver.NewLspServer(server.name, server.path,
-                                                   args, server.syncInit,
-                                                   initializationOptions,
-                                                   server.workspaceConfig,
-                                                   server.rootSearch,
-                                                   server.runIfSearch,
-                                                   server.runUnlessSearch,
-                                                   customNotificationHandlers,
-                                                   customRequestHandlers,
-                                                   ProcessDiagHandler,
-                                                   features, server.debug)
+    var lspserver: dict<any> = lserver.NewLspServer(server)
 
     var ftypes = server.filetype
     if ftypes->type() == v:t_string
index 8ccf2f590e18657b70226bb29fc4bc88a85d492f..03d89bd8414953d862576c75b501adfa8752a645 100644 (file)
@@ -135,6 +135,11 @@ def ServerInitReply(lspserver: dict<any>, initResult: dict<any>): void
     exe $'doautocmd <nomodeline> User LspServerReady_{lspserver.id}'
   endif
 
+  # set the server debug trace level
+  if lspserver.traceLevel != 'off'
+    lspserver.setTrace(lspserver.traceLevel)
+  endif
+
   # if the outline window is opened, then request the symbols for the current
   # buffer
   if bufwinid('LSP-Outline') != -1
@@ -1709,27 +1714,18 @@ def GetUniqueServerId(): number
   return UniqueServerIdCounter
 enddef
 
-export def NewLspServer(name_arg: string, path_arg: string, args: list<string>,
-                       isSync: bool, initializationOptions: any,
-                       workspaceConfig: dict<any>,
-                       rootSearchFiles: list<any>,
-                       runIfSearchFiles: list<any>,
-                       runUnlessSearchFiles: list<any>,
-                       customNotificationHandlers: dict<func>,
-                       customRequestHandlers: dict<func>,
-                       ProcessDiagHandler: func,      
-                       features: dict<bool>, debug_arg: bool): dict<any>
+export def NewLspServer(serverParams: dict<any>): dict<any>
   var lspserver: dict<any> = {
     id: GetUniqueServerId(),
-    name: name_arg,
-    path: path_arg,
-    args: args,
-    syncInit: isSync,
-    initializationOptions: initializationOptions,
-    customNotificationHandlers: customNotificationHandlers,
-    customRequestHandlers: customRequestHandlers,
-    processDiagHandler: ProcessDiagHandler,
-    features: features,
+    name: serverParams.name,
+    path: serverParams.path,
+    args: serverParams.args->deepcopy(),
+    syncInit: serverParams.syncInit,
+    initializationOptions: serverParams.initializationOptions->deepcopy(),
+    customNotificationHandlers: serverParams.customNotificationHandlers->deepcopy(),
+    customRequestHandlers: serverParams.customRequestHandlers->deepcopy(),
+    processDiagHandler: serverParams.processDiagHandler,
+    features: serverParams.features->deepcopy(),
     running: false,
     ready: false,
     job: v:none,
@@ -1737,9 +1733,9 @@ export def NewLspServer(name_arg: string, path_arg: string, args: list<string>,
     nextID: 1,
     caps: {},
     requests: {},
-    rootSearchFiles: rootSearchFiles,
-    runIfSearchFiles: runIfSearchFiles,
-    runUnlessSearchFiles: runUnlessSearchFiles,
+    rootSearchFiles: serverParams.rootSearch->deepcopy(),
+    runIfSearchFiles: serverParams.runIfSearch->deepcopy(),
+    runUnlessSearchFiles: serverParams.runUnlessSearch->deepcopy(),
     omniCompletePending: false,
     completionTriggerChars: [],
     signaturePopup: -1,
@@ -1751,9 +1747,10 @@ export def NewLspServer(name_arg: string, path_arg: string, args: list<string>,
     peekSymbolFilePopup: -1,
     callHierarchyType: '',
     selection: {},
-    workspaceConfig: workspaceConfig,
+    workspaceConfig: serverParams.workspaceConfig->deepcopy(),
     messages: [],
-    debug: debug_arg
+    debug: serverParams.debug,
+    traceLevel: serverParams.traceLevel
   }
   lspserver.logfile = $'lsp-{lspserver.name}.log'
   lspserver.errfile = $'lsp-{lspserver.name}.err'
index 7bee0a06eb532ff02ef013c51a92f60e717d875d..6c8b47f290c0f1e495934054ae643261b9fb267c 100644 (file)
@@ -384,6 +384,10 @@ Additionally the following configurations can be made:
                        debugging a language server.  By default the
                        messages are not logged.  See |lsp-debug| for more
                        information.
+                                               *lsp-cfg-traceLevel*
+       traceLevel      (Optional) set the debug trace level for this language
+                       server.  Supported values are: "off", "debug" and
+                       "verbose".  By default this is seto "off".
 
 The language servers are added using the LspAddServer() function. This
 function accepts a list of language servers with the above information.