Set default syntax for all unknown files


#1

I am dealing with a lot file names that have extensions that aren’t the appropriate syntax.
I have the file mechenergypickup.projectile, that is JSON but it doesn’t have the JSON extension so Atom doesn’t know what to do and defaults to plain text. I want it so that when it has an unknown file extension then it defaults to JSON.
If some one has a solution that would be great.


#2

The easy thing would be to set the file extension for all .projectile files, which you can do via config.cson.

To have all unknown files default to one grammar, you’ll need to write an init.coffee function that watches atom.workspace.observeTextEditors(), checks the grammar and the file extension of the resulting TextBuffer, and, if editor.getGrammar().name is "Plain Text" and editor.getTitle().split(".", 1)[1] is not "txt", sets the grammar to atom.grammars.getGrammarByScopeName(".source.json").


Deprecation cop, finally annoying me enough to ask for a fix
Set file name programmatically?
#3

You could install the Default Language extension.


#4

:expressionless: thank you for the extention i probably should have looked harder