Simple: don't invent gunpowder.
It was originally developed around the 800s IIRC- the Chinese using it for rockets, bombs, etc. as well as "fire lances" or very very crude "guns". Black powder first appeared in Europe around 1200 courtesy of the Mongols/Muslims; by the 1300s it was seeing limited use primarily in siege mortars, basically bells turned on their sides and stuffed with a giant rock to fire over a castle wall. The first (European) hand guns started appearing around that time, but they were quite crude and didn't really "take off" as practical infantry weapons until the 1400s, becoming increasingly important over the next two hundred years; 1650-1750 is when guns finally emerged as the preeminent battlefield weapon.
In other words, it took a hell of a long time to get from "black powder that goes boom when you burn it" to "stuff it down a metal tube along with a lead ball and kill anything in front of you."
Gunpowder was actually surprisingly complicated to "stumble across" and its discovery is IMO by no means a given.
Without gunpowder, pikes, plate armored lancers, horse archers. and to a lesser extent crossbows are the most prominent on the battlefield. Tactics and logistics determine the precise ratio/effectiveness/employment of them.
Eventually, given general technological progress one might imagine that chemistry is developed, and explosives start appearing- but it is entirely feasible to delay the development of gunpowder for several centuries.