Set package association by file name (not extension)


Probably a weird request. I’m familiar with how to set atom to use a specific package when is sees a file EXTENSION. However, is there a way to use a specific package (automatically) when selecting a specific file NAME?

For example, chrome bookmarks are a JSON file named “Bookmarks” (no extension). I’d like to be able to click on bookmarks, and have it open in Atom under the JSON editor package.

Conversely, if I open it under atom (just as a document) how can I THEN get the JSON package to operate with it?



By default you cannot have Atom identify the file just by the file name.
As alternative look at a posting ->
How get shell linter to recognise file without shebang

Without coding


This can be solved using The following code will set the grammar to JSON when the file is named “Bookmarks”.

atom.workspace.observeTextEditors (editor) ->
  if editor.getTitle() == "Bookmarks"
    jsonGrammar = atom.grammars.grammarForScopeName "source.json"
    editor.setGrammar jsonGrammar