For You, O LORD of Hosts, the God of Israel, have revealed this to Your servant when You said, ‘I will build a house for you.’ Therefore Your servant has found the courage to offer this prayer to You.
We have here the solemn address David made to God, in answer to the gracious message God had sent him. We are not told what he said to Nathan; no doubt he received him very kindly and respectfully as God's messenger. But his answer to God he took himself, and did not send by Nathan.
Commenting on 2 Samuel 7:18-29
For thou, O Lord of hosts, God of Israel,.... As he is called in Sa2 7:26, hast revealed to thy servant; which he otherwise could not have known: saying, I will build thee an house; see Sa2 7:11, therefore hath thy servant found in his heart to pray this prayer unto thee; found his heart disposed to this service, or found freedom and boldness in...
2Sa 7:27 David felt himself encouraged to offer this prayer through the revelation which he had received. Because God had promised to build him a house, “therefore Thy servant hath found in his heart to pray this prayer,” i.e., hath found joy in doing so.