Is there a way (or mod even) to prevent Lydia from trying her hardest to get between you and your target when using bows? It's an absolute pain in the ass. I often have to tell her to wait behind if I need to clear a room.
The mod, SkyTweak could help. Try tweaking the ff.variables in the 'NPC' section: 'Follower Spacing' and 'Follower Catch Up'. This should make your followers keep their distance from you.
Follower Spacing: How closely a follower will try to follow you.
The tweaks won't stop the follower from entering a fight, but will make them increase their distance from you. This makes them less likely to get in the way between you and an enemy you're fighting. AFAIK, there is no way to completely tweak a follower's behavior / AI to make them get out of your line of sight when you're fighting an enemy.