-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Config API changes #3674
Comments
Here is what was implemented as far as the schema: @config:
fontFamily:
type: 'object'
default: ''
fontSize:
type: 'integer'
default: 16
lineHeight:
type: 'number'
default: 1.3
someArray:
type: 'array'
default: ['ok', 'yeah']
items:
type: 'string'
invisibles:
type: 'object'
properties:
eol:
type: 'string'
default: '\u00ac'
space:
type: 'string'
default: '\u00b7'
tab:
type: 'string'
default: '\u00bb'
cr:
type: 'string'
default: '\u00a4' See https://github.com/atom/atom/blob/master/src/config-schema.coffee |
It'll be great if there was a config API to enable new config types. As I understand the new API, types are used for both validation and UI (on the settings-view), so maybe something like this could do the trick for both: class MyCustomSettingType
coerce: (keyPath, value, schema) ->
# ...
validate: (keyPath, value, schema) ->
# ...
atom.config.registerType 'custom', new MyCustomSettingType As for the UI, the type object could provide a specific method to return a view to use, the only contract for the view would be to dispatch a change event with the value. Maybe something like this:
Do you think this is possible? |
It is currently implemented with eventual extension in mind. At some point, I'd like to open it up to do what you describe. You can add new config types at this time, but the methods to do so are private. I dont want to make extension of the types public until we have a better understanding of how people might want to use them, what extensions are needed, etc. As far as view rendering is concerned, I'd rather not register view rendering with the model like that. I think rendering is the purview of the settings view. What if a new, competing settings view came out and wanted to render things differently? I'd like to register any setting renderers / editors on the settings view. Also, setting renderers are not necessarily bound to a type. They might be bound to some other key like Basically, I want more usage and thought in the current schema additions before committing to an API. |
And we're adhering pretty strictly to (parts) of json schema: http://json-schema.org/latest/json-schema-core.html#anchor8 ; http://json-schema.org/latest/json-schema-validation.html#anchor76. We currently do not have any special additions to it. When we add extensions or allow for it, I want to be sure we are doing the right thing. |
The Config::observe no longer honors the callNow option in favor of::onDidChange. * atom/atom#3674 * atom/atom@b0731af This fixes #10.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks! |
Status: Donezo
Via @nathansobo
Abstract
This roadmap proposes replacing scoped properties with scoped config settings. In short, you'll be allowed to specify a CSS selector when calling
Config::set
, andConfig::get
will optionally accept a token against which to evaluate its selectors. This roadmap also proposes adding aConfig::onDidChange
method to replace thecallNow
property to::observe
.Tasks
Config schema
#3613
Add types and things to the config.
getInt
style methodscallNow: false
Config::onDidChange
APIMove syntax properties into config
#3697
Currently
Syntax
supports scoped config settings. It doesnt make sense to have multiple config systems. This unifies them and will put us in a good place to do scoped configs (eg. enable softwrap for markdown, hard tabs for bash, etc). See #2593, atom/language-make#3Config::get/set
atom.syntax
toatom.config
atom.syntax
toatom.config
atom.config
instead ofatom.syntax
atom.config
instead ofatom.syntax
when loading packages.API
Writing Scoped Settings
We can add an optional selector as the first argument to
Config::set
andConfig::setDefaults
. For example, this enabled soft-wrapping on anything in the.gfm
scope, but disables it for code blocks within markdown. (We would need to update the editor to be capable of honoring these settings within a given scope).Reading Scoped Settings
We can update
Config::get
andConfig::observe
to take an optional token that must match against selectors. Here's an example of determining if we should use soft-tabs in a particular context:Observing Scoped Settings
We can also extend the API to allow scoped settings to be observed. This should assume that the token is immutable, meaning that if the token's scope changes we'll need to set up a new observation:
Eliminating callNow: falseOne final change, unrelated to the scoped properties, is to add a simple
::onDidChange
method toConfig
that replaces thecallNow: false
option to::observe
. This brings the config API into line with changes we've made elsewhere, where::observeFoo
calls the callback immediately and::onDidChangeFoo
calls it only on the next change.The text was updated successfully, but these errors were encountered: