find rust-analyzer automatically and display error when not found

This commit is contained in:
2025-09-22 09:50:27 +02:00
parent f0378b57e6
commit 82af4d91d4

View File

@@ -171,8 +171,15 @@ return {
lazy = false,
ft = { "rust" },
config = function()
local rust_analyzer_path = vim.fn.trim(vim.fn.system("rustup which rust-analyzer"))
if rust_analyzer_path == "" then
vim.notify("rust-analyzer not found! Install it with: rustup component add rust-analyzer",
vim.log.levels.ERROR)
return
end
vim.g.rustaceanvim = {
server = {
cmd = { rust_analyzer_path },
on_attach = lsp_attach,
settings = {
-- rust-analyzer language server configuration