To force vim to trigger a specific keypress behavior, you need to map the key to a function.
For example, to match a key . to call some type of completion in INSERT mode you will need:
:inoremap <expr> <buffer> . MyFunction()
and then the function will need to evaluate the context in which it was called and provide the appropriate response to the user.
Change This is the foundation of how clang complete described by @honk.
I'm not sure that you can customize omnifunc behavior to suit your needs, but in my experience I have never gone too far. As @Mikhail said, you will need to keep track of everything that in practice means interpreting or even running the code to some extent.
Unode Jan 03 2018-11-11T00: 00Z
source share