My Neovim & NvChad Configuration

Introduction

This repo hosts my Neovim and NvChad configuration for Linux, macOS, and Windows.

This configuration is written as clearly as possible. You can clone the entire repository and use it, but this is not recommended. The best configuration is personal, so everyone should have their own unique configuration. You are encouraged to clone from this repo the part you want and add it to your config.

To reduce the possibility of damage, this configuration is only maintained for the latest Neovim stable release and the latest NvChad. No effort is required to maintain backward compatibility.

Preview

Click to expand

nv-dash cheatsheet lazy mason1 mason2 telescope file chatgpt nvimtree search cmdline symboloutline code theme

Features

Prerequisites

  • Make sure you have installed the latest version of Neovim v0.9+.
  • Have installed NvChad v2.0.
  • Have Installed Neovide (optional, if using Neovide as Neovim GUI).
  • Have the following programs installed on your system:
    • git
    • make
    • curl, wget
    • File compression: unzip, gzip, tar, 7zip, ... (optional)
    • lua
    • nodejs, npm and yarn
    • python3 and pip3
    • ripgrep or fd for live grep Telescope search
  • Terminal with true color support.
  • Use a Nerd Font v3+ in your terminal emulator, make sure the nerd font you set doesn't end with Mono to present small icons. This config recommends Cascadia Code (Caskaydia Cove) or Fira Code fonts.
  • Delete old custom NvChad config folder (check uninstall commands below).

Install

# Linux/macOS
rm -rf ~/.config/nvim/lua/custom
git clone https://github.com/DuongHieu0712z/nvchad-config.git ~/.config/nvim/lua/custom
# Windows (Powershell)
rm -r -fo ~\AppData\Local\nvim\lua\custom
git clone https://github.com/DuongHieu0712z/nvchad-config.git ~\AppData\Local\nvim\lua\custom

Uninstall

Note: These commands only delete this config, not NvChad config. To delete NvChad config, please go here.

# Linux/macOS
rm -rf ~/.config/nvim/lua/custom
rm -rf ~/.local/share/nvim
rm -rf ~/.cache/nvim
# Windows (Powershell)
rm -r -fo ~\AppData\Local\nvim\lua\custom
rm -r -fo ~\AppData\Local\nvim-data

Get healthy

Open nvim and enter the following:

:checkhealth

You'll probably notice you don't have support for copy/paste also that python and node haven't been setup.

So let's fix that.

First, we'll fix copy/paste:

  • On macOS, pbcopy should be builtin.

  • On Ubuntu:

    sudo apt install xsel # for X11
    sudo apt install wl-clipboard # for wayland

Next, we need to install python and node support:

  • Neovim python support:

    pip install pynvim
  • Neovim node support:

    npm i -g neovim

Update NvChad

To update NvChad to the latest version

:NvChadUpdate

Markdown preview setup

If you build markdown-preview.nvim get error, you can fix it by:

  • Change to markdown-preview.nvim directory:

    # Linux/macOS
    cd ~/.local/share-nvim/lazy/markdown-preview.nvim
    # Windows (Powershell)
    cd ~\AppData\Local\nvim-data\lazy\markdown-preview.nvim
  • Build plugin:

    yarn install
    yarn build

ChatGPT secret management

Get an API key from OpenAI, which you can obtain here. Save API key to file openai.txt in your $HOME folder.

Generate a new GPG key if you haven't, follow the instructions here. After generate, use the follow command to encrypt file openai.txt in your $HOME folder:

gpg -e openai.txt -r <USER-ID>

Note: You can use passphrase for security, but I recommend not using passphrase for convenience.

If the previous command run successfully, a new filename openai.txt.gpg will be generated in your $HOME folder.

The following configuration would use GPG to decrypt a local file containing the API key in file custom/configs/chatgpt.lua:

local home = vim.fn.expand "$HOME"

local M = {
  api_key_cmd = "gpg -d " .. home .. "/openai.txt.gpg",
}

return M

Codium authentication

When start Neovim, run :Codeium Auth to set up the plugin and start using Codeium.

Copy the token from your browser and paste it into API token request.

Use Ctrl-R * or Ctrl-R +, to paste the token into Popup.