History of Scottish Gaelic
All surviving dialects are Highland and/or Hebridean dialects. Dialects of Lowland Gaelic have become defunct since the demise of Galwegian Gaelic, originally spoken in Galloway, which seems to have been the last Lowland dialect and which survived into the Modern Period. By the 18th century Lowland Gaelic had been largely replaced by Lowland Scots across much of Lowland Scotland. According to a reference in "The Carrick Covenanters " by James Crichton, the last place in the Lowlands where Scottish Gaelic was still spoken was the village of Barr in Carrick: only a few miles inland to the east of Girvan, but at one time very isolated. Crichton gives neither date nor details.
Scotland in the Middle Ages
Modern linguists divide Celtic languages into two major groups, the P-Celtic, from which the Brythonic languages: Welsh, Breton, Cornish and Cumbric derive, and the Q-Celtic, from which come the Goidelic languages: Irish, Manx and Gaelic. The Pictish language remains enigmatic, since the Picts had no written script of their own and all that survives are place names and some isolated inscriptions in Irish ogham script. Most modern linguists accept that, although the nature and unity of Pictish language is unclear, it belonged to the former group. Historical sources, as well as place name evidence, indicate the ways in which the Pictish language in the north and Cumbric languages in the south were overlaid and replaced by Gaelic, Old English and later Norse in this period. By the High Middle Ages the majority of people within Scotland spoke the Gaelic language, then simply called "Scottish", or in Latin, "lingua Scotica". The Kingdom of Alba was overwhelmingly an oral society dominated by Gaelic culture. Our fuller sources for Ireland of the same period suggest that there would have been filidh, who acted as poets, musicians and historians, often attached to the court of a lord or king, and passed on their knowledge and culture in Gaelic to the next generation.