Coder Social home page Coder Social logo

vscode-reasonml's Introduction

vscode-reasonml

Reason support for Visual Studio Code

screenshot

Discussion

There is an #editorsupport channel on the Reason discord server. If you would like to discuss an idea or need help or have other feedback you can usually find me (@freebroccolo) idling there.

Features

  • highlighting

    • advanced syntax highlighting for reason
    • basic highlighting for merlin, ocamlbuild, and opam files
  • editing

    • document formatting (enable on save with reason.formatOnSave)
    • completion and snippets
    • rename symbol (F2 or right click)
    • case splitting
  • navigation

  • static analysis

    • merlin integration with incremental edit synchronization
    • display types over definitions (disable with editor.codeLens setting)
    • display types and markdown-rendered docs on hover
    • online linting and compiler diagnostics with suggested fixes
      • ⇧⌘M to toggle diagnostics panel
      • F8 to loop through diagnostics for current file
      • Click on lightbulb icon for suggested fixes

Getting Started

Note: due to an existing problem, make sure that you're opening vscode from the command-line, at the root of your project!

Recommended Syntax Themes

Although syntax highlighting should display well in most themes we recommend and test with the following:

Reason Configuration

The Reason installation steps also installs Merlin for you, so you can skip the Merlin installation in the next section.

Merlin Configuration

Configured for you already if you've installed Reason above & plan to use it for JS compilation. Skip this step.

This extension relies heavily on merlin so you will need to have your project set up for that in order to enable completion and hover info. See the Merlin wiki for details on how to do that. Basically you need to have a .merlin file in your project root which lists the source directories, libraries, and extensions used.

Advanced Features

Case splitting

For the examples below, <cursor> represents the position of the current VS Code editor cursor.

Introducing a switch

In order to introduce a switch, execute the following steps:

  1. select an identifier or move the cursor anywhere within its word range (as below)
  2. open the palette (⇧⌘P) and run Reason: case split (typing case should pull it up)
Before
let foo (arg: list 'a) => a<cursor>rg;
After
let foo (arg: list 'a) => switch arg {
  | [] => failwith "<case>"
  | [_, ..._] => failwith "<case>"
};

Nesting switch expressions

The switch introduction functionality works with nested switch expressions:

Before
let foo (arg: list 'a) => switch arg {
  | [] => failwith "<case>"
  | [_, ...xs] => x<cursor>s
};
After
let foo (arg: list 'a) => switch arg {
  | [] => failwith "<case>"
  | [_, ...xs] => switch xs {
    | [] => failwith "<case>"
    | [_, ..._] => failwith "<case>"
  }
};

Splitting a pattern without introducing a switch

The case split feature can be used to split an existing pattern further:

Before
let foo (arg: list 'a) => switch arg {
  | [] => failwith "<case>"
  | [x, ...x<cursor>s] => failwith "<case>"
};
After
let foo (arg: list 'a) => switch arg {
  | [] => failwith "<case>"
  | [_] | [_, _, ..._] => failwith "<case>"
};

vscode-reasonml's People

Contributors

freebroccolo avatar greenkeeperio-bot avatar chenglou avatar khady avatar

Watchers

Michael Stengel avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.