Skip to content

Instantly share code, notes, and snippets.

@davidmles
Created December 15, 2015 17:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidmles/bc748625e6e94d24a417 to your computer and use it in GitHub Desktop.
Save davidmles/bc748625e6e94d24a417 to your computer and use it in GitHub Desktop.
init.coffee for Atom
atom.workspace.observeTextEditors (editor) ->
path = editor.getPath()
return unless path?
fileTypes =
'.html.erb': 'text.html.ruby',
'.rb': 'source.ruby.rails'
for extension of fileTypes when \
path.toLowerCase().endsWith(extension.toLowerCase()) and
(longestExtension ? "").length < extension.length
longestExtension = extension
return unless longestExtension?
g = atom.grammars.grammarForScopeName fileTypes[longestExtension]
return unless g?
editor.setGrammar g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment