我安装了YCM插件。我希望YCM完成左右括号。
我制作了一个简单的cpp源文件。在main函数中,我声明了
vector<int> v(10, 0);
当我按下点(。)时,显示了矢量成员函数。
然后,我按下向下箭头键并到达empty()
功能。
每次按箭头键,YCM自动完成功能名称。当我移动推荐菜单时,YCM ONLY完成功能名称。没有完成括号。这是合理的。
最后,我按了回车键(我选择empty()
功能)。但YCM没有完成括号。
v.empty
所以,我需要手动输入左右括号。
我预计当我按下Enter键时,YCM也会完成括号。
是否可以使YCM完全括号?
下面是我的~/.vimrc
配置。
let g:neocomplcache_enable_at_startup = 1
set completeopt-=preview
let g:ycm_add_preview_to_completeopt = 0
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')
Plugin 'delimitMate.vim'
Plugin 'VundleVim/Vundle.vim'
Plugin 'AutoComplPop'
Plugin 'Valloric/YouCompleteMe'
Plugin 'tpope/vim-fugitive'
Plugin 'L9'
Plugin 'git://git.wincent.com/command-t.git'
call vundle#end() " required
filetype plugin indent on " required
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
"To avoid conflict snippets
let g:ycm_key_list_select_completion = ['<C-j>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-k>', '<Up>']
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_show_diagnostics_ui = 0
let g:ycm_enable_diagnostic_signs = 0
let g:ycm_echo_current_diagnostic = 0
let g:ycm_collect_identifiers_from_tags_files = 1
set backspace=2
if has("syntax")
syntax on
endif
set nu
set nuw=9
set magic
set ls=2
set sc
set cursorline
"set autoindent
set ts=4
set shiftwidth=4
set laststatus=2
set statusline=\ %<%l:%v\ [%P]%=%a\ %h%m%r\ %F\
set hlsearch
set scrolloff=2
set showmatch
set showmode
set smarttab
set smartindent
set softtabstop=4
set tabstop=4
set ruler
set incsearch
set title
set wrap
set scrollbind
set background=dark
hi Comment term=bold cterm=bold ctermfg=green
syntax enable
" AutoComplPop customizing
function! InsertTabWrapper()
let col = col('.')-1
if !col||getline('.')[col-1]!~'\k'
return "\<TAB>"
else
if pumvisible()
return "\<C-N>"
else
return "\<C-N>\<C-P>"
end
endif
endfunction
" AutoComplPop end
inoremap <TAB> <c-r>=InsertTabWrapper()<cr>
hi Pmenu ctermbg=blue
hi PmenuSel ctermfg=yellow ctermbg=black
hi PmenuSbar ctermbg=red
"DelimitMate customizing
"BreakLine: Return TRUE if in the middle of {} or () in INSERT mode
fun BreakLine()
if (mode() == 'i')
return ((getline(".")[col(".")-2] == '{' && getline(".")[col(".")-1] == '}') ||
\(getline(".")[col(".")-2] == '(' && getline(".")[col(".")-1] == ')'))
else
return 0
endif
endfun
" Remap <Enter> to split the line and insert a new line in between if
" BreakLine return True
inoremap <expr> <CR> BreakLine() ? "<CR><ESC>O" : "<CR>"
"DelimitMate end