呕心沥血,终于配好了vim,虽然也配了YouComplete,但是没有效果,也不知道为什么~,心力交瘁 不搞了,裸着吧~
踩了个大坑,脑子抽了把vim自带的python3.5卸载了,就是手贱,明明有帖子说不要删不要删,我还是不信这个邪~ 欸~就没有我搞不砸的事
下面记录一下吧,以后也用得到!!!
踩坑注意:
vim8.0
gcc g++ 要支持c++17 我用的gcc-8,g++-8
python要>=3.6
clang>=8
还有啥要注意的呢~
plugin 和plug Install的时候经常fatal ,不要百度啦,找个网好的地方多试几次。但是plug要注意,尽量不要多个插件一起install ,不用问~一定会失败!!!!
然后就各种百度教程吧~~~~~我也看了好多教程,从来没有一个教程能一下子搞定!!!!
ale 之前要安装linter, c/c++就选clang拉,但是clang又不好安装,千万别学人家下各种包 然后自己编译~一般小白都会失败(就是我),我是找了个链接命令下的。但是由于我配置的时候乱七八糟的,然后我就忘了存这些链接!! 好想骂自己这个渣渣
配置ale还要有ale-airline ,不然会没有状态栏
我的界面就长这样了
反正可能有些没用的配置,我又不会改,就这样吧~
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'Yggdroot/LeaderF'
Plugin 'dense-analysis/ale'
Plugin 'kana/vim-textobj-user'
Plugin 'kana/vim-textobj-indent'
Plugin 'kana/vim-textobj-syntax'
Plugin 'kana/vim-textobj-function', { 'for':['c', 'cpp', 'vim', 'java'] }
Plugin 'majutsushi/tagbar'
" Multiple Plug commands can be written in a single line using | separators
Plugin 'SirVer/ultisnips' | Plugin 'honza/vim-snippets'
Plugin 'vim-scripts/a.vim'
" Any valid git URL is allowed
Plugin 'https://github.com/junegunn/vim-github-dashboard.git'
Plugin 'mhinz/vim-signify'
Plugin 'Yggdroot/indentLine'
Plugin 'sgur/vim-textobj-parameter'
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plugin 'justinmk/vim-dirvish'
Plugin 'Shougo/echodoc.vim'
Plugin 'vim-airline/vim-airline-themes'
call vundle#end() " required
filetype plugin indent on " required
call plug#begin('~/.vim/plugged')
" 定义插件,默认用法,和 Vundle 的语法差不多
Plug 'junegunn/vim-easy-align'
Plug 'skywind3000/quickmenu.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' }
" 延迟按需加载,使用到命令的时候再加载或者打开对应文件类型才加载
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'Valloric/YouCompleteMe'
" 确定插件仓库中的分支或者 tag
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
Plug 'ludovicchabant/vim-gutentags'
Plug 'skywind3000/asyncrun.vim'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'tpope/vim-unimpaired'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'
call plug#end()
" Chinese
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set foldmethod=manual
syntax enable
set nu " 显示行号
set showcmd " 显示命令
set showmode " 在底部显示,当前处于命令模式还是插入模式。
set t_Co=256
set backspace=eol,start,indent
set showmatch " 光标遇到圆括号、方括号、大括号时,自动高亮对应的另一个圆括号、方括号和大括号。
" tab转化为4个zi符
set expandtab
set smarttab
set shiftwidth=4
set tabstop=4
set autoread " 当文件在外部被修改时,自动重新读取
set mouse=a " 在所有模式下都允许使用鼠标,还可以是n,v,i,c等
" 光标所在的当前行高亮
"set cursorline
set hlsearch
highlight CursorLine cterm=NONE ctermbg=gray ctermfg=black guibg=NONE guifg=NONE
highlight CocHighlightText cterm=NONE ctermbg=yellow ctermfg=black guibg=NONE guifg=NONE
"set spell spelllang=en_us " 打开英语单词的拼写检查I
"vim-gutentags
" gutentags 搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归
let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project']
" 所生成的数据文件的名称
let g:gutentags_ctags_tagfile = '.tags'
" 将自动生成的 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
" NERD tree
""将F3设置为开关NERDTree的快捷键
map :NERDTreeMirror
map :NERDTreeToggle
""修改树的显示图标
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
""窗口位置
let g:NERDTreeWinPos='left'
""窗口尺寸
let g:NERDTreeSize=30
""窗口是否显示行号
let g:NERDTreeShowLineNumbers=1
""不显示隐藏文件
let g:NERDTreeHidden=0
""打开vim时如果没有文件自动打开NERDTree
autocmd vimenter * if !argc()|NERDTree|endif
""当NERDTree为剩下的唯一窗口时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
""打开vim时自动打开NERDTree
autocmd vimenter * NERDTree
" skywind3000/asyncrun.vim
" 自动打开 quickfix window ,高度为 6
let g:asyncrun_open = 6
" 任务结束时候响铃提醒
let g:asyncrun_bell = 1
" 设置 F10 打开/关闭 Quickfix 窗口
nnoremap :call asyncrun#quickfix_toggle(6)
noremap :AsyncRun gcc -Wall -O2 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)"
nnoremap :AsyncRun -raw -cwd=$(VIM_FILEDIR) "$(VIM_FILEDIR)/$(VIM_FILENOEXT)"
let g:asyncrun_rootmarks = ['.svn', '.git', '.root', '_darcs', 'build.xml']
nnoremap :AsyncRun -cwd= make
nnoremap :AsyncRun -cwd= -raw make run
nnoremap :AsyncRun -cwd= -raw make test
nnoremap :AsyncRun -cwd= cmake .
nnoremap :AsyncRun -cwd=$(VIM_FILEDIR) -mode=4 "$(VIM_FILEDIR)/$(VIM_FILENOEXT)"
nnoremap :AsyncRun -cwd= -mode=4 make run
"analysis/ale
"y查看错误或警告的详细信息
nmap y :ALEDetail
"始终开启标志列
let g:ale_sign_column_always = 1
let g:ale_set_highlights = 1
" 错误警告消息格式
""自定义error和warning图标
"自定义error和warning图标
let g:ale_sign_error = '⨉'
let g:ale_sign_warning = '⚠ '
"在vim自带的状态栏中整合ale
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %code: %%s[%severity%]'
"普通模式下,sp前往上一个错误或警告,sn前往下一个错误或警告
nmap sp (ale_previous_wrap)
nmap sn (ale_next_wrap)
let g:ale_lint_on_text_changed = 'insert'
"let g:ale_lint_on_insert_leave = 1
let g:airline#extensions#ale#enabled = 1
let g:ale_lint_on_enter = 0
"设置状态栏显示的内容
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}\ %{ALEGetStatusLine()}
"let g:airline_theme='bubblegum'
let g:ale_linters = {'c++': ['clang'],'c': ['clang'],'python': ['pylint']}
"let g:ale_c_gcc_options = '-Wall -O2 -std=c99'
"let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++14'
"let g:ale_c_cppcheck_options = ''
"let g:ale_cpp_cppcheck_options = ''
"let g:ale_sign_error = "\ue009\ue009"
hi! clear SpellBad
hi! clear SpellCap
hi! clear SpellRare
hi! SpellBad gui=undercurl guisp=red
hi! SpellCap gui=undercurl guisp=blue
hi! SpellRare gui=undercurl guisp=magenta
" YouCompleteMe
let g:ycm_global_ycm_extra_conf='~/.vim/plugged/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
let g:ycm_add_preview_to_completeopt = 0
let g:ycm_show_diagnostics_ui = 0
let g:ycm_server_log_level = 'info'
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_complete_in_strings=1
let g:ycm_key_invoke_completion = ''
set completeopt=menu,menuone
let g:ycm_python_interpreter_path = "/usr/bin/python3"
let g:ycm_python_binary_path = "/usr/bin/python3"
noremap
let g:ycm_semantic_triggers = {
\ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
\ 'cs,lua,javascript': ['re!\w{2}'],
\ }
" LeaderF
let g:Lf_ShortcutF = ''
let g:Lf_ShortcutB = ''
noremap :LeaderfMru
noremap :LeaderfFunction!
noremap :LeaderfBuffer
noremap :LeaderfTag
let g:Lf_StlSeparator = { 'left': '', 'right': '', 'font': '' }
let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git']
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_WindowHeight = 0.30
let g:Lf_CacheDirectory = expand('~/.vim/cache')
let g:Lf_ShowRelativePath = 0
let g:Lf_HideHelp = 1
let g:Lf_StlColorscheme = 'powerline'
let g:Lf_PreviewResult = {'Function':0, 'BufTag':0}
"设置tagbar使用的ctags的插件,必须要设置对
let g:tagbar_ctags_bin='/usr/bin/ctags'
"设置tagbar的窗口宽度
let g:tagbar_width=30
"设置tagbar的窗口显示的位置,为右边
let g:tagbar_right_=1
"打开文件自动 打开
autocmd BufReadPost *.cpp,*.c,*.h,*.hpp,*.cc,*.cxx call tagbar#autoopen()
"映射tagbar的快捷键
map :TagbarToggle