Setting default syntax for new editors?


#1

I wrote a small snippet in my init file, to make the default syntax gfm. This works, however, I now get periodic errors, such as when i close or move panes, etc.

atom.workspace.observeTextEditors (editor) ->
    original_grammar = editor.getGrammar() if editor?
    if original_grammar? and original_grammar is atom.syntax.grammarForScopeName('text.plain.null-grammar')
      editor.setGrammar(atom.syntax.grammarForScopeName('source.gfm'))

Anything obviously wrong?

Thanks in advance!