I have implemented the sql auto complete feature for Query Tool in pgAdmin4. To achieve this I have analyzed the code of "pgcli (http://pgcli.com/)" and also used some part of the code "(https://github.com/dbcli/pgcli)" with our own modification.
"pgcli" buffers all the data(databases, tables, functions etc...) at once while connecting to the database, but we can't do that, so when user press "Ctrl+Space" in the Query Tool we will fetch the data and display the suggestions accordingly.
Attached is the patch file. Please review it and let me know the review comments (if any).