Youcompleteme: Manually triggering identifier completion popup

0

As a follow up from a previous question https://github.com/Valloric/YouCompleteMe/issues/1056

What I would like to do is to have some YCM setting to manually triggering identifier popup... in the case that it just encounter a single match (no ambiguity) it should just pick that (as VIM auto completion does!)

Take a look at the following gif, the first one using YCM and the second one just using VIM auto completion:

vim_with_ycm_popup

vim_without_ycm_popup

saaguero picture saaguero  ·  4 Aug 2014

Most helpful comment

12

Is this still the state of art, does it not coincide with the vision of the plugin to allow to manually trigger completion? YouCompleteMe is an incredible plugin, but at the current state YCM is super intrusive, and I'd love to have a way to trigger all completions with <Tab>.

Leandros picture Leandros  ·  24 Oct 2017

All comments

0

in the case that it just encounter a single match (no ambiguity) it should just pick that (as VIM auto completion does!)

This is precisely something YCM does _not_ want to do. I'm sorry, but the idea for YCM is to be unobtrusive by default.

Valloric picture Valloric  ·  4 Aug 2014
4

Thanks for responding @Valloric! Recalling the documentation:

The g:ycm_auto_trigger option

When set to 0, this option turns off YCM's identifier completer (the as-you-type popup) and the semantic triggers (the popup you'd get after typing . or -> in say C++). You can still force semantic completion with the <C-Space> shortcut.

If you want to just turn off the identifier completer but keep the semantic triggers, you should set g:ycm_min_num_of_chars_for_completion to a high number like 99.

Default: 1

let g:ycm_auto_trigger = 1

In this case you provide an ability to manually triggering semantic completion through <C-Space>... maybe I'm missing something, but: why don't we have a manual trigger for identifier completion as well?

saaguero picture saaguero  ·  4 Aug 2014
0

why don't we have a manual trigger for identifier completion as well?

The main use-case YCM wants to address is the one where identifier completion auto-triggers as you type. Given that, manually triggering it makes no sense. There's some _minor_ support for different YCM workflows, but it isn't really the "vision" of the plugin. The more knobs there are to tweak the harder it becomes to maintain and extend YCM, so I'm trying to keep the amount of knobs low.

Valloric picture Valloric  ·  5 Aug 2014
0

Thanks again Valloric for taking your time to respond. I can see that the main use case of YCM is what you described. Despite that, I would like to go on with my use case (hope somebody else will find useful). Right now I could just use g:ycm_auto_trigger = 0 and fits with my needs... _but_ I can't set up the completeopt which I want as YCM seems to always overwrite with some defaults...

YCM uses completeopt=preview,menuone

I would want to use completeopt=menu,preview

Is there a way to avoid YCM overwriting my vimrc compleopt setting?

saaguero picture saaguero  ·  5 Aug 2014
0

if you really want that behaviour you could try

augroup set_completeopt
  au!
  au Filetype * set completeopt=menu,preview
augroup END

But as Valloric said this is not the behaviour that YCM want.

vheon picture vheon  ·  5 Aug 2014
1

@vheon thanks for your suggestion! I've tried a similar workaround but in the end, inspecting a little bit the _autoload/youcompleteme.vim_

function! s:SetUpCompleteopt()

Is being used with different events... therefore my completeopt will be overwritten with this function. Finally, and I know is ugly, I just changed that function to simple add menu and remove menuone and everything works as I want.

With respect what YCM want, I understand that. But considering that YCM offers a settings to turn off automatic trigger popup but defining a hotkey to manually triggering semantic completion I think the common sense is to provide some hotkey for the identifier completion as well.

saaguero picture saaguero  ·  5 Aug 2014
12

Is this still the state of art, does it not coincide with the vision of the plugin to allow to manually trigger completion? YouCompleteMe is an incredible plugin, but at the current state YCM is super intrusive, and I'd love to have a way to trigger all completions with <Tab>.

Leandros picture Leandros  ·  24 Oct 2017
1

Try this:

let g:ycm_auto_trigger = 0
inoremap <a-i> <c-r>=<sid>ycm_trigger_identifier()<cr>

function! s:ycm_trigger_identifier()
  let g:ycm_auto_trigger = 1
  augroup ycm_trigger_identifier
    au!
    autocmd InsertLeave * ++once let g:ycm_auto_trigger = 0
  augroup end
  doautocmd TextChangedI
  return ''
endfunction

if you press <a-i> in insert mode, it turns on g:ycm_auto_trigger, trigger TextChangedI to tell ycm to do identifier completion, it also registers a one time autocmd to reset g:ycm_auto_trigger to 0 after you leave insert mode.

dedowsdi picture dedowsdi  ·  25 Jul 2019
0

@dedowsdi This is nice... but it would be even nicer if it would disable auto_trigger after a successful completion or the start of a new word. This would make the functionality effectively the same as a manual trigger.

@saaguero It would be nice if you would reconsider this feature. YCM has a lot of settings.. many of which are arguably less useful than this. The ability to disable auto complete, but no way to provide a manual trigger for the identifier completion seems like a strange decision.

I would love to keep auto_trigger on. But it remains too slow to not feel intrusive even after using it for the past 4 years. I finally come to the conclusion I need to turn it off, only to find that it pretty much removes the core functionality of the plugin. I can get manually triggered semantic completion using my current plugin set without using YCM at all.

leigh-ols picture leigh-ols  ·  23 Aug 2019