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

Automatic fallback #70

Open
wants to merge 7 commits into
base: master
from
Open

Automatic fallback #70

wants to merge 7 commits into from

Conversation

@ghetto-ch
Copy link

ghetto-ch commented Feb 21, 2020

If completion fails, fallback to keyword automatically.
I'm not experienced with Vim script at all, therefore my changes may be ugly... please let me know if so.

endif

let omni_pattern = get(b:, 'vcm_omni_pattern', get(g:, 'vcm_omni_pattern'))
let file_pattern = (has('win32') || has('win64')) ? '\\\|\/' : '\/'
let return_exp = &completeopt =~ 'noselect' ? "\<C-p>" : "\<C-p>\<C-p>"

" Action for automatic fallback
let b:shift_tab = a:shift_tab
let fallback_action = "\<C-r>=pumvisible() ? '' : VimCompletesMe#vim_completes_me(b:shift_tab)\<CR>"

This comment has been minimized.

Copy link
@ajh17

ajh17 Feb 22, 2020

Owner

This will cause an infinite loop if no completion is found and if the fallback completion failed. There needs to be a base case for this to prevent this.

This comment has been minimized.

Copy link
@ghetto-ch

ghetto-ch Feb 22, 2020

Author

I tried that but VimCompletesMe get called only twice (tried adding echom). The fallback cases are not using fallback_action, how it can go in infinite loop?

This comment has been minimized.

Copy link
@ghetto-ch

ghetto-ch Feb 22, 2020

Author

I can't reproduce the infinite loop. I made sure to test all cases and they always fallback to keyword. During first call b:completion_tried is set, so the second call will do keyword completion without fallback_action.

This comment has been minimized.

Copy link
@ajh17

ajh17 Feb 22, 2020

Owner

I can't reproduce the infinite loop. I made sure to test all cases and they always fallback to keyword. During first call b:completion_tried is set, so the second call will do keyword completion without fallback_action.

Open a new file named test.c, type in "ma" and hit Tab twice.

This comment has been minimized.

Copy link
@ghetto-ch

ghetto-ch Feb 22, 2020

Author

Ok, I didn't hit Tab twice. I will try to fix this, thanks!

This comment has been minimized.

Copy link
@ghetto-ch

ghetto-ch Feb 23, 2020

Author

Might be fixed now. I will use it for a while.
EDIT: not working... fallback used only once, unless you leave insert mode.

This comment has been minimized.

Copy link
@ghetto-ch

ghetto-ch Feb 23, 2020

Author

I couldn't find a solution without using an extra function. This works for me now though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.