"文件:.config/nvim/init.vim
"--------v20201230-----------
"—注意首次运行如果出错
"—在nvim命令行:
"PlugInstall
":UpdateRemotePlugins
"----------------------------
call plug#begin(’~/.vim/plugged’)
Plug ‘scrooloose/nerdtree’
" 主题
"Plug ‘morhetz/gruvbox’
"好看的状态栏
Plug ‘vim-airline/vim-airline’
Plug ‘vim-airline/vim-airline-themes’
let g:airline#extensions#hunks#enabled = 0
" 语法检查
Plug ‘neomake/neomake’
" 括号匹配
Plug ‘jiangmiao/auto-pairs’
" 自动补全
Plug ‘neoclide/coc.nvim’, {‘branch’: ‘release’}
" 主要为vimspector提供调试模板文件列表(.vim/vimspector_json/):cpp.json python.json shell.json
" File navigation
Plug ‘junegunn/fzf’, { ‘dir’: ‘~/.fzf’, ‘do’: ‘./install --all’ }
Plug ‘junegunn/fzf.vim’
"F10键 终端 编辑/首选项/常规/(取消)启用菜单快捷键
"F11键 终端 快捷键/(取消)启用快捷键
Plug ‘puremourning/vimspector’,{‘do’:’./install_gadget.py --force-enable-rust -enable-python --enable-go --enable-bash --enable-c’}
call plug#end()
"vim 与 系统共享粘贴板
set clipboard=unnamedplus
let g:airline#extensions#hunks#enabled = 0
" 主题
"colorscheme gruvbox
"set background=dark " 或者 set background=light
" 语法检查 忽视警告
let g:neomake_python_enabled_makers = [‘pyflakes’]
call neomake#configure#automake(‘nrwi’, 500) " 自动检查
" 代码补充的键位替换
"inoremap pumvisible() ? “<c-n>” : “<tab>”
map ,q :call CompileRunGcc()
" 一键执行
func! CompileRunGcc()
exec “w”
if &filetype == ‘c’
exec ‘!g++ % -g -o %<’
exec ‘!time ./%<’
elseif &filetype == ‘cpp’
exec ‘!g++ % -g -o %<’
exec ‘!time ./%<’
elseif &filetype == ‘python’
exec ‘!python %’
elseif &filetype == ‘sh’
:!time bash %
endif
endfunc
map ,m :call Make()
func! Make()
exec “w”
exec ‘!cd %:p:h && make’
endfunc
" 键位的映射
map ,n :call ShowNumberToggle()
func! ShowNumberToggle()
if &nu
set nonu
set mouse=v
else
set nu
set mouse=a
endif
endfunc
noremap :NERDTreeToggle
noremap :q
noremap :w
inoremap :q
inoremap :w
noremap ,l :spj:term ipython i %run
set guifont=Courier/20
set foldenable " 允许折叠
set showcmd " 输入的命令显示出来,看的清楚些
set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示
" 语法高亮
set syntax=on
" 自动缩进
set autoindent
set cindent
" Tab键的宽度
set tabstop=2
set shiftwidth=2
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=1
"去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible
"设置编码
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
" 括号匹配
set showmatch
" 鼠标
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 显示行号
set number
" 高亮当前行
set cursorline
highlight CursorLine cterm=NONE ctermbg=black ctermfg=green guibg=NONE guifg=NONE
highlight CursorColumn cterm=NONE ctermbg=black ctermfg=green guibg=NONE guifg=NONE
" 设置空白字符的视觉提示
set list listchars=extends:❯,precedes:❮,tab:▸\ ,trail:˽
"autocmd vimenter * NERDTree "启动时打开插件
"退出编辑窗口就直接关闭目录树窗口
autocmd BufEnter * if 0 == len(filter(range(1, winnr(’$’)), ‘empty(getbufvar(winbufnr(v:val), “&bt”))’)) | qa! | endif
" ===
" === vimspector
" ===
let g:vimspector_enable_mappings = ‘HUMAN’
function! s:read_template_into_buffer(template)
" has to be a function to avoid the extra space fzf#run insers otherwise
execute ‘0r ~/.vim/vimspector_json/’.a:template
endfunction
command! -bang -nargs=* LoadVimSpectorJsonTemplate call fzf#run({
\ ‘source’: ‘ls -1 ~/.vim/vimspector_json’,
\ ‘down’: 20,
\ ‘sink’: function(‘read_template_into_buffer’)
\ })
" %:p:h返回当前调试源文件所在的目录
" 如果没有%:p:h时.vimspector.json会被默认存到vim/nvim启动目录
" ~$nvim test/main.cpp 没有%:p:h时则返回~/.vimspector.json 如果有 %:p:h/.vimspector.json返回~/test/.vimspector.json
noremap vs :tabe %:p:h/.vimspector.json:LoadVimSpectorJsonTemplate
sign define vimspectorBP text= texthl=Normal
sign define vimspectorBPDisabled text= texthl=Normal
sign define vimspectorPC text= texthl=SpellBad
" ===
" === youcompleteme
" ===
".ycm_extra_conf.py 是否提示加载1确认 0不需要确认
let g:ycm_confirm_extra_conf = 0
" 除/Documents/目录之外拒绝加载/目录内的.ycm_extra_conf.py文件
" 在例表前面的优先级高
let g:ycm_extra_conf_globlist = [’/Documents/*’,’!/*’]
" 跳转快捷键
nnoremap :YcmCompleter GoToDeclaration|
nnoremap :YcmCompleter GoToDefinition|
nnoremap :YcmCompleter GoToDefinitionElseDeclaration|