这篇文章上次修改于 2118 天前,可能其部分内容已经发生变化,如有疑问可询问作者。
受够了YouCompleteMe每次插件升级就得重新编译的痛苦,决定试试传说中的新贵neovim
Ubuntu/Mint
https://launchpad.net/~neovim-ppa/+archive/ubuntu/stable (Xenial 16.04 or newer only).
https://launchpad.net/~neovim-ppa/+archive/ubuntu/unstable
To be able to use add-apt-repository you may need to install software-properties-common:
sudo apt-get install software-properties-common
If you’re using an older version Ubuntu you must use:
sudo apt-get install python-software-properties
Run the following commands:
sudo add-apt-repository ppa:neovim-ppa/stable
sudo apt-get update
sudo apt-get install neovim
让neovim成为默认首选编辑器
sudo update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60
sudo update-alternatives --config vi
sudo update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60
sudo update-alternatives --config vim
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 60
sudo update-alternatives --config editor
nvim的默认配置文件路径
The Nvim config file is named “init.vim”, located at:
Unix ~/.config/nvim/init.vim
Windows ~/AppData/Local/nvim/init.vim
Or if |$XDG_CONFIG_HOME| is defined:
$XDG_CONFIG_HOME/nvim/init.vim
The $XDG_CONFIG_HOME
and $XDG_DATA_HOME
environment variables are used if they
exist, otherwise default values (listed below) are used.
CONFIG DIRECTORY (DEFAULT)
*$XDG_CONFIG_HOME* Nvim: stdpath("config")
Unix: ~/.config ~/.config/nvim
Windows: ~/AppData/Local ~/AppData/Local/nvim
DATA DIRECTORY (DEFAULT)
*$XDG_DATA_HOME* Nvim: stdpath("data")
Unix: ~/.local/share ~/.local/share/nvim
Windows: ~/AppData/Local ~/AppData/Local/nvim-data
$NVIM_LOG_FILE
Usually the file is ~/.local/share/nvim/log unless that path is inaccessible or if $NVIM_LOG_FILE was set before |startup|.
总的来说,你从vim切换到neovim会如丝般顺滑,基本没什么不同.
对于使用了pyenv或者goenv以及npm的同志来说,自动识别更让人惊喜.
安装plug.vim来管理插件
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
编辑~/.config/nvim/init.vim
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }
" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'
" Initialize plugin system
call plug#end()
以上是例子,具体要装哪些插件根据自己需求决定.
附上我的插件列表:
Finished. 0 error(s).
[========================] ~
~
- git-blame.vim: OK ~
- coc.nvim: OK ~
- neosnippet.vim: OK ~
- pangu.vim: OK ~
- vim-css-color: OK ~
- nerdtree: OK ~
- nerdtree-git-plugin: OK ~
- vim-template: OK ~
- vim-terraform: OK ~
- vim-misc: OK ~
- vim-go: OK (not loaded) ~
- vim-gitgutter: OK ~
- molokai: OK ~
- tabular: OK ~
- neoterm: OK ~
- vim-vue: OK ~
- neosnippet-snippets: OK ~
- nerdcommenter: OK ~
- tagbar: OK ~
- vim-easymotion: OK ~
- ctrlsf.vim: OK ~
- ctrlp.vim: OK ~
- vim-easytags: OK ~
- vim-markdown: OK
上张效果图
福利就附一篇网友写的vim手册:
https://www.dreamxu.com/books/vim/
https://www.zhihu.com/question/23590572
没有评论