Skip to content

banacorn/bs-atom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bs-atom

Complete Atom API bindings for BuckleScript (as for 1.40.1)

All pull request are welcome

Installation

npm install --save @banacorn/bs-atom

Then add @banacorn/bs-atom to bs-dependencies in your bsconfig.json:

{
  ...
  "bs-dependencies": ["@banacorn/bs-atom"]
}

Usage

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 Points or Ranges:

let p = Atom.Point.make(0, 3);

also, they come with getters:

let row = p.row;

Uncharted modules

How to deal with optional arguments

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

Options with optional fields

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

About

Atom bindings for BuckleScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • OCaml 100.0%