I recently installed Ocaml and its Merlin plugin for a university course. I am using Vim as a text editor. I have heard that it is possible to configure Merlin to compile automatically the .ml file when saving, but I can not find anything about that with a web research, and the professor is using emacs so he can not give me any information about how to activate this feature.
Asked
Active
Viewed 344 times
0
-
How do you compile the ml files. Do you use `makefile` or normal `ocaml` in CLI? – dlmeetei Sep 18 '17 at 10:16
-
I use a command similar to `ocamlopt -o helloWorld helloWorld.ml` and then `./helloWorld` – Raf Sep 19 '17 at 12:31
1 Answers
0
This is plain vanilla vim style, not relating to merlin. May be you can read merlin document for merlin specific configuration. Set the following in your ~/.vimrc
Use a key like F5 to achieve it
autocmd filetype ocaml nnoremap <F5> :!ocamlopt % -o %:r && ./%:r <CR>
This will compile and run executable when you hit F5.
If you prefer makeprg
option, keep the following autocommand in your vimrc
au filetype ocaml set makeprg=ocamlopt\ -o\ %<\ %
set aw
and then :make
when you open your ml file. I would prefer this approach

dlmeetei
- 9,905
- 3
- 31
- 38