Set up Neovim for Rust by installing the nvim-lspconfig plugin and configuring rust-analyzer with cargo build scripts and procMacro support. Add the following Lua configuration to your Neovim init.lua file to enable the language server and inlay hints:
local lspconfig = require('lspconfig')
lspconfig.rust_analyzer.setup({
on_attach = function(client, bufnr)
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end,
settings = {
['rust-analyzer'] = {
cargo = {
buildScripts = { enable = true }
},
procMacro = {
enable = true
}
}
}
})
Restart Neovim to apply the changes.