First things first. There is a big difference between the words avenge and revenge. As a writer (here) suggested:
Avenge is a verb meaning to inflict a punishment or penalty for an
injury or a wrong.
- We will avenge your son’s death.
- I will avenge those who sullied your name.
- The victim was avenged after the shooter was sentenced.
- “As her family, we do not seek to avenge her death.” – The Guardian
Revenge is both a noun and a verb and generally means the act of
taking vengeance for injuries or wrongs; retaliation. While revenge
can function as a verb, it is much more commonly used as a
noun.
- He was so blinded by a desire to get revenge. (Noun)
- I had difficulty not being overwhelmed by feelings or hate and revenge. (Noun)
- “Rodman, a lifetime fifty-eight-per-cent free-throw shooter, was decidedly less amused, but he got revenge by making nine of twelve
from the line.” – The New Yorker (Noun)
- We are determined to revenge our humiliating loss from last year. (Verb)
As the writer I've quoted above says,
Avenge means the achievement of justice. Both avenge and achievement
start with the letter “A.”
Revenge means retaliation. Both revenge and retaliation start with the
letter “R.”
Samson was more interested in being avenged for the loss of his sight than in exacting revenge on his enemies. His prayer to the LORD reflects--albeit belatedly--his dependence on God for the amazing--miraculous, really--feat of strength with which he would be avenged, yet at the cost of his life.
Since context is of paramount importance is hermeneutics, I suggest we start answering your question by unpacking several layers of context. First, there is the context which constitutes the elephant in the room, so to speak, and that is the natural antipathy between Samson, a child of Israel, and the Philistines. Writ large, this antipathy was commanded by God, and if Joshua and his generation had obeyed God by dispossessing the Philistines as he had directed, the life of Israel as a nation would have been vastly different--and for the better!
God, of course, realized that Israel's obedience in ridding the promised land of her (and God's) enemies would be but partial. Hence, the antipathy between the polytheistic Philistines and the monotheistic Israelites would dog Israel's history for generations.
Since God did not have a Plan B but only a Plan A, which is just as true today as it was in Samson's day, God did not require Samson's obedience to bring his will to pass. Nevertheless, Samson's partial obedience, as evinced by his last heart-felt prayer, God rewarded, and Samson was avenged.
Were Samson's motives as pure as the driven snow? Probably not. Was he after justice or revenge? The Bible does not give us a definitive answer. In his defense, however, Samson was not the only "judge" of Israel who disappointed God during this dark time in the history of Israel. A verse which summarizes the spiritual nadir into which Israel had sunk is in Judges Chapter 21:
In those days there was no king in Israel; everyone did what was right in his own eyes (v.25).
In other words, the second contextual component for Samson's sad story is the entire period of the judges, which according to some estimates could be anywhere from 385 years to 450 years, depending on how you calculate its beginning and ending. Regardless how long the period was, the lesson writ large over the entire period is that despite its lack of a king (Judges 21:25a reads "in those days there was no king in Israel"), a king would one day burst on the scene who would have the cure for the ills of humankind.
The third contextual component, then, is Jesus Christ himself, who through his death, burial, and resurrection would one day bring a sure hope to the world's repentant sinners who by being regenerated and sanctified would become a kingdom of priests. As such they will, both in this life and the next, be "offering spiritual sacrifices acceptable to God through Jesus Christ" (1 Peter 2:5). They will also rule and reign with Jesus, who alone is the King of kings and Lord of lords, in a new heaven and a new earth in which only righteousness dwells.
The failures of not only the period of the judges but also the failures of each and every period will give way to the success of the Kingdom of God, through which the kingdoms of this world will become the kingdom of the Lord and of his Christ, and he shall reign forever and ever as the only infinitely perfect prophet, priest, and king.
In conclusion, as for revenge of any sort constituting disobedience to God, the verse you quoted from Leviticus 19 includes a key phrase; namely,
. . . against the sons of your people (v.25).
God commanded his people to refrain from exacting vengeance (or taking revenge) on their fellow Israelites, for vengeance belongs only to God. Morevoer, Israel was charged by God to be a light of righteousness in the midst of a dark world which saw nothing wrong with exacting revenge on an enemy.
Jesus amplified and expanded the concept of revenge in his Sermon on the Mount, which looked forward to the time when his followers, after his ascension to heaven, would refuse to take revenge not only on a fellow believer but would also refuse to take revenge on their enemies and persecutors.
To that end, even Gentiles would experience the mercy and grace of a loving God who
causes His sun to rise on the evil and the good, and sends rain on the righteous and the unrighteous (v.45b).