@@ -931,13 +931,17 @@ describe('lsp_status component', function()
931
931
assert_comp_ins (lsp_status_comp , ' lua_ls' )
932
932
end )
933
933
934
- it (' shows LSP progress when supported with precise time measurement ' , function ()
934
+ it (' shows LSP progress when supported' , function ()
935
935
vim .cmd (' edit ' .. file )
936
936
stub (vim .lsp , ' get_clients' )
937
937
vim .lsp .get_clients .on_call_with ({ bufnr = vim .api .nvim_get_current_buf () }).returns { { id = 2 , name = ' lua_ls' } }
938
- vim .uv = vim .uv or {}
939
- stub (vim .uv , ' hrtime' )
940
- vim .uv .hrtime .on_call_with ().returns (12 * 1e6 * 80 )
938
+ if vim .uv and vim .uv .hrtime then
939
+ stub (vim .uv , ' hrtime' )
940
+ vim .uv .hrtime .on_call_with ().returns (12 * 1e6 * 80 )
941
+ elseif vim .loop and vim .loop .hrtime then
942
+ stub (vim .loop , ' hrtime' )
943
+ vim .loop .hrtime .on_call_with ().returns (12 * 1e6 * 80 )
944
+ end
941
945
942
946
local ok = pcall (vim .api .nvim_exec_autocmds , ' LspProgress' , {
943
947
data = { client_id = 2 , params = { value = { kind = ' begin' } } },
@@ -950,24 +954,24 @@ describe('lsp_status component', function()
950
954
end
951
955
end )
952
956
953
- it (' shows LSP progress when supported without precise time measurement ' , function ()
957
+ it (' shows LSP done when supported' , function ()
954
958
vim .cmd (' edit ' .. file )
955
959
stub (vim .lsp , ' get_clients' )
956
960
vim .lsp .get_clients .on_call_with ({ bufnr = vim .api .nvim_get_current_buf () }).returns { { id = 2 , name = ' lua_ls' } }
957
- vim .uv = nil
958
961
959
962
local ok = pcall (vim .api .nvim_exec_autocmds , ' LspProgress' , {
960
963
data = { client_id = 2 , params = { value = { kind = ' begin' } } },
964
+ }) and pcall (vim .api .nvim_exec_autocmds , ' LspProgress' , {
965
+ data = { client_id = 2 , params = { value = { kind = ' end' } } },
961
966
})
962
967
963
968
-- Skip assertion if LSP progress updates are not supported by the current `nvim` version.
964
969
if ok then
965
- -- We start from 0 and advanced by 1, so use spinner symbol 1.
966
- assert_comp_ins (lsp_status_comp , ' lua_ls ⠙' )
970
+ assert_comp_ins (lsp_status_comp , ' lua_ls ✓' )
967
971
end
968
972
end )
969
973
970
- it (' shows LSP progress when supported with precise time measurement ' , function ()
974
+ it (' shows LSP done when supported and no begin ' , function ()
971
975
vim .cmd (' edit ' .. file )
972
976
stub (vim .lsp , ' get_clients' )
973
977
vim .lsp .get_clients .on_call_with ({ bufnr = vim .api .nvim_get_current_buf () }).returns { { id = 2 , name = ' lua_ls' } }
@@ -982,7 +986,11 @@ describe('lsp_status component', function()
982
986
end
983
987
end )
984
988
985
- it (' shows LSP done when supported' , function ()
989
+ it (' does not add unnecessary space separator when LSP progress symbol is empty' , function ()
990
+ local opts_no_done = opts
991
+ opts_no_done .symbols = { done = ' ' }
992
+ local lsp_status_comp_no_done = helpers .init_component (' lsp_status' , opts )
993
+
986
994
vim .cmd (' edit ' .. file )
987
995
stub (vim .lsp , ' get_clients' )
988
996
vim .lsp .get_clients .on_call_with ({ bufnr = vim .api .nvim_get_current_buf () }).returns { { id = 2 , name = ' lua_ls' } }
@@ -995,7 +1003,7 @@ describe('lsp_status component', function()
995
1003
996
1004
-- Skip assertion if LSP progress updates are not supported by the current `nvim` version.
997
1005
if ok then
998
- assert_comp_ins (lsp_status_comp , ' lua_ls ✓ ' )
1006
+ assert_comp_ins (lsp_status_comp_no_done , ' lua_ls' )
999
1007
end
1000
1008
end )
1001
1009
end )
0 commit comments