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.

  1. If you already have a Neovim installation and want to start from a clean sheet, try,

rm -rf ~/.config/nvim ~/.local/share/nvim

  1. Start with installing Neovim 0.9.5 from here https://github.com/neovim/neovim/blob/master/INSTALL.md

  2. Install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

  1. Install rust-analyzer using rustup

rustup component add rust-analyzer

  1. 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

  1. In Neovim run :Mason and ensure the package manager works. It's Mason, not Manson. If you need to troubleshoot Neovim, try :checkhealth

  2. Install packages in Nvim using Mason

:MasonInstall lua-language-server
:MasonInstall rust-analyzer
:MasonInstall codelldb
  1. Install nvim-dap
git clone https://github.com/mfussenegger/nvim-dap.git ~/.config/nvim/pack/plugins/start/nvim-dap
  1. Restart Nvim make sure things are working.

  2. 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
  },
}
  1. Restart Nvim and make sure things are still working.

  2. 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.

  3. Have a coffee.