install neovim

进入neovim下载页面neovim_downpage下载并安装对应版本(此处为win32)image.png


install Python

进入Python_Downpage下载安装Python安装时注意勾选pip一并安装
image.png


在Powershell中使用neovim

以管理员身份运行powershell并输入
Set-ExecutionPolicy RemoteSigned(按Y确定后)

new-item -path $profile -itemtype file -force
image.png

修改图示路径下对应文件 内容为

  1. set-alias vim "C:\Users\63164\nvim\Neovim\bin\nvim.exe" # 此处为vim的安装路径

重启powershell输入vim

image.png

  • **
  • **

安装配置nvim插件(vim-plug)

此次安装环境为win10 powershell 安装neovim
powershell执行下述命令

  1. md ~\AppData\Local\nvim\autoload
  2. $uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  3. (New-Object Net.WebClient).DownloadFile(
  4. $uri,
  5. $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
  6. "~\AppData\Local\nvim\autoload\plug.vim"
  7. )
  8. )

参考连接

plug.vim文件下载完成后,再创建对应路径下init.vim文件并修改

  • Windows: ~\AppData\Local\nvim\init.vim
  1. if has('win32') || has('win64')
  2. let g:plugged_home = '~/AppData/Local/nvim/plugged'
  3. else
  4. let g:plugged_home = '~/.vim/plugged'
  5. endif
  6. call plug#begin(g:plugged_home)
  7. Plug 'chriskempson/base16-vim'
  8. Plug 'vim-airline/vim-airline'
  9. Plug 'vim-airline/vim-airline-themes'
  10. Plug 'Yggdroot/indentLine'
  11. Plug 'w0rp/ale'
  12. Plug 'ncm2/ncm2'
  13. Plug 'roxma/nvim-yarp'
  14. Plug 'ncm2/ncm2-bufword'
  15. Plug 'ncm2/ncm2-path'
  16. Plug 'ncm2/ncm2-jedi'
  17. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  18. Plug 'Chiel92/vim-autoformat'
  19. call plug#end()
  20. filetype plugin indent on

进入vim,命令行模式下输入
PlugInstall
image.png
安装后如上图所示

完成后,继续配置init.vim文件(颜色,缩进,快捷键等)

  1. " Configurations Part
  2. " UI configuration
  3. syntax on
  4. syntax enable
  5. " colorscheme
  6. let base16colorspace=256
  7. colorscheme base16-gruvbox-dark-hard
  8. set background=dark
  9. " True Color Support if it's avaiable in terminal
  10. if has("termguicolors")
  11. set termguicolors
  12. endif
  13. if has("gui_running")
  14. set guicursor=n-v-c-sm:block,i-ci-ve:block,r-cr-o:blocks
  15. endif
  16. set number
  17. set relativenumber
  18. set hidden
  19. set mouse=a
  20. set noshowmode
  21. set noshowmatch
  22. set nolazyredraw
  23. " Turn off backup
  24. set nobackup
  25. set noswapfile
  26. set nowritebackup
  27. " Search configuration
  28. set ignorecase " ignore case when searching
  29. set smartcase " turn on smartcase
  30. " Tab and Indent configuration
  31. set expandtab
  32. set tabstop=4
  33. set shiftwidth=4
  34. " vim-autoformat
  35. noremap <F3> :Autoformat<CR>
  36. " NCM2
  37. augroup NCM2
  38. autocmd!
  39. " enable ncm2 for all buffers
  40. autocmd BufEnter * call ncm2#enable_for_buffer()
  41. " :help Ncm2PopupOpen for more information
  42. set completeopt=noinsert,menuone,noselect
  43. " When the <Enter> key is pressed while the popup menu is visible, it only
  44. " hides the menu. Use this mapping to close the menu and also start a new line.
  45. inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
  46. " uncomment this block if you use vimtex for LaTex
  47. " autocmd Filetype tex call ncm2#register_source({
  48. " \ 'name': 'vimtex',
  49. " \ 'priority': 8,
  50. " \ 'scope': ['tex'],
  51. " \ 'mark': 'tex',
  52. " \ 'word_pattern': '\w+',
  53. " \ 'complete_pattern': g:vimtex#re#ncm2,
  54. " \ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
  55. " \ })
  56. augroup END
  57. " Ale
  58. let g:ale_lint_on_enter = 0
  59. let g:ale_lint_on_text_changed = 'never'
  60. let g:ale_echo_msg_error_str = 'E'
  61. let g:ale_echo_msg_warning_str = 'W'
  62. let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
  63. let g:ale_linters = {'python': ['flake8']}
  64. " Airline
  65. let g:airline_left_sep = ''
  66. let g:airline_right_sep = ''
  67. let g:airline#extensions#ale#enabled = 1
  68. let airline#extensions#ale#error_symbol = 'E:'
  69. let airline#extensions#ale#warning_symbol = 'W:'

Code completion and code lint/formatting

为了完成代码,语法检查和代码格式化,我们需要以下python包

  • jedi for code completion: pip install jedi
  • flake8 for code linting: pip install flake8
  • autopep8 for code formatting: pip install autopep8

自动报错、代码格式化和自动补全全部OK 了
image.pngimage.png
fix-2.gif

参考连接@yufanlu

其它插件

tmhedberg/SimpylFold #代码折叠

scrooloose/nerdtree #目录树

majutsushi/tagbar #右侧缩略树

VIM练级手册

@温欣爸比