By Murray Pittock, this is perhaps the best book on Scotland I ever have read? But do note it is relatively light on the Scottish Enlightenment. In any case, here is the passage I will pull out, on the roots of that Enlightenment:
Charles II’s brother James’s rule in Edinburgh as Duke of Albany 1679-82 has been characterized as ‘a brief period of enlightened government’ made possible by the Catholic heir’s exile from the irrational hysteria of the aftermath of the ‘Popish Plot’ in England. Both Charles and James carried out extensive building in the Scottish capital and supported civic redevelopment; indeed what was eventually to become the New Town development was first envisioned under James. James created or supported many of the institutions which underpinned the Enlightenment: the Royal College of Physicians of Edinburgh (1681), the Edinburgh Merchant Company (1681), the Advocates’ Library (1682) and the Order of the Thistle (1687), as well as the offices of Historiography and Geographer Royal (1681-82). In the aftermath of Union, new institutions were developed to defend and preserve Edinburgh’s capital status, such as Allan Ramsey’s theatre (1736) and the Academy of St. Luke, Scotland’s first art school, in 1729. A large number of clubs and associations for improvements were formed, such as the Society for Endeavouring Reformation of Manners (1699), the Rankenian and Associated Critics Clubs (1716-17), the Honourable Society of Improvers in the Knowledge of Agriculture in Scotland (1723), the Society for the Improvement of Medical Knowledge (1731) and the Philosophical Society (1737). The University Medical School (where over three-quarters of students in the eighteenth century were not Scots) was founded by the support of the Royal College of Physicians of Edinburgh in 1726. Like the other Scottish universities, Edinburgh went on to benefit substantially from the addition to the student body of English and Irish dissenters, who were unable to attend Oxford and Cambridge because of their religious affiliations.
Pittock stresses the importance of good education for the Scottish story, here is one good Guardian review noting that point. Here is a good Scotsman review. You can buy the book here, definitely recommended and interesting on virtually every page.