-
-
Save verbosemode/cb9f8f1e8927352e03af80233c3fb517 to your computer and use it in GitHub Desktop.
OCaml vimrc
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
if executable("opam") | |
let g:opamshare = substitute(system('opam config var share'),'\n$','','''') | |
let g:ocamlocpindent = g:opamshare . "/ocp-indent/vim" | |
if !isdirectory(g:ocamlocpindent) | |
echom "Couldn't find ocp-indent in " . g:ocamlocpindent | |
let g:ocaml_has_ocpindent = 0 | |
else | |
let g:ocaml_has_ocpindent = 1 | |
endif | |
let g:ocamlmerlin = g:opamshare . "/merlin/vim" | |
if !isdirectory(g:ocamlmerlin) | |
echom "Couldn't find merlin in " . g:ocamlmerlin | |
let g:ocaml_has_merlin = 0 | |
else | |
let g:ocaml_has_merlin = 1 | |
endif | |
endif | |
call plug#begin('~/.cache/vim/plugged') | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'ervandew/supertab' | |
Plug 'godlygeek/tabular' | |
Plug 'luochen1990/rainbow' | |
Plug 'rgrinberg/vim-ocaml' | |
Plug 'w0rp/ale' | |
Plug g:ocamlocpindent, { 'for': 'ocaml' } | |
Plug g:ocamlmerlin, { 'for': 'ocaml' } | |
call plug#end() | |
function FT_ocaml() | |
setlocal textwidth=80 | |
setlocal colorcolumn=80 | |
setlocal shiftwidth=2 | |
setlocal tabstop=2 | |
setlocal expandtab | |
setlocal smarttab | |
if g:ocaml_has_merlin | |
nmap <LocalLeader>d :MerlinDocument<CR> | |
nmap <LocalLeader>gd :MerlinILocate<CR> | |
nmap <LocalLeader>m :MerlinDestruct<CR> | |
nmap <LocalLeader>o :MerlinOutline<CR> | |
nmap <LocalLeader>r <Plug>(MerlinRename) | |
nmap <LocalLeader>R <Plug>(MerlinRenameAppend) | |
nmap <LocalLeader>T :MerlinYankLatestType<CR> | |
endif | |
vmap a- :Tabularize /-><CR> | |
vmap a: :Tabularize /:<CR> | |
" Load topkg in Merlin when editing pkg/pkg.ml | |
if expand("%:p") =~# "pkg\/pkg\.ml$" | |
call merlin#Use("topkg") | |
endif | |
call SuperTabSetDefaultCompletionType("<c-x><c-o>") | |
endfunction | |
au FileType ocaml call FT_ocaml() | |
au BufRead,BufNewFile *.ml,*.mli compiler ocaml | |
autocmd BufNewFile,BufRead jbuild setlocal filetype=scheme | |
autocmd BufNewFile,BufRead jbuild :RainbowToggle | |
let g:rainbow_active = 0 | |
let g:ale_lint_on_text_changed = 'never' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment