起因
开始在windows下使用官网程序安装得到的vim不支持python(UltiSnips插件需要使用python)。在网上查找解决方案时看到了这个软件。该软件可以与VIM兼容操作和插件,并且python支持问题可以很好解决,因此在windows下面使用这个。特此整理安装使用过程。
安装
参考github上的相应介绍即可
配置
首先将解压后的NeoVim\bin
路径加入到PATH当中。
python支持
首先需要安装pynvim, neovim库
pip install pynvim neovim
然后需要在neovim的配置文件init.vim
中加入这一句
let g:python3_host_prog='f:\anaconda3\python.exe'
用于指定python可执行文件的位置。
查看帮助文件
在nvim中,通过执行:help {subject}
可以查看对应的帮助文件,需要注意,如果出现E149错误,一般是由于VIM,VIMRUNTIME环境变量没有设置,只需要将对应的环境变量设置好即可。
在nvim中,也需要设置VIM和VIMRUNTIME,设置方式与vim一致
let $VIM='d:\2-software\Neovim\share\nvim\'
let $VIMRUNTIME='d:\2-software\Neovim\share\nvim\runtime\'
检查
运行:checkhealth
来判断问题。
配置
配置文件位置可以通过:help vimrc
来查看,对于windows:
Windows ~/AppData/Local/nvim/init.vim
配置文件可以大部分使用vim的配置文件。附录是我目前使用的配置文件
最大化方式打开
想要在打开时最大化,需要增加ginit.vim
配置文件,并在其中加上
call GuiWindowMaximized(1)
不过会出现闪烁的情况
FAQ
主要参考官方文档
配置文件
let $VIM='d:\2-software\Neovim\share\nvim\'
let $VIMRUNTIME='d:\2-software\Neovim\share\nvim\runtime\'
set runtimepath^=$HOME/.vim runtimepath+=$HOME/.vim/after
let &packpath = &runtimepath
"source $HOME/_vimrc
let g:python3_host_prog='f:\anaconda\python.exe'
set nocompatible
" vundle
filetype off " required
"" set the runtime path to include Vundle and initialize
set rtp+=$HOME/.vim/bundle/Vundle.vim
call vundle#begin('$HOME/.vim/bundle/')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'sirver/ultisnips'
Plugin 'scrooloose/nerdcommenter'
Plugin 'jiangmiao/auto-pairs'
Plugin 'itchyny/lightline.vim'
Plugin 'honza/vim-snippets'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
call GuiWindowMaximized(1)
"source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim
let $LANG = 'en'
set langmenu=en
set laststatus=2
let g:lightline = { 'colorscheme': 'powerline', }
syntax on
set nu
set relativenumber
set nowrap
set shiftwidth=4
set tabstop=4
set expandtab
set ai
set si
set hlsearch
set showmatch
set foldenable
set noswf
set wildmenu
set ruler
set showcmd
set mouse=a
map - $
map <space> /
filetype plugin indent on
set background=dark
"set background=light
"colorscheme solarized
colorscheme molokai
let g:molokai_original =1
set nobackup
let mapleader = ","
map <leader>c "+y
map <leader>v <Esc>o<Esc>"+p
"font
"set guifont=Bitstream_Vera_Sans_Mono:h12:cANSI
GuiFont Consolas:h14
" you can change the font size by ctrl + mouse scroll
let s:fontsize = 12
function! AdjustFontSize(amount)
let s:fontsize = s:fontsize+a:amount
:execute "GuiFont! Consolas:h" . s:fontsize
endfunction
noremap <C-ScrollWheelUp> :call AdjustFontSize(1)<CR>
noremap <C-ScrollWheelDown> :call AdjustFontSize(-1)<CR>
inoremap <C-ScrollWheelUp> <Esc>:call AdjustFontSize(1)<CR>a
inoremap <C-ScrollWheelDown> <Esc>:call AdjustFontSize(-1)<CR>a
" after textwidth columes, the line will be break into another line
autocmd FileType * setlocal textwidth=130 formatoptions=tmM
autocmd FileType c,cpp,fortran setlocal textwidth=130 formatoptions=tcrmM
set fileencodings=utf-8,gbk,gb2312,big5,cp936
set encoding=utf-8
"for vim-markdown
let g:vim_markdown_folding_disabled=1
let g:vim_markdown_no_default_key_mappings=1
let g:vim_markdown_math=1
" for UltiSnips
let g:UltiSnipsSnippetDirectories=['UltiSnips']
let g:UltiSnipsSnippetsDir='c:\User\cq\.vim\UltiSnips'
let g:UltiSnipsExpandTrigger='<C-j>'
let g:UltiSnipsListSnippets='jj'
let g:UltiSnipsJumpForwardTrigger='<C-j>'
let g:UltiSnipsJumpBackwardTrigger='<C-k>'
欢迎关注