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

Disable automatic semantic completion for specific filetypes #2950

Closed
leigh-ols opened this issue Mar 15, 2018 · 7 comments
Closed

Disable automatic semantic completion for specific filetypes #2950

leigh-ols opened this issue Mar 15, 2018 · 7 comments

Comments

@leigh-ols
Copy link

We used to be able to use the g:ycm_filetype_specific_completion_to_disable setting for this. However at some point the behavior has changed and this entirely disabled semantic completion for these filetypes even when pressing <C-Space>.

Where as previously it only disabled the automatic triggers.

How do I disable semantic completion automatic triggers for certain filetypes, while still allowing <C-Space> to continue working?

@bstaletic
Copy link
Collaborator

Use g:ycm_semantic_triggers.

let g:ycm_semantic_triggers = { 'c': [] }

@leigh-ols
Copy link
Author

Correct me if i'm wrong but doesn't g:ycm_semantic_triggers only allow you to add more triggers and not remove them?

Setting key-value pairs on the dictionary adds semantic triggers to the
internal default set (listed below). You cannot remove the default triggers,
only add new ones.

I tried this before submitting the issue and:

let g:ycm_semantic_triggers = { 'php' : [] }

Does not work.

@leigh-ols
Copy link
Author

Is there really no way to do this anymore?

This functionality used to exist.

@bstaletic
Copy link
Collaborator

g:ycm_semantic_triggers doesn't only add new triggers. Are you sure the variable has the expected value? Check with :echo g:ycm_semantic_triggers.

@leigh-ols
Copy link
Author

In vimrc:

let g:ycm_semantic_triggers = { 'php' : [] }

In vim:

echo g:ycm_semantic_triggers
{'php': []}

Typing $this:: or $this-> still fires semantic completion.

let g:ycm_filetype_specific_completion_to_disable = { 'vim':1, 'txt':1, 'javascript':1, 'php':1 }
Disables semantic triggers, but also disables <C-Space> which some months back it didn't used to do.

g:ycm_semantic_triggers doesn't only add new triggers.

The documentation states otherwise, are the docs incorrect? Is this a bug?

@micbou
Copy link
Collaborator

micbou commented Mar 26, 2018

let g:ycm_filetype_specific_completion_to_disable = { 'vim':1, 'txt':1, 'javascript':1, 'php':1 }
Disables semantic triggers, but also disables which some months back it didn't used to do.

The old behavior was not working as expected because there was no fuzzy-matching in that case. See issue #961. Pressing <C-Space> was the same as directly calling Vim's omnifunc through <C-X><C-O><C-P>. I think these changes should bring the old behavior back without the fuzzy-matching issue. Could you give it a try?

The documentation states otherwise, are the docs incorrect? Is this a bug?

No, the docs are correct but I think that being able to override the default triggers would be an improvement. However, this would break users adding custom triggers to the predefined ones so it's probably out of the question. Maybe we could add a new option with that behavior and deprecate g:ycm_semantic_triggers. We could name it g:ycm_filetype_triggers. @Valloric @puremourning @bstaletic @vheon Thoughts?

@bstaletic
Copy link
Collaborator

Okay, I was obviously wrong about g:ycm_semantic_triggers. I think the general idea of deprecating the current option in favour of g:ycm_filetype_triggers is good. We should probably :echom the deprecation warning too. I also really think we should start putting a "timer" on the deprecation period too.

zzbot added a commit that referenced this issue Apr 14, 2018
…ble, r=puremourning

[READY] Do not disable omnifunc when filetype completion is disabled

Prior to PR #2657, it was possible to trigger Vim's omnifunc with `<C-Space>` even if semantic completion was disabled for the current filetype through the `g:ycm_filetype_specific_completion_to_disable` option. It worked because `<C-Space>` was mapped to `<C-X><C-O><C-P>`, which are the keys to trigger the omnifunc. PR #2657 changed that by making `<C-Space>` directly call the `SendCompletionRequest` function with `force_semantic` sets to `True`. This change was necessary to get fuzzy matching with the omnifunc (see issue #961) but broke the `<C-Space>` behavior when filetype completion is disabled. This PR restores that behavior.

Fixes #2950.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2978)
<!-- Reviewable:end -->
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 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

3 participants