ReasonML language plugin for idea
Latest commit f05fd6e Sep 21, 2018

README.md

reasonml-idea-plugin

ReasonML language plugin for idea

screenshot

Status

❗️ This is a work in progress, the language has very basic - and partially implemented - functionalities.

This code might change quite a lot or break in the future. The project board should reflect what I'm working on.

Features

  • Reason syntax, OCaml syntax (limited support), Dune syntax (limited support)
  • Structured view
  • Syntax highlighting
  • Line and block commenting
  • Code folding
  • Pair braces matcher
  • JSX completion
  • Bucklescript compiler integration
  • Reformat using refmt (press crtl alt shift R or ⌘⎇⇧R on Mac)
  • Reformat on save
  • Type annotation
  • Configuration through facet
  • Intentions (ReasonML): add braces to function, transform local open
  • Works natively on Windows

This plugin offer a lightweight integration for OCaml files, go to the wiki to see how to configure OCaml if you're not using bucklescript.

Make sure "namespace": false is set in bsconfig.json to enable inferred types hints in the editor.

Screenshots

Type annotations:

type

Reformat using refmt(3)

refmt

Bucklescript window

bsb

Bucklescript

Advanced features, like syntax error highlighting or type annotations require the installation of Bucklescript.

See the wiki to see how to configure Bucklescript.

Local installation

  • Install bucklescript locally to your project using npm or yarn
  • Start idea

The plugin will find and use the binaries found in the node_modules/bs-platform directory.

Tip: if you can, prefer a local installation... you won't have to configure anything else

Global installation

  • Install bucklescript globally
  • Start idea
  • Set the path to bs-platform in the reason settings

Some live templates

List of templates that may help development.

abbrevation: jsp, description: create a jsProps in wrapReasonForJs

~$NAME$=jsProps##$NAME$,$END$

abbreviation: style, description: create a style module

module Styles = {
    open Css;
    let $VAR$ = style([
        $END$
    ]);
};

abbreviation: comp, description: create a reason component

let component = ReasonReact.statelessComponent("$NAME$");

let make = (~$PROP$, _children) => {...component, render: _self => <div />};
$END$
/*
 JS interop
 expose an helper for js - can be deleted when no more used by javascript code
 */
let jsComponent =
  ReasonReact.wrapReasonForJs(~component, jsProps =>
    make(~$PROP$=jsProps##$PROP$, [||])
  );

What?

  • Why don't you consider using Language Server Protocol ?

    Mainly because I want a strong integration in the IDE and I need a first class support of Windows.

  • What versions does the plugin support at the moment?

    It should work with idea 15

  • How is it different than ocaml language plugin?

    I wanted to have a plugin dedicated to reason and that's why I created one called reasonml, not ocaml. Then I realised that I still need ocaml support and that people are asking for it.

    I started this plugin by studying and copying parts of the ocaml plugin, but now the 2 projects are taking different orientations, technically.

    I am moving away from merlin and trying to use the most of Intellij structures.

    Now, they have incompatible implementations, and different goals.

How to help

  • Be patient
  • Give this project some love, star it or star the plugin page in intellij repository
  • Fill the github repo with specific issues
  • Donate using Liberapay Support my work

Development

This project is heavily inspired by :