ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.41k stars 2.8k forks source link

Disable general identifier-based completion but not UltiSnips #872

Closed felixjung closed 2 years ago

felixjung commented 10 years ago

Hi,

I work a lot with LaTeX. Obviously having YCM's identifier-based completion turned on gets quite annoying, just as it would with markdown. From the YCM help I gather that setting g:ycm_min_num_of_chars_for_completion to something high like 100 in an autocmd for tex will practically disable the identifier-based completion. However, I've noticed that in this case the YCM pop-up will no longer work for UltiSnips snippets either. Is there a way to disable the popup for standard identifier-based completion but not snippets?

Thanks

Valloric commented 10 years ago

Is there a way to disable the popup for standard identifier-based completion but not snippets?

Not currently, but there should be. Related to #708; there should be a way to choose the components that go into the identifier completion.

felixjung commented 10 years ago

Cool. Thanks for developing YCM.

ccll commented 10 years ago

+1 In my case the identifier based completion interferes with the semantic completion. For example when I enter these for the first time:

printf...

The completion menu shows the signature of printf correctly. But then I type printf again in somewhere else in the same file, the completion item poped up is a identifier based one, only a word is shown and no function signature.

oblitum commented 10 years ago

@ccll How? semantic completion for me only shows up through a semantic completion trigger or forced with ctrl+space, it never shows up just by typing letters.

ccll commented 10 years ago

How? semantic completion for me only shows up through a semantic completion trigger or forced with ctrl+space, it never shows up just by typing letters.

I don't know, when I press 'p' in printf, it just pops up semantic completion instead of identifier based one (of cause only for the first time according to my previous post). I'm using spf13-vim configuration, it comes with YCM support (with ultisnips and vim-snippets) but is disabled by default. After I enable YCM manually, I got this behavior. So it might be something wrong in spf13-vim? I'll check that later, thanks for the tip!

felixjung commented 10 years ago

Any news on this?

wwwdata commented 10 years ago

+1 from me too. I am using this awesome plugin with gocode completion. It works really nice but I would also like to disable the identifier based completion.

rejozenger commented 7 years ago

+1 from me too. Use case: I am using UltiSnips with a considerable amount of snippets when writing e-mail. I'd like to have YCM suggest me snippets, but no other things.

sanjayankur31 commented 6 years ago

Another LaTeX user here - this would be really useful! :+1:

:)

kwrobert commented 6 years ago

Was just trying to accomplish this exact thing, and stumbled upon this issue. Would love to have only snippet completions, and no identifier based completions or semantic completions when writing Latex and markdown notes.

hbodas commented 6 years ago

Any news on this? Was looking for something similar and stumbled upon this report

Astrantia commented 5 years ago

@Valloric Is this still not possible? :( Does it require a lot of effort to implement this considering the issue was opened in 2014 and now it's almost 2019?

ghosty141 commented 4 years ago

Does https://github.com/ycm-core/YouCompleteMe/issues/1114#issuecomment-51111787 solve this?

puremourning commented 4 years ago

I doubt it. But I don’t really know what you mean by ‘solve’. You can disable auto trigger, but then you would never get ultisnips suggestions.

puremourning commented 4 years ago

While I personally think this isn't a good idea, it seems to have some support. Leaving this open, but the core team are unlikely to spend any effort on it.

rudolf-adamkovic commented 3 years ago

Fellow LaTeX sufferers! Here is what I came up with today:

let g:ycm_min_num_of_chars_for_completion = 1

let g:ycm_min_num_of_chars_for_completion_enabled = g:ycm_min_num_of_chars_for_completion
let g:ycm_min_num_of_chars_for_completion_disabled = 999

function FixLaTeXCompletion()
  if &ft == 'tex' && g:ycm_min_num_of_chars_for_completion != g:ycm_min_num_of_chars_for_completion_disabled
    let g:ycm_min_num_of_chars_for_completion = g:ycm_min_num_of_chars_for_completion_disabled
    YcmRestartServer
  endif
  if &ft != 'tex' && g:ycm_min_num_of_chars_for_completion == g:ycm_min_num_of_chars_for_completion_disabled
    let g:ycm_min_num_of_chars_for_completion = g:ycm_min_num_of_chars_for_completion_enabled
    YcmRestartServer
  endif
endfunction

augroup tex_ycm
  autocmd!

  " Connect VimTeX and YouCompleteMe.
  " Taken from |:help vimtex-complete-youcompleteme|.
  autocmd VimEnter * let g:ycm_semantic_triggers.tex=g:vimtex#re#youcompleteme

  " Make YouCompleteMe *not* suggest identifiers in TeX documents.
  " References:
  " 1. |:help g:ycm_min_num_of_chars_for_completion|
  " 2. https://github.com/ycm-core/YouCompleteMe/issues/872
  autocmd BufEnter * call FixLaTeXCompletion()
augroup end
rionda commented 2 years ago

If trying the above you get a E492: Not an editor command: YcmRestartServer message, add normal! before the calls to YcmRestartServer.

rudolf-adamkovic commented 2 years ago

@rionda I moved from Vim to Emacs 7 months ago.

puremourning commented 2 years ago

I can't see. us implementing this unless someone from the community contributes a PR for this.

uthpalaherath commented 2 years ago

@salutis your suggestion is a Godsend! It's been what I've been looking for for months! Every Vim-Latex user would definitely find it useful.

Thanks again!