First of all, Monaco was annexed by revolutionary France and was part of it from 1793 to 1814.
Before 1793 and from 1814 to 1860 it was surrounded by lands belonging to House of Savoy. (So for that specific timeframes, it would be pretty hard for France to annex Monaco without annexing Savoy's lands).
Monaco is surrounded by France from 1860 as a consequence of Treaty of Turin. Two years before, France has agreed to help Kingdom of Sardinia (ruled by House of Savoy) to fight Austrian Empire (Second Italian Independence War), and the price for this help were Duchy of Savoy and County of Nice.
Monaco was not annexed by Savoys before 1860, because its independence was guaranteed by France (Treaty of Peronne).
The later relation between Monaco and France, was regulated by a treaty of 1861, when France guaranteed Monaco's sovereignity in exchange for towns Menton and Roquebrune.
And why France have not tried to annex Monaco? Maybe because Monaco is France's client state anyway: France controls its foreign affairs and may interfere with the succession issues, see Monaco Succession Crisis - so why annex it at all?
The other reasons coming to mind is Monaco's existence as independent state, attracting tourists and rich folks from all over the world is beneficial to the whole French south rivera's economy, yet this is a somewhat controversial statement.
And finally, addressing your question about the nationalism, if we only take a look at the languages: Monagesque dialect is of Ligurian origin, but the local population through the time felt rather strong local identity, during the revolution people threatened the Prince with establishing a republic, not joining France or Italy, in other words: seems that Monagesque people have never really desired to be a part of either France or Italy.