install neovim
进入neovim下载页面neovim_downpage下载并安装对应版本(此处为win32)
install Python
进入Python_Downpage下载安装Python安装时注意勾选pip一并安装
在Powershell中使用neovim
以管理员身份运行powershell并输入
Set-ExecutionPolicy RemoteSigned(按Y确定后)
new-item -path $profile -itemtype file -force
修改图示路径下对应文件 内容为
set-alias vim "C:\Users\63164\nvim\Neovim\bin\nvim.exe" # 此处为vim的安装路径
重启powershell输入vim
- **
- **
安装配置nvim插件(vim-plug)
此次安装环境为win10 powershell 安装neovim
powershell执行下述命令
md ~\AppData\Local\nvim\autoload
$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(New-Object Net.WebClient).DownloadFile(
$uri,
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
"~\AppData\Local\nvim\autoload\plug.vim"
)
)
plug.vim文件下载完成后,再创建对应路径下init.vim文件并修改
- Windows:
~\AppData\Local\nvim\init.vim
if has('win32') || has('win64')
let g:plugged_home = '~/AppData/Local/nvim/plugged'
else
let g:plugged_home = '~/.vim/plugged'
endif
call plug#begin(g:plugged_home)
Plug 'chriskempson/base16-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'Yggdroot/indentLine'
Plug 'w0rp/ale'
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-jedi'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Chiel92/vim-autoformat'
call plug#end()
filetype plugin indent on
进入vim,命令行模式下输入PlugInstall
安装后如上图所示
完成后,继续配置init.vim文件(颜色,缩进,快捷键等)
" Configurations Part
" UI configuration
syntax on
syntax enable
" colorscheme
let base16colorspace=256
colorscheme base16-gruvbox-dark-hard
set background=dark
" True Color Support if it's avaiable in terminal
if has("termguicolors")
set termguicolors
endif
if has("gui_running")
set guicursor=n-v-c-sm:block,i-ci-ve:block,r-cr-o:blocks
endif
set number
set relativenumber
set hidden
set mouse=a
set noshowmode
set noshowmatch
set nolazyredraw
" Turn off backup
set nobackup
set noswapfile
set nowritebackup
" Search configuration
set ignorecase " ignore case when searching
set smartcase " turn on smartcase
" Tab and Indent configuration
set expandtab
set tabstop=4
set shiftwidth=4
" vim-autoformat
noremap <F3> :Autoformat<CR>
" NCM2
augroup NCM2
autocmd!
" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()
" :help Ncm2PopupOpen for more information
set completeopt=noinsert,menuone,noselect
" When the <Enter> key is pressed while the popup menu is visible, it only
" hides the menu. Use this mapping to close the menu and also start a new line.
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
" uncomment this block if you use vimtex for LaTex
" autocmd Filetype tex call ncm2#register_source({
" \ 'name': 'vimtex',
" \ 'priority': 8,
" \ 'scope': ['tex'],
" \ 'mark': 'tex',
" \ 'word_pattern': '\w+',
" \ 'complete_pattern': g:vimtex#re#ncm2,
" \ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
" \ })
augroup END
" Ale
let g:ale_lint_on_enter = 0
let g:ale_lint_on_text_changed = 'never'
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_linters = {'python': ['flake8']}
" Airline
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline#extensions#ale#enabled = 1
let airline#extensions#ale#error_symbol = 'E:'
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 了
参考连接@yufanlu