Closed meritozh closed 7 years ago
Can you define "slow" ? Is it OK for a trivial project?
Please post relevant benchmarks, demo screencast or something.
Also, what's in :YcmDiags
? Are there problems parsing the file? As you will have seen when you read the README, completions can be slow if libclang is not able to create a preamble. I can see that ycmd is frequently reporting"
RuntimeError: No completions found; errors in the file?
Which indicates that libclang is failing to parse your file successfully.
FWIW I regularly use YCM with clang's codebase and performance is fine.
Very Strange. When I typing:
CompilerInstance CI;
C[cursor]
It should only trigger tags completer which should be very fast, no semantic completer which may be slow.
You can see I just hit keyboard regularly, but characters didn't show in screen expected. It appear or disapear discontinuously.
What is the value of ycm_min_num_of_chars_for_completion
? The default is 2, so after C
I wouldn't expect any suggestion.
" ===== YouCompleteMe =====
" highlight ERROR line
highlight YcmErrorLine guibg=#433D3D
" global YouCompleteMe setting file location
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
" auto-close preview window
let g:ycm_autoclose_preview_window_after_completion = 0
let g:ycm_min_num_of_chars_for_completion = 1
" complete file path
let g:ycm_filepath_completion_use_working_dir = 1
let g:ycm_extra_conf_vim_data = ['&filetype']
let g:ycm_python_binay_path = "python3"
let g:ycm_error_symbol = 'x'
let g:ycm_warning_symbol = '!'
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_confirm_extra_conf = 0
" prevent python because i want use python-mode instead of YouCompleteMe
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'qf' : 1,
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'unite' : 1,
\ 'text' : 1,
\ 'vimwiki' : 1,
\ 'pandoc' : 1,
\ 'infolog' : 1,
\ 'mail' : 1,
\ 'python' : 1,
\}
au FileType c,cpp,objc,objcpp,python nnoremap <leader>gd :YcmCompleter GoTo<CR>
au FileType c,cpp,objc,objcpp,python nnoremap <leader>gt :YcmCompleter GetType<CR>
au FileType c,cpp,objc,objcpp,python nnoremap <leader>gi :YcmCompleter GoToInclude<CR>
au FileType python nnoremap <leader>gc :YcmCompleter GetDoc<CR>
au FileType c,cpp,objc,objcpp nnoremap <leader>gf: YouCompleteMe FixIt<CR>
Use C[cursor]
as example is not proper. You can see gif. When I type Dia[...]
second time, it appear suddenly, not one by one.
Something else block UI?
Seems code_color
block UI. Do YCM has any plan to support semantic highlight?
I can't see a problem in the inserted gif, but I think you're saying that the problem is with code_color
which I assume is another plugin. YCM does not block the GUI for completions.
Do YCM has any plan to support semantic highlight?
Take a look at DyeVim by @davits. It uses ycmd to provide semantic highlighting.
If you disable code_color
does the problem go away ?
In gif, whole Dia
appears suddenly, not D
i
a
, one by one. I know DyeVim
, but it use a forked YCM.
After disable code_color
, simply test, can not reproduce the problem.
OK, so the problem is with code_color
then, so closing.
@puremourning sorry for comment again. Yes, color_coded
will cause vim slow, because it parse source code with wrong include search path, then raise a lot errors. But after fix color_coded
issue, I faced this problem again.
After analysis YCM working phases, this problem produced because of the preview window. Below is my settings:
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_autoclose_preview_window_after_completion = 0
When I write code based on llvm which has great doxygen style comments, every up/down hittings cause corresponding doc show in preview, but it has a performance issue which cause vim slow.
When Vim opens the preview window, it triggers the BufEnter
autocommand event on the preview window then on the current window. This may explain the slowness you are experiencing if one of your plugins does some costly computation on the BufEnter
event. We had this issue with YCM but it was fixed in PR https://github.com/Valloric/YouCompleteMe/pull/2312. Type :verbose autocmd BufEnter
to see which plugins are using the BufEnter
event.
Below is my output of :verbose autocmd BufEnter
:
--- Auto-Commands ---
filetypedetect BufEnter
*.xpm if getline(1) =~ "XPM2" | setf xpm2 | else | setf xpm | endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
*.xpm2 setf xpm2
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
NERDTree BufEnter
NERD_tree_*
stopinsert
Last set from ~/.vim/plugged/nerdtree/plugin/NERD_tree.vim
NERDTreeHijackNetrw BufEnter
* call nerdtree#checkForBrowse(expand("<amatch>"))
Last set from ~/.vim/plugged/nerdtree/plugin/NERD_tree.vim
NERDCommenter BufEnter
* :call s:SetUpForNewFiletype(&filetype, 0)
Last set from ~/.vim/plugged/nerdcommenter/plugin/NERD_commenter.vim
color_coded BufEnter
* call color_coded#enter()
Last set from ~/.vim/plugged/color_coded/plugin/color_coded.vim
delimitMate BufEnter
* if !exists('b:delimitMate_was_here') | call <SID>setup() | let b:delimitMate_was_here = 1 | endif
Last set from ~/.vim/plugged/delimitMate/plugin/delimitMate.vim
Vimball BufEnter
*.vba setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vba.gz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vba.bz2 setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vba.zip setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vba.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vmb setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vmb.gz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vmb.bz2 setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vmb.zip setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
*.vmb.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so
%)")|endif
Last set from /usr/local/Cellar/macvim/8.0-137_2/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
youcompleteme BufEnter
* call s:OnBufferEnter()
Last set from ~/.vim/plugged/YouCompleteMe/autoload/youcompleteme.vim
To debug this further, use the :profile
command:
:profile start profile.log
:profile func *
:profile file *
" Do the slow operations here.
:profile pause
:qa!
then open the profile.log
file created in the current directory and look for the top functions in the FUNCTIONS SORTED ON SELF TIME
section.
My profile.log.
The ycm_state.HandleFileParseRequest()
is too slow.
Try again with
let g:ycm_show_diagnostics_ui = 0
profile_again.log with let g:ycm_show_diagnostics_ui = 0
.
Still slow.
The profile is dominated by color coded and airline.
Please can you repeat without these plugins enabled.
Repeat this problem, still slow but better than before. The ycm_state.HandleFileParseRequest()
is too slow.
When I hit up/down key, the chosen completion candidate will show in editing line, at this time, YCM will parse source code?
I could reproduce the slowness when enabling the indentLine
plugin. Looks like this plugin redraws indentation levels each time a new window is visited. As I said before, when Vim opens the preview window, it moves the cursor to this window then moves back to the current window. This triggers the WinEnter
autocommand events twice: one for the preview window and another one for the current window. indentLine
does not ignore the preview window so each time you press up or down to select a candidate in the completion menu, indentLine
redraws the indentation levels for both windows, which causes the slowness. indentLine
should not redraw at all in that scenario.
When I hit up/down key, the chosen completion candidate will show in editing line, at this time, YCM will parse source code?
No, it won't.
Thank you very much 😄
Issue Prelude
Please complete these steps and check these boxes (by putting an
x
inside the brackets) before filing your issue:vim --version
.:YcmDebugInfo
.:YcmToggleLogs
command.install.py
(orcmake
/make
/ninja
) including its invocationThank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.
Issue Details
Writing a tool base on clang, just typing normally
YCM works fine, showing completion list very fast.
Strange behavior. YCM is slow, but I didn't know why.
Diagnostic data
Output of
vim --version
Output of
YcmDebugInfo
Contents of YCM, ycmd and completion engine logfiles
ycm_log
ycmd_stderr
ycmd_stdout
OS version, distribution, etc.
Output of build/install commands