Created
September 30, 2019 08:30
-
-
Save CSchnackenberg/1c216186dd4c207f83f97c8e0146f5fb to your computer and use it in GitHub Desktop.
Atom init.coffee script to quickly change spell-cheking-language and see the current spell-setting in status bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add a label to the status bar | |
initLangLabel = -> | |
selectedLang = atom.config.get('spell-check.locales'); | |
bar = document.querySelector('status-bar .status-bar-right') | |
spellSelect = document.createElement('a'); | |
labelNode = document.createTextNode('-'); | |
spellSelect.appendChild(labelNode); | |
spellSelect.setAttribute('class', 'line-ending-tile inline-block') | |
bar.insertBefore(spellSelect, bar.firstChild); | |
atom.config.observe('spell-check.locales', {}, -> | |
selectedLang = atom.config.get('spell-check.locales'); | |
if selectedLang.length > 0 | |
labelNode.nodeValue = selectedLang[0]; | |
else | |
labelNode.nodeValue = '-' | |
); | |
initLangLabel() | |
# Adding short cuts | |
atom.commands.add 'atom-workspace', 'Spell-DE', -> | |
atom.config.set('spell-check.locales', ['de-DE']); | |
atom.notifications.addSuccess('Switched spell check to: de-DE') | |
atom.commands.add 'atom-workspace', 'Spell-EN', -> | |
atom.config.set('spell-check.locales', ['en-US']); | |
atom.notifications.addSuccess('Switched spell check to: en-US') | |
# add more short cuts here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment