diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/rust_analyzer.lua | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/lua/lspconfig/server_configurations/rust_analyzer.lua b/lua/lspconfig/server_configurations/rust_analyzer.lua index 656c459d..22575b47 100644 --- a/lua/lspconfig/server_configurations/rust_analyzer.lua +++ b/lua/lspconfig/server_configurations/rust_analyzer.lua @@ -50,19 +50,26 @@ return { end local cargo_crate_dir = util.root_pattern 'Cargo.toml'(fname) - local cmd = { 'cargo', 'metadata', '--no-deps', '--format-version', '1' } + local cargo_workspace_root + if cargo_crate_dir ~= nil then - cmd[#cmd + 1] = '--manifest-path' - cmd[#cmd + 1] = util.path.join(cargo_crate_dir, 'Cargo.toml') - end + local cmd = { + 'cargo', + 'metadata', + '--no-deps', + '--format-version', + '1', + '--manifest-path', + util.path.join(cargo_crate_dir, 'Cargo.toml'), + } - local result = async.run_command(cmd) - local cargo_workspace_root + local result = async.run_command(cmd) - if result and result[1] then - result = vim.json.decode(table.concat(result, '')) - if result['workspace_root'] then - cargo_workspace_root = util.path.sanitize(result['workspace_root']) + if result and result[1] then + result = vim.json.decode(table.concat(result, '')) + if result['workspace_root'] then + cargo_workspace_root = util.path.sanitize(result['workspace_root']) + end end end |
