atom/grammar-selector

Allow grammars to exclude themselves in menu

Alhadis opened this issue · 1 comments

Some grammars shouldn't have entries in the selection menu. For instance, the Hyperlink language only exists to inject those helpful underlines on any URL-like sequence in the editor, irrespective of language:

Other grammars exist on their own to be loaded by others (e.g., "Regular Expression (Javascript)".

In short, it'd be great if grammars could flag themselves as hidden. Possibly by having a property set in the grammar file?

'name': 'Hyperlink'
'scopeName': 'text.hyperlink'
'fileTypes': []
'hideInMenu': true

It's tempting to rely on an empty fileTypes array to exclude the grammar instead, but that would assume the grammar's author intended for a user to never select it from the file-menu.

FYI, I've started looking at this locally (as the filename in the image would suggest), but I'm unable to get my development copy of first-mate running. Calls to console.log are showing up normally, but not if they're running from inside the Grammar class's constructor. I'm assuming the grammars are being instantiated externally (outside the running Atom window)...