backported some stuff from haskell-vim