I wrote two previous articles about the benefits of using NeoVim and basic NeoVim instructions. In this article I will guide you to install plugins and setup to turn NeoVim into your own IDEs.
Vim-plug
I use vim-plug as a plugin manager, NeoVim or Vim can use it. I recommend using NeoVim, the reason is because NeoVim is a refactor of Vim with 30% less code, better support for plugins integration. Setting:
1 2 3 | <span class="token function">curl</span> -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
Create a folder to store NeoVim’s config file at ~ / .config / nvim / init.vim
1 2 3 | <span class="token function">cd</span> ~/.config <span class="token operator">&&</span> <span class="token function">mkdir</span> nvim <span class="token function">cd</span> nvim <span class="token operator">&&</span> <span class="token function">touch</span> init.vim |
NeoVim will read this init.vim file by default when it boots up. Like when you code C / C ++ will want to have a file containing main () function, in NeoVim you can create many of your configs files outside and then source (include in C / C ++) into this init.vim file. .
I temporarily designed the nvim directory like this: In the directory tree above, only the configs folder, my_settings are created by me, the rest of the session , bundle , autoload folders are vim-plug created to manage packages. In this article, you just need to create configs folder and setup plugin.
The configs folder has not all the vim installation files. I want to separate these configs to make it easier to install and setup later. In the init.vimm file, I will run a script that reads all of these configs and loads them.
- 01 plugins.vim: manage the plugins
- 02.settings.vim: manage neovim’s settings
- 03.plugin-settings.vim: manage settings of plugins.
1 2 3 4 5 | // thêm script này vào file init.vim for f in split(glob('~/.config/nvim/configs/*.vim'), 'n') exe 'source' f endfor |
Prefix 01. * to indicate the priority of the script when loaded. Plugins need to be loaded first, then the settings of neovim other settings are last loaded.
Setting
Plugins
I will take 2 plugins to make an example that is nerdtree (folder / file manager) and gruvbox (theme of neovim like I’m using). In the file 01.plugins.vim you add the following script:
1 2 3 4 5 6 | call plug#begin('~/.config/nvim/bundle') // tất cả các plugin phải nằm giữa hai hàm này plug#begin và plug#end Plug 'scrooloose/nerdtree' // trình quản lý file giống như trong hình của mình Plug 'morhetz/gruvbox' // theme giống như trong hình của mình luôn :)) call plug#end() |
There are many plugins you can search here
After adding, the steps you have to do are:: w to save it later : so% to reload configs later : PlugInstall to install Plugins
When you install any plugins, you should go to the plugin’s homepage (most are github) to see the user manual and do you need to install anything. Because most of the plugins installed need to be installed to work.
If you feel the plugin makes sense to you, then don’t hesitate a star for that project to encourage the author
For example, I just installed the nerdtree plugin (the folder / file manager) then I went to the nerdtree’s github page to see the docs
Settings
File 02.settings.vim will contain NeoVim’s general settings, global in nature and less likely to change over time. Some basic settings in the file 02.settings.vim:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | let mapleader = "<Space>" // prefix key dùng để trigger các function hay event filetype plugin on filetype plugin indent on autocmd BufEnter * :set scroll=10 // set croll line syntax on set encoding=UTF-8 set mouse=a // enable mouse trong context của neovim set incsearch set hlsearch // hightlight text khi search set tabstop=4 // space mỗi lần tab set softtabstop=0 set shiftwidth=4 |
Plugins Setting
The file 03.plugins-setting.vim will contain the plugin’s settings. I have just installed 2 plugins, nerdtree and gruvbox, now I start config as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | "NERDTree map <C-b> :NERDTreeToggle<CR> map <C-i> :NERDTreeFind<CR> let g:NERDTreePatternMatchHighlightFullName = 1 let NERDTreeAutoDeleteBuffer = 1 let NERDTreeMinimalUI = 1 let NERDTreeDirArrows = 1 let g:NERDDefaultAlign = 'left' let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } } let g:NERDTreeChDirMode=2 let g:NERDTreeIgnore=['.rbc$', '~$', '.pyc$', '.db$', '.sqlite$', '__pycache__', 'node_modules'] let g:NERDTreeShowBookmarks=1 "Theme syntax enable set background=dark highlight Normal ctermbg=None colorscheme gruvbox let g:airline_theme='gruvbox' set termguicolors |
Copy the settings I created and pasted into your plugins-settings file. : w to save,: so% to reload the setting and you will see the theme of neovim has changed. Check if NerdTree’s settings have been eaten by pressing Ctrl + b to toggle nerdtree.
Conclude
I would like to stop here, this article I just want you to know how to install 1 plugin neovim, how to install neovim. Have you tried the installation if you have any questions or difficulties, please comment.
Register and follow me, the next article I will summarize the required plugins and how to set up for you to code in any language.