From the dismay of verse 1 to the worship of verse 6, how does David get there?

Psalm 13:1, Psalm 13:2-4, Psalm 13:5 and Psalm 13:6