Skip to content

Instantly share code, notes, and snippets.

@CSchnackenberg
Created September 30, 2019 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CSchnackenberg/1c216186dd4c207f83f97c8e0146f5fb to your computer and use it in GitHub Desktop.
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
# 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