• Stars
    star
    659
  • Rank 68,396 (Top 2 %)
  • Language
    OCaml
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A language server for reason, in reason

NOTICE:

With the recent "rescript" split, this language server becomes less relevant. If you're working on .res files, check out the rescript-vscode plugin. If you're using reason/ocaml compiled to native, ocaml-lsp has the best support for dune.

Reason Language Server

This project implements the Language Server Protocol for Reason.

It is written in Reason, and compiled w/ esy + dune. The goal is for it to work equally well on Windows, MacOS, and Linux.

Platform support

  • Macos βœ…
  • Linux βœ…
  • Windows βœ… (but not under WSL, make sure you install bs-platform etc. from the windows side)

Installation

VS Code

Install through VS Code extensions. Search for reason-vscode:

Visual Studio Code Marketplace: reason-vscode

Can also be installed with VS Code Quick Open: press Cmd/Ctrl + P, paste the following command, and press enter.

ext install jaredly.reason-vscode

The vscode extension is configured via the normal vscode settings screen.

ArchLinux

There is a package available in the AUR.

Use your favorite AUR helper or:

git clone https://aur.archlinux.org/reason-language-server.git
cd reason-language-server
makepkg -si

OniVim

Oni has support for Reason baked in, and it only needs a little bit of configuration to integrate this langauge server.

  1. Download the your-platform.zip file from the latest release, unzip it, and put the reason-language-server.exe file somewhere.
  2. Open the Oni config file ( Ctrl/Cmd + ,), and add the following to the export const configuration = { block at the end:
    "language.reason.languageServer.command": "/abs/path/to/your/reason-language-server.exe",
    "language.reason.languageServer.arguments": [],
    "language.reason.languageServer.configuration": {},

And you're done!

Sublime Text

  1. Install the sublime reason plugin for syntax highlighting, etc. (has to be done manually)
  2. Install the LSP Plugin via the Sublime Text Package Manager
  3. Download the your-platform.zip file from the latest release, unzip it, and put the reason-language-server.exe file somewhere.
  4. Ctrl/Cmd + Shift + P and type "Preferences: LSP Settings" to bring up the settings file, and put in:
{
  "clients": {
    "reason": {
      "enabled": true,
      "command": ["/absolute/path/to/reason-language-server"],
      "scopes": [
        "source.reason",
        "source.ocaml"
      ],
      "syntaxes": [
        "Packages/Reason/Reason.tmLanguage",
        "Packages/sublime-reason/Reason.tmLanguage",
        "Packages/OCaml/OCaml.sublime-syntax"
      ],
      "languageId": "reason"
    }
  }
}

If you're on a newer version of macOS and receive the error popup "reason-language-server cannot be opened because the developer cannot be verified", see here.

Emacs

  1. Download the your-platform.zip file from the latest release, unzip it, and put the reason-language-server.exe file somewhere.
  2. Assuming you're using lsp-mode, add the following to your config file:
(lsp-register-client
 (make-lsp-client :new-connection (lsp-stdio-connection "/absolute/path/to/reason-language-server.exe")
                  :major-modes '(reason-mode)
                  :notification-handlers (ht ("client/registerCapability" 'ignore))
                  :priority 1
                  :server-id 'reason-ls))

Atom

Install https://atom.io/packages/ide-reason

Vim

  1. Download the your-platform.zip file from the latest release, unzip it, and put the reason-language-server.exe file somewhere.
  2. Install the vim-reason-plus plugin, following the README. Add the following to your .vimrc file:
let g:LanguageClient_serverCommands = {
    \ 'reason': ['/absolute/path/to/reason-language-server.exe']
    \ }

Vim config location

LanguageClient-neovim supports configuring language servers via a configuration file. By default the configuration file is .vim/settings.json in the root of your project. For example to set the format width the file will contain:

{
  "reason_language_server": {
    "format_width": 100
  }
}

Configuration settings

The language server supports the following settings (not all of them apply to all clients, for example some clients don't support codelenses at all).

  • format_width - defaults to 80 (int)
  • per_value_codelens - show the type of each toplevel value in a lens (bool)
  • dependencies_codelens - list a files dependencies at the top (bool)
  • opens_codelens - show what values are used from an open (bool)
  • autoRebuild β€” rebuild project on save (turned on by default) (bool)

Debug settings

Useful if you're developing the language server itself.

  • location - provide a custom binary location for the langauge server (string)
  • refmt - provide a custom location for refmt (string)
  • lispRefmt - provide a custom location for reason-lisp's refmt (string)
  • reloadOnChange - reload the server when the reason-language-server binary is updated (bool). assumes the location setting.
  • show_debug_errors - pipe the server's stderr into the output pane (bool)

Troubleshooting

NOTE: reason-language-server runs bsb or dune automatically for you, it is not necessary to have a separate process running bsb -w. In fact, having a separate process running can sometimes get the editor into a weird state.

If your editor is in a weird state, the first recourse (if you're in VSCode) is to restart the reason-language-server, with cmd+shift+p "restart reason language server". That often clears things up.

If that doesn't work, try cleaning built artifacts, with bsb -clean-world (or for dune, dune clean). Then try to build, with bsb -make-world (or dune build @install) and see if that works.

If you encounter Unable to find project root dir error, check that there are no extra .merlin files in other folders than the project root folder.

What about the ocaml-language-server?

That project uses merlin under the hood, which is a very powerful and well-developed tool for IDE features in OCaml/Reason. I had a couple of reasons for starting a new one. The biggest is that I wanted something with minimal dependencies, so that windows support would be relatively easy, and so that I might be able to ship it with bucklescript at some future point. (it also makes targetting JS easier). I also wanted a server that was written entirely in Reason (not part typescript, part reason), and something that was written from the ground up with the Language Server Protocol in mind, instead of taking a different IDE-support-tool and mapping the LSP onto it.

Contributing

  • Install esy if you don't have it (npm install -g esy)
  • Clone this repo
  • cd to the cloned dir
  • Run esy from the main project dir
  • Run esy symlink to link the built artifact into the root folder at bin.exe
  • Install the VS Code extension's dependencies cd editor-extensions/vscode && npm i && cd ../..
  • Open this project in VS Code

Running the test suite

  • esy cp-test
  • ./RunTests.exe

NOTE it's important that you don't run the RunTests.exe from within an esy shell (e.g. esy dune exec RunTests.exe) -- the variables esy sets will mess things up.

Building the OCaml grammar

  • Edit the files in editor-extensions/vscode/src/syntaxes
  • Run cd editor-extensions/vscode && npm run build-syntaxes

To test your changes in one of the example projects

  • Open the "Debug" pane in VS Code. Select a debug target. Press "Run"
  • It should start up a window titled [Extension development host]
  • Run npm install && npm run build in the project directory
  • To reload the server if something goes wrong: Ctrl/Cmd + Shift + P "Restart Reason Language Server"

You can then develop on the language server! When you change something, the server will automatically reload.

Building a new release

  • Add a commit with the message actions: release (it can have anything in the body), that increments the version in extensions/vscode/package.json to the desired version. Github actions will see that commit, and build a new github release.
  • then download the .vsix, briefly test it locally, and then use vsce to publish the release

Copyright & License

Copyright Β© 2018 Jared Forsyth and contributors.

Distributed under the MIT License (see LICENSE).

More Repositories

1

hexo-admin

An Admin Interface for Hexo
JavaScript
1,763
star
2

treed

Powerful Tree Editor
JavaScript
1,710
star
3

gravitron

a little game
OCaml
490
star
4

rxvision

visualizer debugger for reactive streams
HTML
425
star
5

qmoji

πŸ™ƒ Like mojibar, but written in swift
Swift
294
star
6

vim-debug

A plugin for VIM that creates an Integrated Debugging Environment :) Currently works with PHP and Python
Python
283
star
7

github-issues-viewer

A gitub issues viewer build in react + backbone
JavaScript
239
star
8

local-first

data syncing, storage, and collaboration. that works
JavaScript
220
star
9

milk

Milk πŸ₯› Stress-free serialization & deserialization for Reason/OCaml
Reason
203
star
10

veoluz

"I see light" - visualize the paths of millions of light rays through reflection, refraction and diffusion
Rust
153
star
11

redoc

A clean & easy documentation generator for reason/bucklescript/ocaml
JavaScript
117
star
12

stylecleanup

Find & fix unused styles in react native and aphrodite
JavaScript
114
star
13

fluid

OCaml
110
star
14

reason-macros

Template-based macros for Reason/OCaml
OCaml
106
star
15

codetalker

A succinct, pythonic parser + translator solution
Python
100
star
16

let-anything

Deprecated, use the reasonml-community one
OCaml
99
star
17

ohai

easy setup from ocaml/reason native projects
OCaml
98
star
18

a-reason-react-tutorial

included code for A ReasonReact Tutorial
CSS
92
star
19

django-appsettings

A unified settings system for reusable django apps
Python
88
star
20

hooks-experimental

An experiment using react's new "hooks" with ReasonReact
OCaml
75
star
21

pack.re

a simple js bundler for reason
OCaml
72
star
22

reason-cli-tools

A cross-platform collection of useful utilities for making cli's in reason
OCaml
68
star
23

unison.rs

Scheme
65
star
24

reason_async

OCaml
65
star
25

reprocessing-scripts

OCaml
64
star
26

reepl

The cljs Read-eval-print-loop that really understands you
Clojure
63
star
27

reason-websocket

A websocket library for reason native
OCaml
57
star
28

django-feedback

A reusable django app to add an AJAX "feedback" tab to your site
Python
57
star
29

PJs

kinda like pyjamas, but quicker, cleaner, and easier. has the goal of generating readable, usable *robust* javascript code from python code
JavaScript
53
star
30

isomagic-todos

OCaml
51
star
31

terraform

rust + usgs data = 3d-printable models of mountains, canyons, etc.
Rust
51
star
32

myntax

OCaml
50
star
33

reprocessing-example-cross-platform

A boilerplate example for getting cross-platform reprocessing games off the ground
OCaml
50
star
34

purple-maze

A maze game written in reasonml
OCaml
45
star
35

rex-json

A simple cross-target JSON parser for Reason/OCaml
OCaml
45
star
36

reason-simple-server

A simple server library for native reason
OCaml
42
star
37

get_in_ppx

Reason
40
star
38

clevercss2

A complete rewrite of clevercss, utilizing the codetalker library
Python
39
star
39

pydbgp

A fork of Activestate's PyDBGp server
Python
37
star
40

reason-lisp-example

An example of using the lisp syntax for reason/ocaml
35
star
41

js_deep_ppx

[@js.deep] for immutably updating nested javascript objects in Reason/OCaml
OCaml
35
star
42

jerd

TypeScript
35
star
43

demobox

Demo Page Generator & Live Editor Component
JavaScript
35
star
44

minimist.re

A no-frills cli argument parser for reason
OCaml
34
star
45

f3d

OCaml
34
star
46

react-router

An integrated router for react
JavaScript
33
star
47

rusty-automata

Cellular Automata in Rust
Rust
29
star
48

vscode-background-terminal-notifier

Get a notification when a long-running terminal process completes in the background.
JavaScript
27
star
49

ppx_autoserialize

OCaml
27
star
50

hexo-renderer-handlebars

JavaScript
26
star
51

hexium

CSS
25
star
52

grow

Generative art
Rust
23
star
53

belt

Bucklescript's belt library packaged for native ocaml / dune / esy
OCaml
22
star
54

ocaml-cross-mobile

Shell
19
star
55

css

A small, fast css parser in python that utilizes the codetalker library
Python
16
star
56

drupal2django

A tool for migrating a blog from drupal to django; supports nodes, users, redirects, and more
Python
16
star
57

rsnpaint

experimenting with animations + reasonml
OCaml
15
star
58

mocha-selenium

Run selenium tests in parallel using mocha
JavaScript
15
star
59

lost-ranger

OCaml
15
star
60

reason_async_example

OCaml
15
star
61

hybrid-logical-clocks-example

JavaScript
14
star
62

tutorial-cljs

Clojure
14
star
63

reason-docker-server

An example cohttp server w/ dockerfile for deploying to now.sh
Dockerfile
14
star
64

esyi

OCaml
13
star
65

django-restive

A library for enabling the easy and intuitive creating of RESTful services in django
Python
13
star
66

react-teleporter

Make teleportable components
JavaScript
12
star
67

Contruct

the free open-source game creator by scirra
C++
12
star
68

babytux

A game based on babysmash, for occupying small children at the computer
Python
12
star
69

j3

Another attempt to realize my programming language
TypeScript
10
star
70

jaredly.github.io

node.js python data science golang philosophy faith. in no particular order
JavaScript
10
star
71

reason-bucklescript-example

Very bare bones starter pack for reason and bucklescript
OCaml
10
star
72

flame-rsn

OCaml
9
star
73

ssh-keypair

JavaScript
8
star
74

reason-docs

This is the old version: go to
JavaScript
7
star
75

letop-bs-example

OCaml
7
star
76

cowcow

http://cowcow.surge.sh/
OCaml
7
star
77

jfcom

repository for my website
Python
6
star
78

pbj

python build jelly - a simple, extensible pythonic build framework
Python
6
star
79

jnew

JavaScript
6
star
80

reactconf

Relay, Redux, Om/next Oh my!
JavaScript
6
star
81

type-safe-react-native

JavaScript
5
star
82

redu

A disk usage analyser, that's just a simple GUI on top of `du -sh`
OCaml
5
star
83

geometricart

TypeScript
5
star
84

advent-2017

OCaml
5
star
85

rocks

Go
5
star
86

itreed

Notablemind:repl a tree-based interface for iPython and Gorilla-repl
JavaScript
5
star
87

coqdocs

The docs I wish I had while learning Coq
Coq
5
star
88

blender

My blender scripts
Python
5
star
89

graphql-flow

Generate flowtypes for your graphql queries
JavaScript
4
star
90

ppx_guard

early returns for ocaml/reason
OCaml
4
star
91

j2

TypeScript
4
star
92

ppx_import

OCaml
4
star
93

type-safe-react

JavaScript
4
star
94

ferver

fe(a)rver - versioning for those of us who only care about breaking changes
4
star
95

pyjamas

a git clone of the sourceforge repo @ https://pyjamas.svn.sourceforge.net/svnroot/pyjamas
Python
4
star
96

move-over-electron

JavaScript
3
star
97

example-reason-codemod

OCaml
3
star
98

cowsay

A repo demonstrating the serializer generator "milk"
OCaml
3
star
99

code-review-checker

Sits in your mac menu par, checking for code reviews
Reason
3
star
100

bees

OCaml
3
star