Can i get Lydia to only use her bow?

In the vanilla game; no.

With mods; possibly, depending on the mods that are out there.

Basically there are "Build-types" with the AI in the game, that lean towards certain traits in the character skill tree. Strength, Sneaking, Magic, etc. Lydia is a Strength/Melee character type, therefore she would prefer to use melee weapons.

That being said, if you give an AI a weapon of greater damage output, they will prefer that weapon. So if you take any high-damage melee weapons away from her, and give her a high-damage bow instead, she will prefer the bow. However, with the AI the way it is, this does not have very much functionality, as she is primarily a melee AI, so she'll tend to whip out her sword and swing that around anyway.

So if you want to achieve this, mods are your best bet.

EDIT: You could try using commands, or pickpocketing her to remove her base equipment, leaving her only with her bow and arrows. However, should you give her a melee weapon to carry, she will likely use that instead.