Passage
David spoke to Yahweh the words of this song in the day that Yahweh delivered him out of the hand of all his enemies, and out of the hand of Saul,
David spoke to Yahweh the words of this song in the day that Yahweh delivered him out of the hand of all his enemies, and out of the hand of Saul,
2 Samuel 22:1 David spoke to Yahweh the words of this song in the day that Yahweh delivered him out of the hand of all his enemies, and out of the hand of Saul,
2 Samuel 22:2 and he said: “Yahweh is my rock, my fortress, and my deliverer, even mine;
2 Samuel 22:3 God is my rock in whom I take refuge; my shield, and the horn of my salvation, my high tower, and my refuge. My savior, you save me from violence.
The verse centers on "david", "spoke", "yahweh", "words", "song", "delivered", and "hand". It is saying that the verse draws attention to "david" and "spoke", so its meaning should be read from those terms before moving to application.
The next verse adds "and he said Yahweh is my rock...", so "david" and "spoke" should be read forward into that movement. In 2 Samuel context, the local focus is covenant, worship, and faithfulness.
A plain takeaway is to answer the verse's own emphasis on "david" and "spoke" with trust shaped by these words, not by a vague optimism outside the passage.