Code Monkey home page Code Monkey logo

vim-reason-plus's Introduction

Vim/Neovim support for Reason

To have the complete Vim/Neovim Reason experience, there are two plugins to install: this one, and the language-server.

This one provides syntax highlight, snippets for Reason and allows related features to recognize the Reason syntax.

Language-server provides all the others (autocompletion, type hint, jump-to-definition, etc.).

Prerequisite

You'll need either Vim with Python 3 support, or Neovim.

This Plugin's Installation

If you are using a plugin manager, add a line such as the following to your .vimrc (or ~/.config/nvim/init.vim for neovim):

" If using Vim-Plug (recommended. Install from https://github.com/junegunn/vim-plug)
Plug 'reasonml-editor/vim-reason-plus'

" Or, using NeoBundle
NeoBundle 'reasonml-editor/vim-reason-plus'

" Or, using Vundle
Plugin 'reasonml-editor/vim-reason-plus'

Language Server Installation

See https://github.com/jaredly/reason-language-server#vim for language-server installation and configuration.

You also need to install Vim/NeoVim's Language Client. Please follow its Quick Start for configurations.

Here's a complete configuration in your ~/.vimrc (or ~/.config/nvim/init.vim for neovim), assuming you use the vim-plug package manager.

call plug#begin('~/.vim/plugged')

Plug 'reasonml-editor/vim-reason-plus'

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }

" for neovim
if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" for vim 8 with python
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
  " the path to python3 is obtained through executing `:echo exepath('python3')` in vim
  let g:python3_host_prog = "/absolute/path/to/python3"
endif

" nice to have
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'

call plug#end()

let g:LanguageClient_serverCommands = {
    \ 'reason': ['/absolute/path/to/reason-language-server.exe'],
    \ }

" enable autocomplete
let g:deoplete#enable_at_startup = 1

To install those, do :PlugClean, :PlugInstall, :PlugUpdate then :UpdateRemotePlugins (for neovim). This may seem contrived, but folks often forget to properly setup their plugins, so we're not taking chances with the instructions here.

Reason-language-server currently only supports BuckleScript and OCaml 4.02.3 as compiler backends. For native development using OCaml 4.03 or later, you should prefer ocaml-language-server.

Bonus Language Server Configuration

Please follow LanguageClient-neovim's documentation on how to configure features. Here's an example configuration:

nnoremap <silent> gd :call LanguageClient#textDocument_definition()<cr>
nnoremap <silent> gf :call LanguageClient#textDocument_formatting()<cr>
nnoremap <silent> <cr> :call LanguageClient#textDocument_hover()<cr>

Now, for example, triggering gf in normal mode would format the code.

vim-reason-plus's People

Contributors

chenglou avatar disusered avatar jordwalke avatar af avatar azanellato avatar anmonteiro avatar bassjacob avatar miuirussia avatar leostera avatar buzzdecafe avatar rohitpaulk avatar gregoirevda avatar zploskey avatar takano-akio avatar

Watchers

James Cloos 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.