From 2dd9e060f21eecd403736bef07ec83b73341d955 Mon Sep 17 00:00:00 2001 From: bstaint Date: Mon, 17 Oct 2022 14:00:42 +0800 Subject: fix(rust_analyzer): path nil (#2198) --- lua/lspconfig/server_configurations/rust_analyzer.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lspconfig/server_configurations/rust_analyzer.lua b/lua/lspconfig/server_configurations/rust_analyzer.lua index e18cbf5a..4e95ce87 100644 --- a/lua/lspconfig/server_configurations/rust_analyzer.lua +++ b/lua/lspconfig/server_configurations/rust_analyzer.lua @@ -41,13 +41,16 @@ return { local cargo_workspace_dir = nil if cm == 0 then cargo_workspace_dir = vim.json.decode(cargo_metadata)['workspace_root'] + if cargo_workspace_dir ~= nil then + cargo_workspace_dir = util.path.sanitize(cargo_workspace_dir) + end else vim.notify( string.format('[lspconfig] cmd (%q) failed:\n%s', table.concat(cmd, ' '), cargo_metadata_err), vim.log.levels.WARN ) end - return util.path.sanitize(cargo_workspace_dir) + return cargo_workspace_dir or cargo_crate_dir or util.root_pattern 'rust-project.json'(fname) or util.find_git_ancestor(fname) -- cgit v1.2.3-70-g09d2