Actually, you heal them the same way as Dogmeat, engage them in conversation and give the some stimpacks. All the followers auto-heal shortly after each fight as well. I have tested it, and the easiest way is to trade with your companion and give them a few stimpacks. Once their health is low enough and they are not under fire (supposing you diverted the enemies attention towards you) you will see your companion take out a stimpack and apply it to him/herself. But don't worry, once combat is over (your companion puts their gun away) they will auto-heal. Stimpacks are only used in emergencies (such as when they are almost dead) however it may take a few seconds to apply it, so don't let them get shot too many times while applying the stimpack.