I am trying to add autocompletion, with suggestions from the currently edited buffer when reading input from the user for a search string:
function! Testinput()
return input("Enter search string: ", 'default', 'syntax')
endfun
call Testinput()
In the above snippet, syntax
is the {completion}
argument, from the help:
The optional {completion} argument specifies the type of completion supported for the input. Without it completion is not performed. The supported completion types are the same as that can be supplied to a user-defined command using the "-complete=" argument. Refer to |:command-completion| for more information. Example: > let fname = input("File: ", "", "file")
I looked though the list available :help command-completion
, the closest matches I could find are: syntax
, tags
(error about not having ctags), i.e. neither one worked. I tested it with file
and I indeed had file autocompletion.
Surely its quite a common use case to auto complete using the buffere's auto complete (or the text in the buffer)? I tried to figure out what auto complete function is currently in use and could not find it (e.g. omnifunc is set to nothing), and the help shows one how to make an autocomplete function.