Install Neovim, NvChad, Mason, and rust‐analyzer from scratch - greensegfault/neovim-rust GitHub Wiki
It took me a while to get Neovim and rust-analyzer rolling so I thought I recap my steps here if it could help anyone.
- If you already have a Neovim installation and want to start from a clean sheet, try,
rm -rf ~/.config/nvim ~/.local/share/nvim
-
Start with installing Neovim 0.9.5 from here https://github.com/neovim/neovim/blob/master/INSTALL.md
-
Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Install rust-analyzer using rustup
rustup component add rust-analyzer
- Install NvChad
apt-get install ripgrep
Check if you have rg
on Mac.
You can get the Jetbrains Nerd Font from here https://www.nerdfonts.com/font-downloads . You will need the font for proper Nvim interface.
Install NvChad
git clone https://github.com/NvChad/starter ~/.config/nvim && nvim
-
In Neovim run
:Mason
and ensure the package manager works. It's Mason, not Manson. If you need to troubleshoot Neovim, try:checkhealth
-
Install packages in Nvim using Mason
:MasonInstall lua-language-server
:MasonInstall rust-analyzer
:MasonInstall codelldb
- Install nvim-dap
git clone https://github.com/mfussenegger/nvim-dap.git ~/.config/nvim/pack/plugins/start/nvim-dap
-
Restart Nvim make sure things are working.
-
Edit
~/.config/nvim/lua/plugins/init.lua
and ensure it looks as follows:
return {
{
"stevearc/conform.nvim",
-- event = 'BufWritePre', -- uncomment for format on save
config = function()
require "configs.conform"
end,
},
{
"neovim/nvim-lspconfig",
config = function()
require("nvchad.configs.lspconfig").defaults()
require "configs.lspconfig"
end,
},
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"lua-language-server", "stylua",
"html-lsp", "css-lsp" , "prettier"
},
},
},
{ 'williamboman/mason-lspconfig.nvim'},
{ 'mfussenegger/nvim-dap'},
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"vim", "lua", "vimdoc",
"html", "css"
},
},
},
{
'mrcjkb/rustaceanvim',
version = '^4', -- Recommended
lazy = false, -- This plugin is already lazy
},
}
-
Restart Nvim and make sure things are still working.
-
Start a new rust project and edit the bin rs file. You should see the LSP cogwheel logo and the code will be real-time commented by the recommendation engine rust-analyzer.
-
Have a coffee.