Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually triggering identifier completion popup #1114

Closed
saaguero opened this issue Aug 4, 2014 · 9 comments
Closed

Manually triggering identifier completion popup #1114

saaguero opened this issue Aug 4, 2014 · 9 comments

Comments

@saaguero
Copy link

saaguero commented Aug 4, 2014

As a follow up from a previous question #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

@Valloric
Copy link
Member

Valloric commented Aug 4, 2014

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 Valloric closed this as completed Aug 4, 2014
@saaguero
Copy link
Author

saaguero commented Aug 4, 2014

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?

@Valloric
Copy link
Member

Valloric commented Aug 4, 2014

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.

@saaguero
Copy link
Author

saaguero commented Aug 5, 2014

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?

@vheon
Copy link
Contributor

vheon commented Aug 5, 2014

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.

@saaguero
Copy link
Author

saaguero commented Aug 5, 2014

@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.

thirtythreeforty added a commit to thirtythreeforty/dotfiles that referenced this issue Sep 2, 2015
Turns out that *only* semantic completion is triggered on Ctrl-Space.
Since this is slightly more annoying than the automatic popup (and
there's not a way to have manual identifier completion trigger along
with semantic completion, see ycm-core/YouCompleteMe#1114), let's use ID
completion.
@Leandros
Copy link

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>.

@dedowsdi
Copy link

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.

@leigh-ols
Copy link

@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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants