vim 配置 ycm补全配置

  if version >= 603

    set helplang=cn

    set encoding=utf-8

endif

set nocompatible              " be iMproved, required

filetype off                  " required

" set the runtime path to include Vundle and initialize

set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

" alternatively, pass a path where Vundle should install plugins

"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required

Plugin 'VundleVim/Vundle.vim'

Plugin 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }

Plugin 'ycm-core/YouCompleteMe', { 'do': './install.py' }

Plugin 'rdnetto/YCM-Generator', { 'branch': 'stable'}

call vundle#end()            " required

filetype plugin indent on    " required

filetype on


 

inoremap <c-w> <ESC><c-w><c-w>

noremap <c-w> <c-w><c-w>i

inoremap yy <ESC>yyi

inoremap <c-v> <ESC>pi

nnoremap <c-v> pi

noremap <c-a> ggVGY

inoremap <c-a> <ESC>ggVGY

inoremap <c-s> <ESC>:w<CR>i

noremap <c-s> :w<CR>

inoremap <c-q> <ESC>:wq<CR>

noremap <c-q> :q!<CR>

imap jk <Esc>

inoremap dd <ESC>ddi

nnoremap tn  :tabnew<CR>

nnoremap tj  :tabnext<CR>

nnoremap tk  :tabprev<CR>

nnoremap tc  :tabclose<CR>

"自动补全

""inoremap ( ()<ESC>i

inoremap ) <c-r>=ClosePair(')')<CR>

inoremap { {<CR>}<ESC>O

inoremap } <c-r>=ClosePair('}')<CR>

inoremap [ []<ESC>i

inoremap ] <c-r>=ClosePair(']')<CR>

inoremap " ""<ESC>i

inoremap ' ''<ESC>i

function! ClosePair(char)

    if getline('.')[col('.') - 1] == a:char

        return "\<Right>"

    else

        return a:char

    endif

endfunction

map <silent> <C-e> :NERDTreeToggle<CR>

"共享剪贴板  

set clipboard+=unnamed

"自动保存

set autowrite

" 在处理未保存或只读文件的时候,弹出确认

set confirm

"搜索逐字符高亮

set hlsearch

colorscheme industry

" 设置当文件被改动时自动载入

set autoread

set shortmess=atI

set showcmd         " 输入的命令显示出来,看的清楚些  

syntax on " 自动语法高亮

set number " 显示行号

set cursorline " 突出显示当前行

set ruler " 打开状态栏标尺

set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4

set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格

set tabstop=4 " 设定 tab 长度为 4

set nobackup " 覆盖文件时不备份

"set autochdir " 自动切换当前目录为当前文件所在的目录

set backupcopy=yes " 设置备份时的行为为覆盖

set ignorecase smartcase " 搜索时忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感

set nowrapscan " 禁止在搜索到文件两端时重新搜索

set incsearch " 输入搜索内容时就显示搜索结果

set hlsearch " 搜索时高亮显示被找到的文本

set noerrorbells " 关闭错误信息响铃

set novisualbell " 关闭使用可视响铃代替呼叫

set t_vb= " 置空错误铃声的终端代码

 set showmatch " 插入括号时,短暂地跳转到匹配的对应括号

 set matchtime=2 " 短暂跳转到匹配括号的时间

set magic " 设置魔术

set hidden " 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存

set guioptions-=T " 隐藏工具栏

set guioptions-=m " 隐藏菜单栏

set smartindent " 开启新行时使用智能自动缩进

set backspace=indent,eol,start

" 不设定在插入状态无法用退格键和 Delete 键删除回车符

set cmdheight=1 " 设定命令行的行数为 1

set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)

set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\

" 设置在状态行显示的信息

set foldenable " 开始折叠

set foldmethod=syntax " 设置语法折叠

set foldcolumn=0 " 设置折叠区域的宽度

setlocal foldlevel=1 " 设置折叠层数为

" set foldclose=all " 设置为自动关闭折叠

 nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>

" 用空格键来开关折叠

autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"

func SetTitle()

    "如果文件类型为.sh文件

    if &filetype == 'sh'

        call setline(1,"\#########################################################################")

        call append(line("."), "\# File Name: ".expand("%"))

        call append(line(".")+1, "\# Author: limu")

        call append(line(".")+2, "\# mail: 修改成自己的@qq.com")

        call append(line(".")+3, "\# Created Time: ".strftime("%c"))

        call append(line(".")+4, "\#########################################################################")

        call append(line(".")+5, "\#!/bin/bash")

        call append(line(".")+6, "")

    else

        call setline(1, "/*************************************************************************")

        call append(line("."), "    > File Name: ".expand("%"))

        call append(line(".")+1, "    > Author: limu")

        call append(line(".")+2, "    > Mail: 1289044138@qq.com ")

        call append(line(".")+3, "    > Created Time: ".strftime("%c"))

        call append(line(".")+4, " ************************************************************************/")

        call append(line(".")+5, "")

    endif

    if &filetype == 'cpp'

       call append(line(".")+6, "#include<iostream>")

"       call append(line(".")+7, "using namespace std;")

         call append(line(".")+8, "")

     endif

"    if &filetype == 'c'

"        call append(line(".")+6, "#include<stdio.h>")

"        call append(line(".")+7, "")

"    endif

"    "新建文件后,自动定位到文件末尾

    autocmd BufNewFile * normal G

endfunc

map <c-b>  :call CompileRunGcc()<CR>

func! CompileRunGcc()

    exec "w"

    if &filetype == 'c'

        exec "!gcc % -o %<"

        exec "! ./%<"

    elseif &filetype == 'cpp'

        exec "!g++ % -o %<"

        exec "! ./%<"

    elseif &filetype == 'java'

        exec "!javac %"

        exec "!java %<"

    elseif &filetype == 'sh'

        :!./%

    endif

endfunc




 

"set( CMAKE_EXPORT_COMPILE_COMMANDS ON )

"imap fw <ESC> <Plug>(YCMFindSymbolInWorkspace)

imap fd <ESC><Plug>(YCMFindSymbolInDocument)

nmap fw <Plug>(YCMFindSymbolInWorkspace)

nmap fd <Plug>(YCMFindSymbolInDocument)    

"nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>

let g:ycm_auto_trigger=1

let g:ycm_min_num_of_chars_for_completion = 2

let g:ycm_min_num_identifier_candidate_chars = 10

let g:ycm_max_num_candidates = 50

let g:ycm_max_num_candidates_to_detail = 0

let g:ycm_max_num_identifier_candidates = 20

let g:ycm_filetype_whitelist = {'*': 1}

""let g:ycm_filepath_blacklist = {'*': 1}

let g:ycm_show_diagnostics_ui = 1

let g:ycm_error_symbol = '>>'

let g:ycm_warning_symbol = '**'

let g:ycm_enable_diagnostic_signs = 1

let g:ycm_enable_diagnostic_highlighting = 1

let g:ycm_echo_current_diagnostic = 1

"nmap <leader>D <plug>(YCMHover)

"augroup MyYCMCustom

"  autocmd!

"  autocmd FileType c,cpp let b:ycm_hover = {

"    \ 'command': 'GetDoc',

"   \ 'syntax': &filetype

"   \ }

"augroup END

"let g:syntastic_always_populate_loc_list=1

let g:ycm_always_populate_location_list = 1

let g:ycm_open_loclist_on_ycm_diags = 1

let g:ycm_complete_in_comments = 0

let g:ycm_complete_in_strings = 1

let g:ycm_collect_identifiers_from_comments_and_strings = 1

let g:ycm_collect_identifiers_from_tags_files = 1

let g:ycm_seed_identifiers_with_syntax = 1

let g:ycm_extra_conf_vim_data = []

let g:ycm_server_python_interpreter = ''

let g:ycm_keep_logfiles = 0

let g:ycm_add_preview_to_completeopt = 1

let g:ycm_autoclose_preview_window_after_completion = 0

let g:ycm_autoclose_preview_window_after_insertion = 1

let g:ycm_max_diagnostics_to_display = 30

let g:ycm_key_list_select_completion = ['<TAB>', '<Down>']

let g:ycm_key_list_previous_completion = ['<S-TAB>', '<Up>']

let g:ycm_key_list_stop_completion = ['<C-y>']

let g:ycm_key_invoke_completion = '<C-Space>'

let g:ycm_key_detailed_diagnostics = '<C-d>'

"let g:ycm_global_ycm_extra_conf=‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘

"let g:ycm_confirm_extra_conf = 1

let g:ycm_filepath_completion_use_working_dir = 1

let g:ycm_cache_omnifunc = 0

let g:ycm_use_ultisnips_completer = 1

let g:ycm_disable_for_files_larger_than_kb = 1000

let g:ycm_goto_buffer_command = 'same-buffer'

let g:ycm_use_clangd = 1

let g:ycm_clangd_binary_path = ''

let g:ycm_clangd_args = []

let g:ycm_clangd_uses_ycmd_caching = 1

""let g:ycm_language_server = []

" Disable signature help

let g:ycm_disable_signature_help = 0

let g:ycm_semantic_triggers =  {

            \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],

            \ 'cs,lua,javascript': ['re!\w{2}'],

            \ }

inoremap <c-l> <ESC>:YcmCompleter GoToDeclaration<CR>

inoremap <c-f> <ESC>:YcmCompleter GoToDefinition<CR>

inoremap <c-;> <ESC>:YcmCompleter GoToDefinitionElseDeclaration<CR>

"inoremap <c-i> <ESC>:YcmDiags<CR>

nnoremap <c-l> :YcmCompleter GoToDeclaration<CR>

nnoremap <c-f> :YcmCompleter GoToDefinition<CR>

nnoremap <c-;> :YcmCompleter GoToDefinitionElseDeclaration<CR>

nnoremap <c-i> :YcmDiags<CR>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值