Skip to content

Instantly share code, notes, and snippets.

@nameoverflow nameoverflow/.vimrc
Last active Jun 18, 2019

Embed
What would you like to do?
VIMRC for neovim
call plug#begin('~/.vim/plugged')
Plug 'prabirshrestha/async.vim'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" (Optional) Multi-entry selection UI.
Plug 'junegunn/fzf'
" (Completion plugin option 1)
" Plug 'roxma/nvim-completion-manager'
" Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" Plug 'tomasr/molokai'
Plug 'sickill/vim-monokai'
" Plug 'crusoexia/vim-monokai'
Plug 'roxma/nvim-yarp'
" Plug 'roxma/vim-hug-neovim-rpc'
Plug 'vim-airline/vim-airline'
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'godlygeek/tabular'
Plug 'majutsushi/tagbar'
Plug 'leafgarland/typescript-vim' "typescript高亮
Plug 'pangloss/vim-javascript' "javascript高亮
Plug 'luochen1990/rainbow'
Plug 'ternjs/tern_for_vim'
Plug 'scrooloose/nerdcommenter'
" Plug 'zefei/vim-wintabs'
" Plug 'Valloric/YouCompleteMe'
Plug 'ludovicchabant/vim-gutentags'
Plug 'JuliaEditorSupport/julia-vim'
Plug 'ntpeters/vim-better-whitespace'
Plug 'tpope/vim-surround'
" Plug 'vim-syntastic/syntastic'
Plug 'w0rp/ale'
Plug 'bitc/vim-hdevtools'
Plug 'ncm2/ncm2'
Plug 'ncm2/float-preview.nvim'
Plug 'ncm2/ncm2-jedi'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
" Plug 'davidhalter/jedi-vim'
" if has('nvim')
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" else
" Plug 'Shougo/deoplete.nvim'
" Plug 'roxma/nvim-yarp'
" Plug 'roxma/vim-hug-neovim-rpc'
" endif
" Plug 'deoplete-plugins/deoplete-jedi'
call plug#end()
let mapleader=","
if !exists("g:syntax_on")
syntax enable
endif
let g:deoplete#enable_at_startup = 1
" hi Normal ctermbg=none
" colorscheme molokai
colorscheme monokai
" set guifont=Operator\ Mono\ for\ Powerline\ 13
set guifont=Fira\ Code\ 13
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
map <C-H> :bnext<CR>
map <C-L> :bprev<CR>
se cul
" 用浅色高亮当前行
set smartindent
" 智能对齐
set autoindent
" 自动对齐
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set shiftround
" 统一缩进为4
set clipboard=unnamedplus
set number
" 显示行号
set history=50
" 历史纪录数
set hlsearch
set incsearch
" 搜索逐字符高亮
set gdefault
" 行内替换
set encoding=utf-8
set fileencodings=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936,utf-16,big5,euc-jp,latin1
" 编码设置
set langmenu=zn_CN.UTF-8
set helplang=cn
" 语言设置
set cmdheight=1
" 命令行(在状态行)的高度,默认为1,这里是2
set ruler
" 在编辑过程中,在右下角显示光标位置的状态行
set laststatus=2
" 总是显示状态行
set showcmd
" 在状态行显示目前所执行的命令,未完成的指令片段亦会显示出来
set scrolloff=3
" 光标移动到buffer的顶部和底部时保持3行距离
set showmatch
" 高亮显示对应的括号
set matchtime=5
" 对应括号高亮的时间(单位是十分之一秒)
set autowrite
" 在切换buffer时自动保存当前文件
set wildmenu
" 增强模式中的命令行自动完成操作
set linespace=0
" 字符间插入的像素行数目
set foldmethod=indent
set nofoldenable
set autochdir
let g:python_host_prog = '/new_home/hcy/miniconda3/envs/nvim2/bin/python'
let g:python3_host_prog = '/new_home/hcy/miniconda3/envs/nvim/bin/python'
set completeopt=noinsert,menuone,noselect
autocmd BufEnter * call ncm2#enable_for_buffer()
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
let g:jedi#completions_enabled = 0
" gutentags 搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归
let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project']
" 所生成的数据文件的名称
let g:gutentags_ctags_tagfile = '.tags'
" 同时开启 ctags 和 gtags 支持:
let g:gutentags_modules = []
if executable('ctags')
let g:gutentags_modules += ['ctags']
endif
if executable('gtags-cscope') && executable('gtags')
let g:gutentags_modules += ['gtags_cscope']
endif
" 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录
let s:vim_tags = expand('~/.cache/tags')
let g:gutentags_cache_dir = s:vim_tags
" 配置 ctags 的参数
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" 检测 ~/.cache/tags 不存在就新建
if !isdirectory(s:vim_tags)
silent! call mkdir(s:vim_tags, 'p')
endif
let g:gutentags_ctags_executable = 'ctags'
" NERD tree
let NERDChristmasTree=0
let NERDTreeWinSize=20
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos="right"
" Automatically open a NERDTree if no files where specified
" autocmd vimenter * if !argc() | NERDTree | endif
" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Open a NERDTree
nmap <leader>n :NERDTreeToggle<CR>
" Tagbar
let g:tagbar_width=20
let g:tagbar_autofocus=1
let g:tagbar_left = 1
" nmap <F6> :TagbarToggle<CR>
nnoremap <leader>t :TagbarToggle<CR>
let g:tagbar_ctags_bin = 'ctags'
let g:tagbar_type_typescript = {
\ 'ctagsbin' : 'tstags',
\ 'ctagsargs' : '-f-',
\ 'kinds': [
\ 'e:enums:0:1',
\ 'f:function:0:1',
\ 't:typealias:0:1',
\ 'M:Module:0:1',
\ 'I:import:0:1',
\ 'i:interface:0:1',
\ 'C:class:0:1',
\ 'm:method:0:1',
\ 'p:property:0:1',
\ 'v:variable:0:1',
\ 'c:const:0:1',
\ ],
\ 'sort' : 0
\ }
" ctrlp
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.png,*.jpg,*.jpeg,*.gif " MacOSX/Linux
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files.
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" Ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" tabular
" nnoremap <leader>t :Tab/
" vnoremap <leader>t :Tab/
"open rainbow
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
" LanguageClient
" Required for operations modifying multiple buffers like rename.
set hidden
let g:LanguageClient_serverCommands = {
\ 'rust': ['rustup', 'run', 'nightly', 'rls'],
\ 'haskell': ['hie', '--lsp'],
\ 'javascript': ['javascript-typescript-stdio'],
\ 'javascript.jsx': ['javascript-typescript-stdio'],
\ 'python': ['~/miniconda3/envs/nvim/bin/pyls'],
\ }
let g:LanguageClient_diagnosticsEnable = 1
nnoremap <silent> <Leader>lh :call LanguageClient_textDocument_hover()<CR>
nnoremap <silent> <Leader>jd :call LanguageClient_textDocument_definition()<CR>
nnoremap <silent> <Leader>ln :call LanguageClient_textDocument_rename()<CR>
nnoremap <silent> <Leader>lf :call LanguageClient_textDocument_formatting()<CR>
" NerdCommenter
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" 保存时去除多余空格
let g:strip_whitespace_on_save = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.