David tells Nathan the prophet that he plans to build God a temple.
God comes to Nathan and says no, but God will plant Israel securely and give David an everlasting lineage. David's son will build a temple.
David goes to God and thanks Him humbly for all He has done: "Let it be as you have said."
18 - David defeats Philistines, Edom, Moab, Ammon, Amalek, and even Syria.
The Ammonites insult Israel. Israel musters for battle. Ammon hires Syrian mercenaries, and it's a tough battle, but thanks to Joab and Abishai, Israel wins. The Syrians muster their whole country after the mercenaries lose, and Israel defeats them again.
How this is about Jesus
These chapters pre-figure Jesus in two ways.
17 - He is the son of David who will have David's throne forever (Luke 1:32).
18-19 - He is the King of kings, who will subdue under Himself all nations.
Sometimes God has other plans, when we are all piously resolved to do great things for Him.
God's people have many enemies, but He will see them protected and victorious.
We need to fight when the enemy seems overwhelming, instead of fleeing or giving up.