ReasonML development environment in neovim



Lately, I started running into some bugs in my ReasonML code, so I decided it is a good time to upgrade from the basic ReasonML syntax highlighting plugin in vim to the full feature support of the vim-reason-plus vim plugin. However, I am having a ton of trouble getting the plugin to work properly with the ocaml-language-server.

My ~/.config/nvim/init.vim configuration looks like the following:

call plug#begin()
Plug 'tpope/vim-sensible'
Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash',
    \ }
Plug 'reasonml-editor/vim-reason-plus'
call plug#end()

set hidden

let g:LanguageClient_rootMarkers = {
    \ 'reason': ['bsconfig.json'],
    \ }
let g:LanguageClient_serverCommands = {
    \ 'reason': ['ocaml-language-server', '--stdio'],
    \ 'ocaml': ['ocaml-language-server', '--stdio'],
    \ }

nnoremap <silent> gd :call LanguageClient_textDocument_definition()<cr>
nnoremap <silent> gf :call LanguageClient_textDocument_formatting()<cr>
nnoremap <silent> <cr> :call LanguageClient_textDocument_hover()<cr>

let g:LanguageClient_loggingFile = '/tmp/LanguageClient.log'
let g:LanguageClient_serverStderr = '/tmp/LanguageServer.log'

and the error logs look like the following:

15:37:36 WARN main src/ Failed to get initializationOptions: No such file or directory (os error 2)
15:37:47 WARN main src/ Failed to start language server automatically. timed out waiting on channel

Error: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
15:37:47 ERROR main src/ Error handling message: Message not handled: MethodCall { jsonrpc: Some(V2), method: "window/showMessageRequest", params: Some(Map({"actions": Array([]), "message": String("Cannot find merlin binary at \"ocamlmerlin\"."), "type": Number(2)})), id: Num(0) }

Error: ErrorMessage { msg: "Message not handled: MethodCall { jsonrpc: Some(V2), method: \"window/showMessageRequest\", params: Some(Map({\"actions\": Array([]), \"message\": String(\"Cannot find merlin binary at \\\"ocamlmerlin\\\".\"), \"type\": Number(2)})), id: Num(0) }" }

Has anyone had any luck getting this set up to work?


I figured out the problem by looking at the language server logs. Turns out I forgot to globally install reason-cli:

npm install -g reason-cli@3.2.0-darwin


I found my problem. Turns out I needed to install reason-cli to get it to work.

npm install -g reason-cli@3.2.0-darwin