GitHub - reasonml-editor/vim-reason: Reason Vim editor integration
source link: https://github.com/reasonml-editor/vim-reason
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Vim support for Reason/OCaml
Note: this is the fallback Reason Vim editor integration for Vim 7 or Vim 8 without Python 3. If you're on NeoVim or Vim 8 with Python 3, please use vim-reason-plus instead!
Installing
If you are using a plugin manager, add a line such as the following to your .vimrc
:
" If using NeoBundle
NeoBundle 'reasonml-editor/vim-reason'
" Or, if using Vundle
Bundle 'reasonml-editor/vim-reason'
" Or, if using Vim-Plug
Plug 'reasonml-editor/vim-reason'
Formatting
The command :ReasonPrettyPrint
invokes the binary refmt
which must be available on your PATH
.
You can set g:vimreason_extra_args_expr_reason
to control the arguments
passed to refmt
(such as --print-width
). The contents of
g:vimreason_extra_args_expr_reason
is a string that contains a VimScript
expression. This allows you do dynamically determine the formatting arguments
based on things like your window width.
" Always wrap at 90 columns
let g:vimreason_extra_args_expr_reason = '"--print-width 90"'
" Wrap at the window width
let g:vimreason_extra_args_expr_reason = '"--print-width " . ' . "winwidth('.')"
" Wrap at the window width but not if it exceeds 120 characters.
let g:vimreason_extra_args_expr_reason = '"--print-width " . ' . "min([120, winwidth('.')])"
Key Mappings
You can create a custom function and map it to a keybinding (in your .vimrc
)
to quickly trigger formatting, and control how the formatting occurs. To enable
keymappings only for reason
files, your vim must have been compiled with
+localmap
(:echo has('localmap')
should output 1
if your vim supports it).
For example, the following maps cmd + shift + m
to reformat only when editing
a reason
file.
autocmd FileType reason map <buffer> <D-M> :ReasonPrettyPrint<Cr>
Merlin
We come with [Merlin] support by default. You can check the features here. Skip the installation procedure in that page; this plugin doesn't use it.
Syntastic support is unobstructedly enabled here by default. Neomake support can be enabled by setting let g:neomake_reason_enabled_makers = ['merlin']
.
Contributing
Lots of content in the repo is copy pasted from https://github.com/ocaml/merlin/tree/v2.5.4/vim/merlin, with a few Reason-specific files added. We'll track master once Reason's global tooling uses the newest Merlin. Until then, since that release branch isn't adding retroactive fixes, there's nothing to sync anymore. You can always submit these Reason files to Merlin or something.
LICENSE
Some files from vim-reason are based on the Rust vim plugin and so we are including that license.
Recommend
-
134
reason-mode An Emacs major mode for ReasonML. Installation Prerequisites Note: the following setup assumes Reason and Merlin are installed...
-
123
-
61
In this blog post, I describe the pros and cons of three programming languages/dialects: JavaScript, TypeScript and ReasonML. My descriptions are based on recent experiences with TypeScript and ReasonML on a few smaller real-world projects and o...
-
57
README.md Vim support for Reason/OCaml Prerequisite You'll need either Vim with Python 3 support, or Neovim. If you're on Vim with Python 2, please use our
-
47
README.md Vim support for Reason/OCaml Note: this is the fallback Reason Vim editor integration for Vim 7 or Vim 8 without Pyt...
-
31
Intro Hello and welcome back to your tutorial series on Reason ML. Yesterday we got familiar with what ReasonML is, what it has to offer, and how to get it installed and configured on our systems and code edito...
-
16
Intro Welcome back to our ReasonML tutorial series. Yesterday we got started on learning the ins and outs of the ReasonML language fundamentals. Today, we're going to continue with this by picking up precisely...
-
30
Intro Welcome back to our tutorial covering the fundamentals of ReasonML. Yesterday we covered some of the more interesting portions of the ReasonML language. Specifically, we looked at some of the data structu...
-
44
README.md vim-reasonml: Native Reason development with esy and Merlin
-
35
README.md Fast Node Manager (fnm)
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK