Complete Atom API bindings for BuckleScript (as for 1.40.1
)
All pull request are welcome
npm install --save @banacorn/bs-atom
Then add @banacorn/bs-atom
to bs-dependencies
in your bsconfig.json
:
{
...
"bs-dependencies": ["@banacorn/bs-atom"]
}
For managers like ViewRegistry
or Config
that are instantiated by Atom under the atom
global.
Access them from the Atom
module:
Atom.Config.set("core.themes", [|"atom-light-ui", "atom-light-syntax"|]);
Instances of class like TextEditor
would have type Atom.TextEditor.t
.
Methods are invoked in the pipe last fashion:
textEditor
|> Atom.TextEditor.getTextInBufferRange(range);
Use make
to construct instances of classes like Point
s or Range
s:
let p = Atom.Point.make(0, 3);
also, they come with getters:
let row = p.row;
Some functions may have options. Take Atom.TextEditor.setText
for example:
setText: (string, t) => unit
setText
may take an an extra JS object as the second argument. We suffix these "opinionated" functions with _
.
setText_: (string, {. "bypassReadOnly": bool}, t) => unit
atom.config.set
may take an extra argument:
atom.config.set('editor.tabLength', 2, {
scopeSelector: ['source.js'],
scope: ['someFile']
})
Both scopeSelector
and scope
in the object may be omitted.
Instead of having 4 variants of setText_
, we simply type those optional fields as option(...)
.
set_: (string, value, {
.
"scopeSelector": option(string),
"source": option(string),
}) => bool
Atom.config.set_("core.themes", [|"atom-light-ui"|], {
.
"scopeSelector": Some([|"source.js"|]),
"source": None
});
Note: not all optional fields of options are typed this way