aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/server_configurations/rust_analyzer.lua
diff options
context:
space:
mode:
authorRaphael <glepnir@neovim.pro>2023-05-11 15:00:38 +0800
committerGitHub <noreply@github.com>2023-05-11 15:00:38 +0800
commit32f0c0465ac3ee53a1a9c0f72602a7b9cecb31d3 (patch)
tree47a974e689b5acc4611ff9307e49a1ee0c187576 /lua/lspconfig/server_configurations/rust_analyzer.lua
parenttest: remove test depend and use vusted (#2603) (diff)
downloadnvim-lspconfig-32f0c0465ac3ee53a1a9c0f72602a7b9cecb31d3.tar
nvim-lspconfig-32f0c0465ac3ee53a1a9c0f72602a7b9cecb31d3.tar.gz
nvim-lspconfig-32f0c0465ac3ee53a1a9c0f72602a7b9cecb31d3.tar.bz2
nvim-lspconfig-32f0c0465ac3ee53a1a9c0f72602a7b9cecb31d3.tar.lz
nvim-lspconfig-32f0c0465ac3ee53a1a9c0f72602a7b9cecb31d3.tar.xz
nvim-lspconfig-32f0c0465ac3ee53a1a9c0f72602a7b9cecb31d3.tar.zst
nvim-lspconfig-32f0c0465ac3ee53a1a9c0f72602a7b9cecb31d3.zip
fix(rust_analyzer): check stdout data size (#2605)
Diffstat (limited to 'lua/lspconfig/server_configurations/rust_analyzer.lua')
-rw-r--r--lua/lspconfig/server_configurations/rust_analyzer.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/lua/lspconfig/server_configurations/rust_analyzer.lua b/lua/lspconfig/server_configurations/rust_analyzer.lua
index cfa61200..6d2ab33d 100644
--- a/lua/lspconfig/server_configurations/rust_analyzer.lua
+++ b/lua/lspconfig/server_configurations/rust_analyzer.lua
@@ -17,7 +17,10 @@ local function get_workspace_dir(cmd)
local stderr = {}
local jobid = vim.fn.jobstart(cmd, {
on_stdout = function(_, data, _)
- stdout[#stdout + 1] = table.concat(data, '\n')
+ data = table.concat(data, '\n')
+ if #data > 0 then
+ stdout[#stdout + 1] = data
+ end
end,
on_stderr = function(_, data, _)
stderr[#stderr + 1] = table.concat(data, '\n')
@@ -38,6 +41,9 @@ local function get_workspace_dir(cmd)
end
coroutine.yield()
+ if next(stdout) == nil then
+ return nil
+ end
stdout = vim.json.decode(table.concat(stdout, ''))
return stdout and stdout['workspace_root'] or nil
end