background

It has been seven years since I started using Vim in 2013. Finally, I began to feel that VIm was too much to watch, so I turned to Neovim. (HAH, is that too long?) All configuration files can be viewed on Github.

The installation

The installationneovim

This article deals only with Linux installations.

Since the neovim version of the repository can be quite different from the latest version, I chose to download and install it manually. Enter the release page of neovim official website. Then download the version you need. Here, NVIM 0.4.3 is used as an example.

  1. Download nvim. Appimage

  2. Add executable permission:

chmod u+x nvim.appimage
Copy the code
  1. In the/usr/bindirectory
sudo mv nvim.appimage /usr/bin/nvim
Copy the code

Then Nvim is up and running.

configuration

By the way, the configuration file location for Neovim is ~/.config/nvim/init.vim

Plug-in management

Here we use vim-plug for plug-in management by default, if you don’t know, you can go to the official website for more information. Vim /autoload/plug.vim = ~/.vim/autoload

curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Copy the code

The link above may not be accessible in China. If you do not have a ladder, you can run the following sentence:

curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
    https://gitee.com/c4pr1c3/vim-plug/raw/master/plug.vim
Copy the code

Automatic completion

1. Installcoc.vim

Coc.vim is an intelligent prompt engine made for Neovim/ VIM8. To learn more, check out the official Wiki.

Coc.vim relies on Node, so we’ll install Node first:

sudo apt install node
Copy the code

Installing coc.vim is as simple as installing the other plugins, added in neovim configuration ~/.config/nvim/init.vim

Plug 'neoclide/coc.nvim', {'branch': 'release'}
Copy the code

And then open up a new Nvim and run it

:PlugInstall
Copy the code

Wait until the installation is complete and restart vim.

2. InstallPythonsupport

You need to install the Python module of Neovim first

pip install neovim
Copy the code

Next install language support:

:CocInstall coc-python
Copy the code

3. Install quick code generation plug-ins

:CocInstall coc-snippets
Copy the code

3. Install bookmarks

Official tutorial check out coc- Bookmark

:CocInstall coc-bookmark
Copy the code

search

Rely on ripgrep

Install deb, go to the official release page to download the package, and then unpack it.

Sudo DPKG -i ripgrep_11. 0.2 _amd64. DebCopy the code

To search, execute in the text:

:CocSearch -w[words]Copy the code

The color plug-in

Here we use the gruvbox plugin for our color scheme.

Vim configuration:

Plug 'morhetz/gruvbox'

colorshceme gruvbox     "Enable the Gruvbox color scheme
Copy the code

Window control

  • <ctrl-L>Switch to the right window
  • <ctrl-H>Switch to the left window
  • <ctrl-J>Switch to the lower window
  • <ctrl-K>Switch to the upper window
  • <ctrl-/>Switch to the previous window

In the configuration file:

Plug 'christoomey/vim-tmux-navigator'
Copy the code

Then :PlugInstall.

File browsing

Use the old NERDTree

Plug 'preservim/nerdtree'
Copy the code

configuration

" NERDTree settings            
                             
" open a NERDTree automatically when vim starts up if no files were specified    
autocmd StdinReadPre * let s:std_in=1    
autocmd VimEnter * if argc() = =0 && !exists("s:std_in") | NERDTree | endif    
                             
" open NERDTree automatically when vim starts up on opening a directory    
autocmd StdinReadPre * let s:std_in=1    
autocmd VimEnter * if argc() = =1 && isdirectory(argv(to)0]) && !exists("s:std_in") | exe 'NERDTree' argv(to)0] | wincmd p | ene | exe 'cd '.argv(to)0] | endif

" map a specific key or shortcut to open NERDTree
map <C-n> :NERDTreeToggle<CR>

" close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") = =1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

" Let NERDTree igonre files
let NERDTreeIgnore = ['\.pyc$'.'\.swp$']
  
Copy the code

Beautify the status bar

The status bar uses the plug-in vim-airline, which interconnects with coc.vim.

Plug 'vim-airline/vim-airline'
let g:airline_theme='badwolf'  "You can customize the theme, using Badwolf
Copy the code

Effect diagram (there can be error number in the lower right corner of the program when there is error E:1) :

Add emoji ICONS

Use the plug-in vim-Devicons

You can refer to the tutorial for installation

Plug 'ryanoasis/vim-devicons'
Copy the code

Nerd font needs to be installed after installation. These fonts are patch fonts with ICONS added. ICONS can be displayed normally only after installation. Go to the font download list and select the font you like to install. The finished interface looks something like this:

Comments plugin

nerdcommenter

Plug 'preservim/nerdcommenter' 
Copy the code

Configuration: Use < CTRL -/> to comment and uncomment code.

nmap <C-_>   <Plug>NERDCommenterToggle
vmap <C-_>   <Plug>NERDCommenterToggle<CR>gv
Copy the code

Automatically generate Python function/class documentation

vim-doge

Plug 'kkoomen/vim-doge'
Copy the code

Configuration:

"let g:doge_doc_standard_python = 'numpy'
"let g:doge_doc_standard_python = 'google'
let g:doge_doc_standard_python = 'reST'
Copy the code

Fast alignment

vim-easy-align

Plug 'junegunn/vim-easy-align'
Copy the code

Configuration:

" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)

" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
Copy the code

Rainbow brackets

vim-rainbow

Plug 'luochen1990/rainbow'
let g:rainbow_active = 1 
Copy the code