1 Kings 8:18

And the Lord said unto David my father, Whereas it was in thine heart to build an house unto my name, thou didst well that it was in thine heart.

Cross-reference

2 Chronicles 6:7-9 parallels God's response that David's intention was good, though he would not build the temple.

2 Samuel 7:3 Historical context

2 Samuel 7:3 shows Nathan's initial approval of David's plan — God's response here later commends the heart behind that same desire.

1 Chronicles 28:2 has David himself declaring his heart to build the temple — the same desire God commends here.

2 Chronicles 6:8 is the parallel account, repeating God's commendation of David's heart almost verbatim.