This little snippet aims to make a little autocomplete script in VimL. the first code:
cat % | grep function | sed 's/(/ /g' | awk '{print $3}'
list all the method inside a php class. For example the output of this command could be:
__construct
__toString
foo
bar
If I send to complete function an array
call complete(col('.'), ["__construct", "__toString", "foo", "bar"])
I can see this menu:
So the final question is, ... how can I transform this:
__construct
__toString
foo
bar
into this ["__construct", "__toString", "foo", "bar"]
?
Here my wrong code:
inoremap <F5> <C-R>=CustomComplete()<CR>
func! CustomComplete()
let l:functions = system("cat % | grep function | sed 's/(/ /g' | awk '{print $3}'")
call complete(col('.'), l:functions)
return ''
endfunc