Ask about making my package (user) configurable?


#1

Hello.

I would like to know more about how to set up the configuration of a designed package. I browsed through some of the provided documentation in the flight-manual and API description.

What I have found…

Looking at LINK1:

Value Coercion

Config settings each have a type specified by way of a schema. For example we might an integer setting that only allows integers greater than 0:

My observation -> The link under schema does not link anywhere.


Later LINK1 mentions:

Defining settings for your package

Define a schema under a config key in your package main.

module.exports =
  # Your config schema 
  config:
    someInt:
      type: 'integer'
      default: 23
      minimum: 1
 
  activate: (state) -> # ... 
  # ...

See package docs for more info.

My observation -> The link to package docs does not seem to add more information.



My follow-up questions:

  1. Is LINK1 the only information there is when it comes to making a package user configurable?

  2. The example above of “under a config key”, is this an entry in the file mentioned under the “entry point of your package” per package.json in LINK2?

  3. Can the description for config key refer to an external file or does it have to be in the main JS / COFFEE script file? There is mention of a json schema in LINK1

Your attention is appreciated.
Regards.


[Solved] Creating a new package for a custom language in Atom
#2

It seems to cover all of the bases that I’m aware of.

The example above of “under a config key”, is this an entry in the file mentioned under the “entry point of your package” per package.json in LINK2?

Almost always, yes.

What do you gain from putting it in a different file? You have four to six lines per config option, and the config declaration should be in a central part of the package. You can take a look at script, which has a relatively short script.js and most of its code in other files. The main file contains the entry point and the config settings.


#3

…now a problem ->

Currently my personal grammar package (minus backup copies):

FILE TREE
language-stl
├───grammars
│     ├───notes.md
│     └───language-stl.cson
├───keymaps
│     └───language-stl.cson
├───lib
│     ├───language-stl.coffee
│     └───language-stl-view.coffee
├───menus
│     └───language-stl.cson
├───settings
│     └───language-stl.cson
├───snippets
│     └───language-stl.cson
├───spec
│     ├───language-stl.coffee
│     └───language-stl-view.coffee
├───styles
│     └───language-stl.less
├.gitignore
├CHANGELOG.md
├LICENSE.md
├package.json
└README.md

The official documentation has the following:

FILE TREE
my-package/
├─ grammars/
├─ keymaps/
├─ lib/
├─ menus/
├─ spec/
├─ snippets/
├─ styles/
├─ index.coffee
└─ package.json

The official documentation makes no mention of ./settings/ which was revealed in this discussion. The suggestion made by @DamnedScholar (thank you!) was instrumental in making Ctrl+/ work.

Now I wonder…

  • Can settings related to a package be placed into ./settings/?
  • What settings can be placed there?

Regards.
dP


#4

Yes.

What settings can be placed there?

The language-specific settings, for sure (although there are some missing from that list, like the indentation and comment settings), but you might be able to put other things in there.