List of all package.json Keywords

I’m trying to find a list of all the keywords (“name”, “main”, “version”, “description”, etc.) for the package.json file that is accepted by Atom, but am having no luck. In particular, I’m trying to figure out which one would let me specify which file formats the package should be activated on. Any help would be greatly appreciated.

The Flight Manual has you covered:

  • activationCommands : an Object identifying commands that trigger your package’s activation. The keys are CSS selectors, the values are Arrays of Strings identifying the command. The loading of your package is delayed until one of these events is triggered within the associated scope defined by the CSS selector. If not specified, the activate() method of your main export will be called when your package is loaded.

Example:

{
  "name": "wordcount",
  "main": "./lib/wordcount",
  "version": "0.0.0",
  "description": "A short description of your package",
  "activationCommands": {
    "atom-workspace": "wordcount:toggle"
  },
  "repository": "https://github.com/atom/your-name-word-count",
  "license": "MIT",
  "engines": {
    "atom": ">=1.0.0 <2.0.0"
  },
  "dependencies": {
  }
}
  • activationHooks : an Array of Strings identifying hooks that trigger your package’s activation. The loading of your package is delayed until one of these hooks are triggered. Currently, there are three activation hooks:
    • core:loaded-shell-environment for when Atom has finished loading the shell environment variables
    • scope.name:root-scope-used for when a file is opened from the specified language (e.g. source.ruby:root-scope-used )
    • language-package-name:grammar-used for when a specific language package is used (e.g., my-special-language-javascript:grammar-used )

Example:

{
  "name": "wordcount",
  "main": "./lib/wordcount",
  "version": "0.0.0",
  "description": "A short description of your package",
  "activationHooks": [
    "language-javascript:grammar-used",
    "language-coffee-script:grammar-used"
  ],
  "repository": "https://github.com/atom/your-name-word-count",
  "license": "MIT",
  "engines": {
    "atom": ">=1.0.0 <2.0.0"
  },
  "dependencies": {
  }
}

Generally speaking, apm init is a good starting point for creating your package’s manifest.

1 Like

Thank you very much for this! The activationHooks key seems to be working for what I need.

I suppose this will only work when a user has these grammars installed? So if I wanted to activate my package just for markdown files, I’d have to use:

"activationHooks": [
    "language-gfm:grammar-used",
    ... [other markdown languages]
  ],

Is there not a way to use file extensions for the activation? Instead of having to list a specific language package, we could just state that this package should be activated for all .md files?

Not that I’m aware of. I guess Markdown is a special case, since there’s no official specification. Still, there only seem to be two relevant language packages for Markdown: the bundled language-gfm package and the third-party language-markdown. Not that many to consider in your activationHook.

If you have a specific package that you recommend users to install to work with your package, take a look at atom-package-deps

1 Like

I think maybe I assumed there would be a way to specify which file types it would be activated on because this is possible to when generating a language package.

When you generate a language package, you have a .cson file, where you can use:

'fileTypes': [
  'filetype1'
  'filetype2'
  'etc...'
]

Anyway, I apologize for this dragging on this long, but I’m still having an issue getting this package to activate on these language types. I essentially only want my package to launch on markdown and txt files.

Currently, my package.json looks like this:

{
  "name": "autobreak",
  "main": "./lib/autobreak",
  "version": "0.0.0",
  "description": "A short description of your package",
  "activationHooks": [
    "language-gfm:grammar-used",
    "language-markdown:grammar-used",
    "language-text:grammar-used"
  ],
  "keywords": [
  ],
  "repository": "https://github.com/atom/autobreak",
  "license": "MIT",
  "engines": {
    "atom": ">=1.0.0 <2.0.0"
  },
  "dependencies": {
  }
}

But my package is still being activated on other file types, I’m definitely missing something here.