autoload/lsp/lsp.vim | 6 +++--- autoload/lsp/lspserver.vim | 4 ++-- doc/lsp.txt | 11 +++++++---- test/unit_tests.vim | 4 ++-- diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index c29f1c451bf0bd7347d2103dd4ff6c53cd370c2c..8fbc9cf7386b4a5d13f33bdbbb038fcc7b1785a2 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -497,12 +497,12 @@ util.ErrMsg('Error: Setting of omnicompl ' .. server.omnicompl .. ' is not a Boolean') return endif - if !server->has_key('sync') - server['sync'] = v:false + if !server->has_key('syncInit') + server.syncInit = v:false endif var lspserver: dict = lserver.NewLspServer(server.path, args, - \ server.sync) + server.syncInit) if server.filetype->type() == v:t_string LspAddServer(server.filetype, lspserver) diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 2c4e25724e6d1da9fdab861442a23766924bc611..ad8e9f8fa3bb5fa2edafaa2b8efcf4fb0fe1881a 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -172,7 +172,7 @@ initparams.capabilities = clientCaps req.params->extend(initparams) lspserver.sendMessage(req) - if lspserver.sync + if lspserver.syncInit lspserver.waitForResponse(req) endif enddef @@ -1020,7 +1020,7 @@ export def NewLspServer(path: string, args: list, isSync: bool): dict var lspserver: dict = { path: path, args: args, - sync: isSync, + syncInit: isSync, running: false, ready: false, job: v:none, diff --git a/doc/lsp.txt b/doc/lsp.txt index 3dee5e256655cb6e656a538f59f5d9f68f7d307f..79d09e89f0171396174cfa6e502d63eec97014f1 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -203,10 +203,13 @@ args a list of command-line arguments passed to the LSP 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'. + syncInit (Optional) for lsp servers (e.g. rust analyzer, gopls) + that take time to reply to a 'initialize' request + message this should be set to 'v:true'. By default + this is set to 'v:false'. If this is set to true, + then a synchronous call is used to initialize the LSP + server. Otherwise the server is initialized + asynchronously. The LSP servers are added using the LspAddServer() function. This function accepts a list of LSP servers with the above information. diff --git a/test/unit_tests.vim b/test/unit_tests.vim index a6603ac8d97d0eada94ad88bb8a426ea8df32a9d..62d9fc54fa05739959d6839d144c36db1055fe7f 100644 --- a/test/unit_tests.vim +++ b/test/unit_tests.vim @@ -661,7 +661,7 @@ assert_equal(['MyFunc(int a, int b) -> int'], getbufline(bnr, 1, '$')) var expected: dict expected = {id: 0, col: 8, end: 1, type: 'signature', length: 5, start: 1} if has('patch-8.2.3233') - expected.type_bufnr = 11 + expected.type_bufnr = bnr endif assert_equal([expected], prop_list(1, {bufnr: bnr})) popup_close(p[0]) @@ -675,7 +675,7 @@ assert_equal(1, p->len()) assert_equal(['MyFunc(int a, int b) -> int'], getbufline(bnr, 1, '$')) expected = {id: 0, col: 15, end: 1, type: 'signature', length: 5, start: 1} if has('patch-8.2.3233') - expected.type_bufnr = 11 + expected.type_bufnr = bnr endif assert_equal([expected], prop_list(1, {bufnr: bnr})) popup_close(p[0])