local etc = require("etc") local buf = vim.api.nvim_get_current_buf() local rustup_dir = os.getenv('RUSTUP_HOME') or vim.env.HOME .. '.rustup' if etc.has_executable("rust-analyzer") then local rust_analyzer = vim.lsp.start({ name = 'rust-analyzer', cmd = { 'rust-analyzer' }, filetypes = { 'rust' }, single_file_support = true, root_dir = vim.fs.root(buf, {'Cargo.toml', '.git'}), }) vim.lsp.buf_attach_client(buf, rust_analyzer) end