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)
# 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
lspserver.job = job
lspserver.running = true
- lspserver.initServer(isSync)
+ lspserver.initServer()
return 0
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)
req.params->extend(initparams)
lspserver.sendMessage(req)
- if isSync
+ if lspserver.sync
lspserver.waitForResponse(req)
endif
enddef
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,
<
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 = [
\ #{
\ 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',
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.