Merge pull request #23458 from neovim/backport-23002-to-release-0.9

[Backport release-0.9] test(lsp_spec): fix unstable tests for set_defaults
This commit is contained in:
zeertzjq
2023-05-03 10:59:02 +08:00
committed by GitHub

View File

@@ -323,14 +323,12 @@ describe('LSP', function()
local client local client
test_rpc_server { test_rpc_server {
test_name = "set_defaults_all_capabilities"; test_name = "set_defaults_all_capabilities";
on_setup = function()
exec_lua [[
BUFFER = vim.api.nvim_create_buf(false, true)
]]
end;
on_init = function(_client) on_init = function(_client)
client = _client client = _client
exec_lua("lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)") exec_lua [[
BUFFER = vim.api.nvim_create_buf(false, true)
lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
]]
end; end;
on_handler = function(_, _, ctx) on_handler = function(_, _, ctx)
if ctx.method == 'test' then if ctx.method == 'test' then
@@ -352,7 +350,8 @@ describe('LSP', function()
local client local client
test_rpc_server { test_rpc_server {
test_name = "set_defaults_all_capabilities"; test_name = "set_defaults_all_capabilities";
on_setup = function() on_init = function(_client)
client = _client
exec_lua [[ exec_lua [[
vim.api.nvim_command('filetype plugin on') vim.api.nvim_command('filetype plugin on')
BUFFER_1 = vim.api.nvim_create_buf(false, true) BUFFER_1 = vim.api.nvim_create_buf(false, true)
@@ -360,14 +359,16 @@ describe('LSP', function()
vim.api.nvim_buf_set_option(BUFFER_1, 'filetype', 'man') vim.api.nvim_buf_set_option(BUFFER_1, 'filetype', 'man')
vim.api.nvim_buf_set_option(BUFFER_2, 'filetype', 'xml') vim.api.nvim_buf_set_option(BUFFER_2, 'filetype', 'xml')
]] ]]
-- Sanity check to ensure that some values are set after setting filetype.
eq('v:lua.require\'man\'.goto_tag', get_buf_option("tagfunc", "BUFFER_1")) eq('v:lua.require\'man\'.goto_tag', get_buf_option("tagfunc", "BUFFER_1"))
eq('xmlcomplete#CompleteTags', get_buf_option("omnifunc", "BUFFER_2")) eq('xmlcomplete#CompleteTags', get_buf_option("omnifunc", "BUFFER_2"))
eq('xmlformat#Format()', get_buf_option("formatexpr", "BUFFER_2")) eq('xmlformat#Format()', get_buf_option("formatexpr", "BUFFER_2"))
end;
on_init = function(_client) exec_lua [[
client = _client lsp.buf_attach_client(BUFFER_1, TEST_RPC_CLIENT_ID)
exec_lua("lsp.buf_attach_client(BUFFER_1, TEST_RPC_CLIENT_ID)") lsp.buf_attach_client(BUFFER_2, TEST_RPC_CLIENT_ID)
exec_lua("lsp.buf_attach_client(BUFFER_2, TEST_RPC_CLIENT_ID)") ]]
end; end;
on_handler = function(_, _, ctx) on_handler = function(_, _, ctx)
if ctx.method == 'test' then if ctx.method == 'test' then
@@ -389,18 +390,16 @@ describe('LSP', function()
local client local client
test_rpc_server { test_rpc_server {
test_name = "set_defaults_all_capabilities"; test_name = "set_defaults_all_capabilities";
on_setup = function() on_init = function(_client)
client = _client
exec_lua [[ exec_lua [[
BUFFER = vim.api.nvim_create_buf(false, true) BUFFER = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(BUFFER, 'tagfunc', 'tfu') vim.api.nvim_buf_set_option(BUFFER, 'tagfunc', 'tfu')
vim.api.nvim_buf_set_option(BUFFER, 'omnifunc', 'ofu') vim.api.nvim_buf_set_option(BUFFER, 'omnifunc', 'ofu')
vim.api.nvim_buf_set_option(BUFFER, 'formatexpr', 'fex') vim.api.nvim_buf_set_option(BUFFER, 'formatexpr', 'fex')
lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
]] ]]
end; end;
on_init = function(_client)
client = _client
exec_lua("lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)")
end;
on_handler = function(_, _, ctx) on_handler = function(_, _, ctx)
if ctx.method == 'test' then if ctx.method == 'test' then
eq('tfu', get_buf_option("tagfunc")) eq('tfu', get_buf_option("tagfunc"))