Hi,
vim help says about completion functions for use with &completefunc:
Each list item can either be a string or a Dictionary. When it is a string it
is used as the completion. When it is a Dictionary it can contain these
items:
word the text that will be inserted, mandatory
abbr abbreviation of "word"; when not empty it is used in
the menu instead of "word"
I'd like to have a completion that spans several lines, i.e. include
newline characters. I tried several possibilities but neither one worked:
call add(t, {'word': "a\nb", 'abbr': 'a'})
call add(t, {'word': 'a\nb', 'abbr': 'b'})
call add(t, {'word': "a\<cr>b", 'abbr': 'c'})
call add(t, {'word': "a\<c-j>b", 'abbr': 'd'})
Is it possible? If yes, how?
If not, is it somehow possible to make a completion call a function
instead of inserting the text? This probably is rather a feature
request, but I was thinking of complementing a new field called 'agent'
or 'function' that is supposed to do the actual work of inserting the
text after an item was selected. An entry could then look like:
call add(t, {'function': 'InsertText("a\nb")', 'abbr': 'a'})
So I imagine the text stump would then be removed and the function
called with the cursor at the position where the text should begin or so.
Regards,
Thomas.