About ctrlp, the doc
says:
Find previous match for words that start with the
keyword in front of the cursor, looking in places
specified with the 'complete' option. The found
keyword is inserted in front of the cursor.
You can then look at :h'complete'
to learn how to modify the behavior of the completion.
You'll see that you have several options to make the search of the match
restricted to the current buffer, using the other loaded buffers or even looking
for the spell dictionaries.
To modify the setting simply add a line like this in your .vimrc
:
set complete=.,w,b,u
Now for your completion plugin what you are looking for is a custom comlete function. Vims allows you to write such a function, for more information you should refer this question and to the doc:
I think you might also be interested in reading :h ins-completion
which explains how the different completion modes of Vim works. (There are about ten different completion modes used to complete different items, learning them can be long but it should make your completion pretty efficient in the end)
:h 'completefunc'
Ctrl-mumble
combinations.