{"id":13765233,"url":"https://github.com/reasonml-editor/reason-mode","last_synced_at":"2025-05-10T20:31:47.762Z","repository":{"id":40572315,"uuid":"90563409","full_name":"reasonml-editor/reason-mode","owner":"reasonml-editor","description":"Emacs major mode for working with ReasonML","archived":false,"fork":false,"pushed_at":"2023-04-05T05:17:39.000Z","size":91,"stargazers_count":121,"open_issues_count":16,"forks_count":26,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-09T04:38:56.015Z","etag":null,"topics":["emacs","ocaml","reasonml"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reasonml-editor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-05-07T21:36:56.000Z","updated_at":"2025-03-01T12:28:17.000Z","dependencies_parsed_at":"2024-01-07T18:18:45.102Z","dependency_job_id":"804f0103-4c85-4dfd-998b-efcf8c72acef","html_url":"https://github.com/reasonml-editor/reason-mode","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reasonml-editor%2Freason-mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reasonml-editor%2Freason-mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reasonml-editor%2Freason-mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reasonml-editor%2Freason-mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reasonml-editor","download_url":"https://codeload.github.com/reasonml-editor/reason-mode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253480569,"owners_count":21915249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emacs","ocaml","reasonml"],"created_at":"2024-08-03T16:00:35.805Z","updated_at":"2025-05-10T20:31:42.741Z","avatar_url":"https://github.com/reasonml-editor.png","language":"Emacs Lisp","readme":"# reason-mode\n![Build Status](https://travis-ci.org/reasonml-editor/reason-mode.svg?branch=master)\n\nAn Emacs major mode for [ReasonML](https://reasonml.github.io/).\n\n## Installation\n\n### Prerequisites\n\n**Note**: the following setup assumes Reason and Merlin are installed. This can be achieved by installing them from OPAM (`opam install reason merlin`). \n\nIf you are using bucklescript, make sure you are using a compatible OCaml version (you can find the version of ocaml compatible with your bucklescript installation by running `npm bsc -version`).\nAt the time of writing this documentation, install OCaml 4.06.1 (for bucklescript 7.\\*)\n\n**Please verify your installation**:\n\n```sh\nocamlc -version # 4.06.1 if you are using bucklescript\nwhich ocamlmerlin # a valid path to the ocamlmerlin binary, mandatorily\nwhich ocamlmerlin-reason # a valid path to the ocamlmerlin-reason binary, mandatorily\n```\n\n### MELPA\n\nIf your Emacs has `package.el` (which is automatically the case for Emacs \u003e= 24), you can install `reason-mode` from the package in [MELPA](https://melpa.org/#/getting-started).\n\n### QUELPA\nAlternatively, you can use [quelpa](https://github.com/quelpa/quelpa) and the following recipe:\n\n```lisp\n(quelpa '(reason-mode :repo \"reasonml-editor/reason-mode\" :fetcher github :stable t))\n```\n\n### Manual Installation\n\nDownload `reason-indent.el`, `reason-interaction.el`, `reason-mode.el` and `refmt.el` at the root of this repository and place it in a `vendor` file next to your Emacs configuration files. Then place the following somewhere in your `.emacs.el`:\n\n```lisp\n(add-to-list 'load-path \"/path/to/vendor\")\n```\n\n\nAdd the following to your `~/.emacs` or `~/.emacs.d/init.el` file:\n\n```elisp\n;;----------------------------------------------------------------------------\n;; Reason setup\n;;----------------------------------------------------------------------------\n\n(defun shell-cmd (cmd)\n  \"Returns the stdout output of a shell command or nil if the command returned\n   an error\"\n  (car (ignore-errors (apply 'process-lines (split-string cmd)))))\n\n(defun reason-cmd-where (cmd)\n  (let ((where (shell-cmd cmd)))\n    (if (not (string-equal \"unknown flag ----where\" where))\n      where)))\n\n(let* ((refmt-bin (or (reason-cmd-where \"refmt ----where\")\n                      (shell-cmd \"which refmt\")\n                      (shell-cmd \"which bsrefmt\")))\n       (merlin-bin (or (reason-cmd-where \"ocamlmerlin ----where\")\n                       (shell-cmd \"which ocamlmerlin\")))\n       (merlin-base-dir (when merlin-bin\n                          (replace-regexp-in-string \"bin/ocamlmerlin$\" \"\" merlin-bin))))\n  ;; Add merlin.el to the emacs load path and tell emacs where to find ocamlmerlin\n  (when merlin-bin\n    (add-to-list 'load-path (concat merlin-base-dir \"share/emacs/site-lisp/\"))\n    (setq merlin-command merlin-bin))\n\n  (when refmt-bin\n    (setq refmt-command refmt-bin)))\n\n(require 'reason-mode)\n(require 'merlin)\n(add-hook 'reason-mode-hook (lambda ()\n                              (add-hook 'before-save-hook 'refmt-before-save)\n                              (merlin-mode)))\n\n(setq merlin-ac-setup t)\n```\n\nIf you have iedit mode set up:\n\n```lisp\n(require 'merlin-iedit)\n(defun evil-custom-merlin-iedit ()\n  (interactive)\n  (if iedit-mode (iedit-mode)\n    (merlin-iedit-occurrences)))\n(define-key merlin-mode-map (kbd \"C-c C-e\") 'evil-custom-merlin-iedit)\n```\n\n(Thanks @sgrove: [https://gist.github.com/sgrove/c9bdfed77f4da8db108dfb2c188f7baf](https://gist.github.com/sgrove/c9bdfed77f4da8db108dfb2c188f7baf))\n\nThis associates `reason-mode` with `.re` and `.rei` files. To enable it explicitly, do \u003ckbd\u003eM-x reason-mode\u003c/kbd\u003e.\n\n### Project specific version of `refmt`\n\nIf you're using different versions of `refmt` between projects, you can use the project-specific installed version via the special config values:\n- `'npm` (calls `npx refmt ...` to use the version of `refmt` installed in the project's `node_modules`) \n- `'opam` (calls `opam exec -- refmt ...` to use the version of `refmt` on the current `opam` switch):\n\n```lisp\n;; can also be set via M-x `customize-mode`\n(setq refmt-command 'npm)\n```\n\n### Utop\n\nReason-mode provides (opt-in) `rtop` support. At the moment only the native workflow is supported.\n\nFirst of all you need to install the [Utop Emacs integration](https://github.com/diml/utop#integration-with-emacs). Make sure it is latest `master` because the feature is fairly new.\n\nThen in your Emacs init file add:\n\n```lisp\n(require 'utop)\n(setq utop-command \"opam config exec -- rtop -emacs\")\n(add-hook 'reason-mode-hook #'utop-minor-mode) ;; can be included in the hook above as well\n```\n\nAfter this, the function `utop` (`C-c C-s`) will start `rtop` in Reason buffers.\n\n### Spacemacs\n\nThe [`reasonml`](https://develop.spacemacs.org/layers/+lang/reasonml/README.html) layer is available in the develop version of spacemacs.\n\n\nFor the stable version of spacemacs, you can install the `reason-mode` package automatically.\n\n```lisp\ndotspacemacs-additional-packages\n  '(\n    (reason-mode\n      :location (recipe\n        :repo \"reasonml-editor/reason-mode\"\n        :fetcher github\n        :files (\"reason-mode.el\" \"refmt.el\" \"reason-indent.el\" \"reason-interaction.el\")))\n)\n```\n\nAfterwards add the [snippet](#manual-installation) to your `dotspacemacs/user-config`.\n\n### Features\n\n#### Auto-format before saving\n\nIf you have refmt installed, you can add this to your `.emacs` file to enable\nauto-format:\n\n```lisp\n(add-hook 'reason-mode-hook (lambda ()\n          (add-hook 'before-save-hook #'refmt-before-save)))\n```\n\n### Tests via Cask + ERT\n\nThe `test` folder contains tests that can be run via [Cask](https://github.com/cask/cask).\nOnce you install `cask`, if it is the first time run:\n\n```\ncask install\ncask exec ./run_tests.sh\n```\n\nIf it is not the first time you can omit the first line and execute the tests with the second one only.\nThe environment variable EMACS controls the program that runs emacs.\n\n## License\n\n`reason-mode` is distributed under the terms of both the MIT license and the\nApache License (Version 2.0).\n\nSee [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for details.\n","funding_links":[],"categories":["Emacs Lisp","ReScript"],"sub_categories":["Editor Support"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freasonml-editor%2Freason-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freasonml-editor%2Freason-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freasonml-editor%2Freason-mode/lists"}