Last active
June 10, 2020 13:28
-
-
Save smondet/bebdf28877b94ffac1de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ### Ocaml | |
" Get the opam directories: | |
let opam_prefix_ = system('echo -n "$(opam config var prefix)"') | |
let opam_prefix = substitute(opam_prefix_,'^\s*\(.\{-}\)\s*$', '\1', '') " This strips the string | |
" #### merlin | |
if filereadable(opam_prefix . '/share/ocamlmerlin/vim/doc/merlin.txt') | |
exec 'set rtp+=' . opam_prefix . '/share/ocamlmerlin/vim' | |
exec 'set rtp+=' . opam_prefix . '/share/ocamlmerlin/vimbufsync' | |
exec 'helptags ' . opam_prefix . '/share/ocamlmerlin/vim/doc' | |
endif | |
if filereadable(opam_prefix . '/share/merlin/vim/doc/merlin.txt') | |
exec 'set rtp+=' . opam_prefix . '/share/merlin/vim' | |
exec 'helptags ' . opam_prefix . '/share/merlin/vim/doc' | |
endif | |
" #### More OCaml files: | |
autocmd BufNewFile,BufReadPost *.eliom set filetype=ocaml | |
autocmd BufNewFile,BufReadPost *.eliomi set filetype=ocaml | |
autocmd BufNewFile,BufReadPost *.atd set filetype=ocaml | |
" #### def's ocp-indent mode | |
" (I use NeoBundle, but it works with other package managers) | |
NeoBundle 'def-lkb/ocp-indent-vim' | |
let g:ocp_indent_args='-c strict_with=always,with=0,strict_comments=false' | |
" #### Some cool optional stuff | |
fun! OCaml_additional() | |
" For the plugin 'tpope/vim-commentary': | |
set commentstring=(*\ %s\ *) | |
" For indenting and folding | |
set foldmethod=indent | |
set shiftwidth=2 | |
map <buffer> <localleader>bmw obegin match with<cr>end<esc>k2==0EEl | |
nmap <buffer> <localleader>om o>>= fun -><esc>==0t- | |
nmap <buffer> <localleader>ou o>>= fun () -><esc>== | |
nmap <buffer> <localleader>ad a(** *)<esc>hh | |
nmap <buffer> <localleader>op o\| -><esc>==^l | |
set cc=81 " display 81st column | |
" It's a merlin thing, but who cares: | |
nmap <buffer> <localleader>l :Locate<cr> | |
endfun | |
autocmd FileType ocaml call OCaml_additional() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment