From 5908d88a3eba9c94d33eeeba5f70e93e04a3818b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 26 Sep 2021 14:21:40 -0700 Subject: [PATCH 1/3] fix(lsp_spec): tests depended on previous session backport #15803 - fix tests which accidentally depended on previous session --- test/functional/plugin/lsp_spec.lua | 55 ++++++++++++++--------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 39e9ed54c0..8423ace232 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -132,38 +132,35 @@ end describe('LSP', function() before_each(function() clear_notrace() + -- Run an instance of nvim on the file which contains our "scripts". + -- Pass TEST_NAME to pick the script. + local test_name = "basic_init" + exec_lua([=[ + lsp = require('vim.lsp') + local test_name, fixture_filename, logfile = ... + function test__start_client() + return lsp.start_client { + cmd_env = { + NVIM_LOG_FILE = logfile; + }; + cmd = { + vim.v.progpath, '-Es', '-u', 'NONE', '--headless', + "-c", string.format("lua TEST_NAME = %q", test_name), + "-c", "luafile "..fixture_filename; + }; + root_dir = vim.loop.cwd(); + } + end + TEST_CLIENT1 = test__start_client() + ]=], test_name, fake_lsp_code, fake_lsp_logfile) + end) + + after_each(function() + exec_lua("lsp._vim_exit_handler()") + -- exec_lua("lsp.stop_all_clients(true)") end) describe('server_name specified', function() - before_each(function() - -- Run an instance of nvim on the file which contains our "scripts". - -- Pass TEST_NAME to pick the script. - local test_name = "basic_init" - exec_lua([=[ - lsp = require('vim.lsp') - local test_name, fixture_filename, logfile = ... - function test__start_client() - return lsp.start_client { - cmd_env = { - NVIM_LOG_FILE = logfile; - }; - cmd = { - vim.v.progpath, '-Es', '-u', 'NONE', '--headless', - "-c", string.format("lua TEST_NAME = %q", test_name), - "-c", "luafile "..fixture_filename; - }; - root_dir = vim.loop.cwd(); - } - end - TEST_CLIENT1 = test__start_client() - ]=], test_name, fake_lsp_code, fake_lsp_logfile) - end) - - after_each(function() - exec_lua("lsp._vim_exit_handler()") - -- exec_lua("lsp.stop_all_clients(true)") - end) - it('start_client(), stop_client()', function() retry(nil, 4000, function() eq(1, exec_lua('return #lsp.get_active_clients()')) From 9eed756cade1410db156d927da6a77bebe9dc4f2 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Tue, 7 Sep 2021 20:52:08 -0700 Subject: [PATCH 2/3] feat(lsp): add warning message for large log size --- runtime/lua/vim/lsp/log.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua index 2848b380be..e25db333f9 100644 --- a/runtime/lua/vim/lsp/log.lua +++ b/runtime/lua/vim/lsp/log.lua @@ -33,6 +33,17 @@ do vim.fn.mkdir(vim.fn.stdpath('cache'), "p") local logfile = assert(io.open(logfilename, "a+")) + + local log_info = vim.loop.fs_stat(logfilename) + if log_info and log_info.size > 1e9 then + local warn_msg = string.format( + "LSP client log is large (%d MB): %s", + log_info.size / (1000 * 1000), + logfilename + ) + vim.notify(warn_msg) + end + -- Start message for logging logfile:write(string.format("[START][%s] LSP logging initiated\n", os.date(log_date_format))) for level, levelnr in pairs(log.levels) do From 3f20d8bb09e82aeff7c6b02fbe8a165b44fc53d4 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Tue, 7 Sep 2021 21:48:19 -0700 Subject: [PATCH 3/3] chore(lsp): fix formatting in vim.lsp.log (#15596) --- runtime/lua/vim/lsp/log.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua index e25db333f9..6c58d27368 100644 --- a/runtime/lua/vim/lsp/log.lua +++ b/runtime/lua/vim/lsp/log.lua @@ -34,15 +34,15 @@ do vim.fn.mkdir(vim.fn.stdpath('cache'), "p") local logfile = assert(io.open(logfilename, "a+")) - local log_info = vim.loop.fs_stat(logfilename) - if log_info and log_info.size > 1e9 then - local warn_msg = string.format( - "LSP client log is large (%d MB): %s", - log_info.size / (1000 * 1000), - logfilename - ) - vim.notify(warn_msg) - end + local log_info = vim.loop.fs_stat(logfilename) + if log_info and log_info.size > 1e9 then + local warn_msg = string.format( + "LSP client log is large (%d MB): %s", + log_info.size / (1000 * 1000), + logfilename + ) + vim.notify(warn_msg) + end -- Start message for logging logfile:write(string.format("[START][%s] LSP logging initiated\n", os.date(log_date_format)))