]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
lspserver: sync property
authorChristoffer Aasted <chr.aasted@gmail.com>
Fri, 16 Sep 2022 01:06:57 +0000 (03:06 +0200)
committerChristoffer Aasted <chr.aasted@gmail.com>
Fri, 23 Sep 2022 20:32:01 +0000 (22:32 +0200)
autoload/lsp/lsp.vim
autoload/lsp/lspserver.vim
doc/lsp.txt

index 8dd73dcfc3b4ad468b1be1aa955a58dcafdbe3e8..c29f1c451bf0bd7347d2103dd4ff6c53cd370c2c 100644 (file)
@@ -497,7 +497,12 @@ export def AddServer(serverList: list<dict<any>>)
       return
     endif
 
-    var lspserver: dict<any> = lserver.NewLspServer(server.path, args)
+    if !server->has_key('sync')
+      server['sync'] = v:false
+    endif
+
+    var lspserver: dict<any> = lserver.NewLspServer(server.path, args,
+          \ server.sync)
 
     if server.filetype->type() == v:t_string
       LspAddServer(server.filetype, lspserver)
index 7559fe4cf366e72809f1302db4e6258adfa2a2d5..2c4e25724e6d1da9fdab861442a23766924bc611 100644 (file)
@@ -77,9 +77,7 @@ enddef
 
 # Start a LSP server
 #
-# If 'isSync' is true, then waits for the server to send the initialize
-# response message.
-def StartServer(lspserver: dict<any>, isSync: bool = false): number
+def StartServer(lspserver: dict<any>): number
   if lspserver.running
     util.WarnMsg("LSP server for is already running")
     return 0
@@ -117,7 +115,7 @@ def StartServer(lspserver: dict<any>, isSync: bool = false): number
   lspserver.job = job
   lspserver.running = true
 
-  lspserver.initServer(isSync)
+  lspserver.initServer()
 
   return 0
 enddef
@@ -125,9 +123,7 @@ enddef
 # Request: 'initialize'
 # Param: InitializeParams
 #
-# If 'isSync' is true, then waits for the server to send the initialize
-# response message.
-def InitServer(lspserver: dict<any>, isSync: bool = false)
+def InitServer(lspserver: dict<any>)
   var req = lspserver.createRequest('initialize')
 
   # client capabilities (ClientCapabilities)
@@ -176,7 +172,7 @@ def InitServer(lspserver: dict<any>, isSync: bool = false)
   req.params->extend(initparams)
 
   lspserver.sendMessage(req)
-  if isSync
+  if lspserver.sync
     lspserver.waitForResponse(req)
   endif
 enddef
@@ -1020,10 +1016,11 @@ def ShowCapabilities(lspserver: dict<any>)
   endfor
 enddef
 
-export def NewLspServer(path: string, args: list<string>): dict<any>
+export def NewLspServer(path: string, args: list<string>, isSync: bool): dict<any>
   var lspserver: dict<any> = {
     path: path,
     args: args,
+    sync: isSync,
     running: false,
     ready: false,
     job: v:none,
index 96158f0f7d85de8fa4bde28ddfafc00022be88e7..3dee5e256655cb6e656a538f59f5d9f68f7d307f 100644 (file)
@@ -154,10 +154,10 @@ file types, add the following commands to the .vimrc file: >
 <
 Depending on the location of the typescript and python pyls language servers
 installed in your system, update the 'path' in the above snippet
-appripriately.
+appropriately.
 
-Another example, for adding the LSP servers for the C, C++, Shell script and
-Vim file types: >
+Another example, for adding the LSP servers for the C, C++, Golang, Rust, 
+Shell script and Vim file types: >
 
    let lspServers = [
                \     #{
@@ -165,6 +165,20 @@ Vim file types: >
                \        path: '/usr/local/bin/clangd',
                \        args: ['--background-index']
                \     },
+                \     #{ 
+                \        filetype: ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'],
+                \        path: '/home/dza/.go/bin/gopls',
+                \        args: [],
+                \        sync: v:true,
+                \        omnicompl: v:true,
+                \      },
+                \     #{
+                \        filetype: ['rust'],
+                \        path: '/home/dza/.cargo/bin/rust-analyzer',
+                \        args: [],
+                \        sync: v:true,
+                \        omnicompl: v:true,
+                \      },
                \     #{
                \        filetype: 'sh',
                \        path: '/usr/local/bin/bash-language-server',
@@ -189,6 +203,10 @@ To add a LSP server, the following information is needed:
                        server. Each argument is a separate List item.
        omnicompl       a boolean value that enables (true) or disables
                        (false) omni-completion for this file type.
+        sync            (Optional) for lsp servers that responds to a 
+                        'initialize'-request with a 'initialzed' response this
+                        should be set to 'v:true'. By default this is set to
+                        'v:false'.
 
 The LSP servers are added using the LspAddServer() function. This function
 accepts a list of LSP servers with the above information.