OCamlPro / ocp-indent

Indentation tool for OCaml, to be used from editors like Emacs and Vim.
http://www.typerex.org/ocp-indent.html
Other
200 stars 63 forks source link

vim support in v1.5 #197

Closed Karmaki closed 9 years ago

Karmaki commented 9 years ago

I have been using opt-indent for a long time in vim, and it is great! But today, in a new opam installation, I wanted to install opt-indent again which came in version 1.5.1, and gives the message:

   * Or for Vim, add this line to ~/.vimrc:
 set rtp^="<my path>/opam/root/4.02.1/share/ocp-indent/vim"

So I did that instead of the previous setting which was:

let g:ocp_indent_vimfile = g:opam_shared_dir . "/vim/syntax/ocp-indent.vim"
execute "source " . g:ocp_indent_vimfile

The problem is that it is not working anymore, I mean, when I do == on a line, it does nothing at all.

I also tried to source opam/root/4.02.1/share/ocp-indent/vim/indent/ocaml.vim, but it didn't change anything :-( Did I miss something ?

1.5.0 do the same thing. Going back to 1.4.2.

AltGr commented 9 years ago

1.5.1 vastly improved the vim indent script; it's also now installed to share/ocp-indent/vim/indent/ocaml.vim, rather than share/vim/syntax/ocp-indent.vim, which should make it auto-loadable by vim for indenting ocaml files.

The editor configuration can now be done automatically by opam-user-setup: please try opam user-setup install (it's transparent on the changes it makes, and can be easily reverted).

(on opam < 1.2.2, you may need to run opam install user-setup first)

Karmaki commented 9 years ago

I tried what you said, but it appears that the problem comes from my version of vim that doesn't know the systemlist function which was introduced in 7.4:248 (see also http://stackoverflow.com/questions/32658499/ocaml-vim-user-setup-does-not-work/32658731#32658731). My version is 7.4:52, which is the one that comes with Ubuntu 14.04 (trusty) which is the last LTS version.

I think that I managed to fix the problems what the following modifications: 1- In the .vimrc part (generated by opam-user-setup):

if exists("*systemlist")
  let s:opam_available_tools = systemlist(join(s:opam_check_cmdline, ' '))
else
  let s:opam_available_tools = split(system(join(s:opam_check_cmdline, ' ')))
endif

2- In the ocaml.vim file:

if exists("*systemlist")
  let s:indents = systemlist(cmdline, getline('1','$'))
else
   let s:indents = split(system(cmdline, join (getline('1','$'), "\n")))
endif
AltGr commented 9 years ago

Ah, thanks a lot, that's very useful feedback! I'll update opam-user-setup for compat.