完美切换到neovim


#1

事实证明neovim现在已经可以完美稳定使用了,这两天切换到了neovim并折腾了一下配置,感觉灰常好 :v:
贴下配置顺便:

call plug#begin('~/.local/share/nvim/plugged')
Plug 'Valloric/YouCompleteMe'
Plug 'rdnetto/YCM-Generator'
Plug 'SirVer/ultisnips'
Plug 'YanhaoMo/vim-snippets'
Plug 'scrooloose/syntastic'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'scrooloose/nerdcommenter'
Plug 'jiangmiao/auto-pairs'
Plug 'sickill/vim-monokai'
Plug 'vim-airline/vim-airline'
Plug 'scrooloose/nerdtree'
Plug 'majutsushi/tagbar'
Plug 'kien/rainbow_parentheses.vim'
Plug 'vim-scripts/mru.vim'
Plug 'Shougo/unite.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

Plug 'ryanss/vim-hackernews'
Plug 'Lokaltog/vim-easymotion'
Plug 'junegunn/vim-easy-align'
Plug 'tpope/vim-surround'
Plug 'terryma/vim-multiple-cursors'
Plug 'mattn/emmet-vim'

"Plug 'fatih/vim-go'
"Plug 'neovimhaskell/haskell-vim'
"Plug 'artur-shaik/vim-javacomplete2'
"Plug 'vimwiki/vimwiki'

"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"Plug 'Shougo/denite.nvim'
call plug#end()

syntax on                                                       "语法高亮支持
set nu                                                          "显示行号
set rnu                                                         "显示相对行号
set wrap                                                        "当一行文字很长时换行
set showmatch                                                   "当光标移动到一个括号时会高亮显示对应的另一个括号
set laststatus=2                                                "总是显示状态行
set ruler                                                       "在编辑过程中右下角显示光标的行列信息
set shortmess=atI                                               "启动时不显示捐助乌干达儿童的提示
set showcmd                                                     "回显输入的命令
set showmode                                                    "显示当前的模式
set clipboard+=unnamed                                          "关联系统的剪贴板
set so=6                                                        "上下滚行时空余6行
set autoindent                                                  "自动套用上一行的缩进方式
set smartindent                                                 "智能缩进
set mouse=a                                                     "开启鼠标支持
set backspace=indent,eol,start                                  "对退格键提供更好的支持
set sts=4                                                       "设置制表符宽度
set shiftwidth=4                                                "设置缩进空格数
set ts=4                                                        "设置tab长度为4
set expandtab                                                   "用空格代替tab键
set smarttab                                                    "更加智能的tab键
set hid                                                         "当buffer被丢弃时隐藏它
set fileencodings=utf-8,cp936,gb18030,big5,euc-kr,latin1        "自动判断编码时 依次尝试一下编码
set ffs=unix,dos,mac                                            "设置文件类型
set hlsearch                                                    "高亮搜索内容
set ignorecase                                                  "搜索模式里忽略大小写
set incsearch                                                   "显示搜索的动态匹配效果
set smartcase                                                   "如果搜索字符串里包含大写字母,则禁用 ignorecase
set splitright                                                  "默认右侧打开新buffer
set lazyredraw                                                  "解决某些类型的文件由于syntax导致vim反应过慢的问题
set cc=130                                                      "在130列的地方显示一道警戒线
set foldmethod=indent                                           "折叠方式
set nofoldenable                                                "不自动折叠
set completeopt-=preview                                        "不显示预览窗口
set t_Co=256                                                    "设置256真彩色
set list lcs=tab:\┊\ ,trail:•                                   "显示tab键为┊,并且显示每行结尾的空格为'•',一些备用字符:›┆┇┊┋♠♦•
set cursorline                                                  "突出显示当前行
colorscheme monokai                                             "设置主题外观
"set cursorcolumn                                                "突出显示当前列
"set foldcolumn=1                                                "在行号前空出一列的宽度
"set nowrap                                                      "当一行文字很长时取消换行
"set history=100                                                 "设置历史记录条数
"set autoread                                                    "当文件在外部被修改时自动载入
"set cindent                                                     "使用c语言的缩进格式
"set whichwrap+=<,>,h,l                                          "允许backspace和光标键跨越行边界
"set cmdheight=2                                                 "显示两行命令行
"set nobackup                                                    "不进行备份
"set nowb                                                        "重新载入文件时不要备份
"set noswapfile                                                  "不使用swf文件,可能导致错误无法恢复

"关闭错误声音
set noerrorbells
set novisualbell
set  t_vb=

"打开一个文件自动定位到上一次退出的位置
if has("autocmd")
    au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
"保存.vim文件后不用退出即可生效
"au! bufwritepost .vimrc source %

"修改<leader>的键盘映射
nmap , <leader>
"当按下\+Enter时取消搜索高亮
map <silent> <leader><CR> :noh<CR>
"将Esc键映射到jj
im jj <Esc>
im JJ <Esc>
"visual模式下快速对齐
vnoremap < <gv
vnoremap > >gv
"设置以空格打开和关闭折叠
nmap <space> @=((foldclosed(line('.'))<0)?'zc':'zo')<CR>
"当一行很长时把分开的段行当作一行来移动
map j gj
map k gk
"quickfix相关的一些快捷键
map cn :cn<CR>
map cp :cp<CR>
map co :lopen<CR>
map cl :lclose<CR>
"辅助设置文件类型
map <leader>l :setfiletype 
"更方便的窗口间跳转
map <leader>j <c-w>j
map <leader>k <c-w>k
map <leader>l <c-w>l
map <leader>h <c-w>h
"更方便的页滚动
map <C-j> <C-f>
map <C-k> <C-b>
"更方便的前进和后退
nmap go <C-]>
nmap bk <C-t>


let g:airline_powerline_fonts = 1
let g:deoplete#enable_at_startup = 1
let g:UltiSnipsEditSplit = "vertical"
let g:UltiSnipsSnippetDirectories = "~/.local/share/nvim/plugged/vim-snippets/snippets", "~/.local/share/nvim/plugged/vim-snippets/UltiSnips"]

"rainbow_parentheses插件配置
let g:rbpt_colorpairs = 
            \ 'brown',       'RoyalBlue3'],
            \ 'Darkblue',    'SeaGreen3'],
            \ 'darkgray',    'DarkOrchid3'],
            \ 'darkgreen',   'firebrick3'],
            \ 'darkcyan',    'RoyalBlue3'],
            \ 'darkred',     'SeaGreen3'],
            \ 'darkmagenta', 'DarkOrchid3'],
            \ 'brown',       'firebrick3'],
            \ 'gray',        'RoyalBlue3'],
            \ 'black',       'SeaGreen3'],
            \ 'darkred',     'DarkOrchid3'],
            \ 'darkmagenta', 'DarkOrchid3'],
            \ 'Darkblue',    'firebrick3'],
            \ 'darkgreen',   'RoyalBlue3'],
            \ 'darkcyan',    'SeaGreen3'],
            \ 'red',         'firebrick3'],
            \ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces

"NERDTree插件配置
let NERDTreeChDirMode=2                                         "设置当前目录为nerdtree的起始目录
let NERDChristmasTree=1                                         "使得窗口有更好看的效果
let NERDTreeMouseMode=1                                         "双击鼠标左键打开文件
let NERDTreeWinSize=35                                          "设置窗口宽度为20
let NERDTreeQuitOnOpen=1                                        "打开一个文件时nerdtree分栏自动关闭
let NERDTreeShowBookmarks=1                                     "默认显示书签
map <leader>f :NERDTreeToggle<CR>

"syntastic插件配置
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_check_on_open = 1
let g:syntastic_aggregate_errors = 1
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 2
let g:syntastic_enable_highlighting = 0
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚡'
let g:syntastic_c_checkers = 'clang_check']
let g:syntastic_cpp_checkers = 'clang_check']
map ,,c :SyntasticCheck<CR>

"mru插件配置
let MRU_Auto_Close = 1
let MRU_Max_Entries = 40
map <Leader>r :MRU<CR>

"Unite插件配置
map <Leader>b :Unite -winheight=10 buffer<CR>

"Tagbar插件配置
let g:tagbar_autoclose=1
map <leader>t :TagbarToggle<CR>

"FZF
map <leader>s :FZF ~/

使用了vim-plug这个插件~


#2

以前,也是vim真爱粉,但后来伤透了心:sob:


#3

为啥,vim挺好用的啊


#4

感觉neovim并没有比vim方便很多的地方,也许是用vim已经用习惯了,不愿意去尝试些新东西了。


(Rickywu) #5

我用Denite为什么乱码呢,不知道你们有么有这个问题


#6

哪儿乱码,试试这个配置

set fileencodings=utf-8,cp936,gb18030,big5,euc-kr,latin1 

(Rickywu) #7

Windows 10, Vim 8, Python 3
Denite file_rec返回的路径和文件名显示不正确
试过set fileencodings=utf-8,cp936,gb18030,big5,euc-kr,latin1 还是一样的


#8

window下vim没用过,file_rec的话我用的是一个叫mru的插件。


(zhcosin) #9

啥时候支持 elisp 了才是真的完美了。


#10

支持python就足够了其实