First, the phrase "with me" does not occur in 2 Sam 22:21 - the word is יִגְמְלֵ֥נִי = "rewarded me".
2 Sam 23:5 is a simple statement of the fact that God established the royal Davidic covenant with David and his progeny which would ultimately reach its climax with the coming of the Messiah, Jesus Christ as per Luke 1:32, 33 -
He will be great and will be called the Son of the Most High. The Lord
God will give Him the throne of His father David, and He will reign
over the house of Jacob forever. His kingdom will never end!”
See also Acts 13:34, John 1:49. This royal Davidic covenant, inherited and fulfilled by Jesus,
- was the initiative of God alone, : 2 Sam 7, 23:5, 1 Kings 6:11, 12, 8:25, 1 Chron 17:11-14, 2 Chron 6:14-16, 7:17, 18, 13:5, Ps 89:4, 29, 34, 39, 132:11, 12, Jer 33:17, 21, Eze 37:15-28.
- eternal, 2 Sam 23:5, 1 Kings 9:5, 2 Chron 13:5, Eze 37:25, 26, Jer 33:17, 21.
- a very solemn "covenant of salt", 2 Chron 13:5, forever, 2 Sam 7:13, 15, 16, Eze 37:26.
- It was fulfilled by Jesus when He founded the kingdom of God/heaven, Matt 1:1, 20, 9:27, 12:23, 15:22, 20:30, 15, 21:9, 15, Mark 10:35, Luke 1:32, 33, 18:38, 39, John 1:49, Acts 13:32-37, Heb 1:8.
None of these could be accomplished by David and thus it was the work of God alone.
We see another example of this in the Israelite covenant where, at the initiative of God alone, God established Israel as a nation, holy to God (Ex 19:5, 6), not because they were greater and more numerous than other nations (Deut 7:1, 7, 17, 4:38) but because God made a sovereign choice to love them, Jer 31:3.
Therefore, of the OP's options, I would selected option "A".