My neovim config is inspired by LunarVim/Neovim-from-scratch repository.
Configuration tree:
.
├── init.lua
├── lua
│ ├── core
│ │ ├── autocommands.lua # autocommands configuration
│ │ ├── gvariable.lua # global variable set(the last one be called)
│ │ ├── gfunc.lua # global function definition
│ │ ├── keymaps.lua # vim-builtin keymap set
│ │ ├── lazy.lua # plugin manager
│ │ └── options.lua # vim option set
│ └── plugins # plugins' configuration
├── snippets # customizer snippets
├── lazy-lock.json # plugins' version control file
├── spell # customizer dictionary
└── templates # store some template file
This configuration mainly focus on programming with C/Cpp, Golang, Rust and Python.
Make sure to remove or move your current nvim directory.
IMPORTANT Configuration based on neovim v0.11.0.
$ git clone https://github.com/Rlyown/nvim.git ~/.config/nvimRequirements
- Neovim
- Lua (for neovim runtime)
- Node (Required, for
tree-sitter-cliand Node-based plugins) - tree-sitter-cli (Required)
- Yarn (It's optional, if no needs to preview markdown (in browser))
Install with following Steps:
First Step. Install the necessary packages, including environments in requirements.
-
On MacOS
NOTE:
Homebrewis not necessary, you can install these packages through the tools provided by your current package-manager manually.# Runtime $ brew install neovim lua go rust # Packages $ brew install ripgrep fd lazygit gnu-sed imagemagick ghostscript # Packages (include required Node runtime) $ brew install bear node yarn # Required $ npm install --global tree-sitter-cli # If you want delete file to trash bin directory by nvim-tree $ brew install trash
Nerd Fonts is needed to show icons. You can choose your favorite font or find icons in the https://www.nerdfonts.com.
# Other nice fonts: Hack, Fira Code, Meslo $ brew tap homebrew/cask-fonts $ brew install --cask font-jetbrains-mono-nerd-fontNote: Don't forget to change your terminal fonts.
-
On Ubuntu
NOTE:
$ sudo snap install --classic nvim $ sudo apt install lua5.1 ripgrep fd-find lazygit $ mkdir -p ~/.local/bin $ ln -s $(which fdfind) ~/.local/bin/fd $ export PATH=$HOME/.local/bin:$PATH # Packages (include required Node runtime) $ npm install --global yarn $ sudo apt install bear xclip nodejs # Required $ npm install --global tree-sitter-cli
Nerd Fonts is needed to show icons. You can choose your favorite font or find icons in the https://www.nerdfonts.com.
# Other nice fonts: Hack, Fira Code, Meslo $ mkdir -p ~/.local/share/fonts $ cd ~/.local/share/fonts && curl -fLo "JetBrains Mono NL Regular Nerd Font Complete.ttf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFontMono-Regular.ttf
Note: Don't forget to change your terminal fonts.
Optional Step. To set neovim as default editor, you can add these to ~/.bashrc or ~/.zshrc:
export VISUAL="nvim"
export EDITOR="nvim"Final Step. Run nvim and wait for the plugins to be installed.
# First time to run nvim
$ nvim
# Or Synchronize all plugins manually
$ nvim --headless "+Lazy! sync"
# Or Synchronize all plugins with specific version
$ nvim --headless "+Lazy! restore"Congratulations, now start enjoying the powerful neovim!
You can disable/enable language packs so that Lazy/Mason won't install or enable the related plugins/tools.
- Default config: edit booleans in
lua/core/features.luadirectly. - Environment (one-shot override):
NVIM_DISABLE_LANGS=go,texNVIM_ENABLE_LANGS=copilot
Installer can also skip dependency install for selected language packs:
./install.sh --disable go,tex
./install.sh --disable-go --disable-texRun nvim and type the following:
:checkhealth
You can see plugins' diagnose problems with your configuration or environment. Some optional features may not work if you don't install the required packages. But you can still use neovim without these features.
Leader key is comma(,) key. You can just press <leader> or <leader><leader> to see most keybindings.
If you want to have a better experience with tmux, you can add the following bindings to your ~/.tmux.conf.
# To enable cycle-free navigation beyond nvim
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }
bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'
# To resize the window
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1'
bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1'
bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1'
bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1'
bind-key -T copy-mode-vi M-h resize-pane -L 1
bind-key -T copy-mode-vi M-j resize-pane -D 1
bind-key -T copy-mode-vi M-k resize-pane -U 1
bind-key -T copy-mode-vi M-l resize-pane -R 1
For more detail refer to usage of tmux.nvim.
If you want to use latex, you can install texshop and VimTeX.
VimTex has been installed by default. It only will be activated when executable latexmk be detected.
You can install Tex Live with brew install --cask mactex-no-gui in MacOS.
For more detail refer to Setting Up a PDF Reader for Writing LaTeX with Vim.
# in neovim command line
:StartupTime
# or in normal mode
<leader><leader>s
# or just use vim builtin argument on terminal
$ nvim --startuptime startup.logAlternatively, you can use a Go program to measure startup time of vim. https://github.com/rhysd/vim-startuptime.
# Installation
$ go install github.com/rhysd/vim-startuptime@latest
# Usage
$ vim-startuptime -vimpath nvimKeybindings Popup
Completion
DAP Debugger




