I am using the merlin plugin for Ocaml and right now I set the runtimepath by hand, as per their installation instructions:

call plug#begin('~/.vim/plugins')
  "other plugins go here...
call plug#end()

set rtp+=/home/hugo/.opam/4.02.3/share/merlin/vim

I want to change this so that merlin is managed by vim-plug for consistency and because of vim-plug's lazy-loading feature. I tried doing the following but now my ocaml keybindings are broken:

call plug#begin('~/.vim/plugins')
  "other plugins go here...

  Plug '/home/hugo/.opam/4.02.3/share/merlin/vim'
call plug#end()

Apparently, there is an /usr/share/vim/vim74/ftplugin/ocaml.vim file in my system that overrides some of the keybindings that are automatically defined by merlin. When I was setting the runtimepath by hand the merlin directory appeared last in the runtimepath list (as seen via :echo &rtp), which seemingly causes merlin to load last but when I use vim-plug the merlin dir shows up before /usr/share/vim/vim74 and the keybinds from the system file have priority.

What is the best way to solve this conflict? Should I look for a way to disable the unwanted ftplugin file that comes installed in my system? Should I redefine all the broken keybindings by hand? Or is there something else I can do?


Look at the top of $VIMRUNTIME/ftplugin/ocaml.vim -- you'll see some lines that say:

if exists("b:did_ftplugin")

So, put in your personal


the line

let b:did_ftplugin= 1

This will effectively prevent the system ocaml plugin from loading.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.