Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocp-indent doesn't work in vim #22

Open
ddosia opened this issue Feb 22, 2016 · 6 comments
Open

ocp-indent doesn't work in vim #22

ddosia opened this issue Feb 22, 2016 · 6 comments

Comments

@ddosia
Copy link

ddosia commented Feb 22, 2016

Hi there! I am new to ocaml.
I have user-setup version 0.4 [4.02.1] installed through opam.
Recently I've tried

dchurikov ~ $ opam user-setup install --editors=vim
vim > .vimrc: already exists, not installing base template
vim > base > .vimrc: adding configuration
vim > ocp-indent > .vimrc: adding configuration

After that I fixed #21 vim has lunched fine. I've tried to edit .ml
file to see how indentation works, but nothing happens. Looks like
ocp-ident doesn't work.

This is what was generated:

" ## added by OPAM user-setup for vim / base ## 9a3a300d80f2faeb258825d3e0c1947c ## you can edit, but keep this line
let s:opam_share_dir = system("opam config var share")
let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')

let s:opam_configuration = {}

function! OpamConfOcpIndent()
  execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim"
endfunction
let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')

function! OpamConfOcpIndex()
  execute "set rtp+=" . s:opam_share_dir . "/ocp-index/vim"
endfunction
let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex')

function! OpamConfMerlin()
  let l:dir = s:opam_share_dir . "/merlin/vim"
  execute "set rtp+=" . l:dir
endfunction
let s:opam_configuration['merlin'] = function('OpamConfMerlin')

let s:opam_packages = ["ocp-indent", "ocp-index", "merlin"]
let s:opam_check_cmdline = ["opam list --installed --short --safe --color=never"] + s:opam_packages
" I changed next line because of issue #21
let s:opam_available_tools = split(system(join(s:opam_check_cmdline, ' ')))
for tool in s:opam_packages
  " Respect package order (merlin should be after ocp-index)
  if count(s:opam_available_tools, tool) > 0
    call s:opam_configuration[tool]()
  endif
endfor
" ## end of OPAM user-setup addition for vim / base ## keep this line
" ## added by OPAM user-setup for vim / ocp-indent ## a8e14cc76b17ff3c60c05a8f8875e778 ## you can edit, but keep this line
if count(s:opam_available_tools,"ocp-indent") == 0
  source "/home/dchurikov/.opam/4.02.1/share/vim/syntax/ocp-indent.vim"
endif
" ## end of OPAM user-setup addition for vim / ocp-indent ## keep this line

The last path (source "/home/dchurikov/.opam/4.02.1/share/vim/syntax/ocp-indent.vim") actually points nowhere, right path would be /home/dchurikov/.opam/4.02.1/share/ocp-indent/vim/indent/ocaml.vim.
Anyway after I set this path it still doesn't indent.

Thanks in advance.

@AltGr
Copy link
Contributor

AltGr commented Feb 29, 2016

How exactly did you try to indent ? The default keybinding for indent-line is ==.

@ddosia
Copy link
Author

ddosia commented Mar 23, 2016

I was expecting indentation when I hit "return" key. Also I tried ==. No luck.

@rohanjr
Copy link

rohanjr commented Jun 24, 2017

I'm having the same issue. Was this ever resolved @ddosia ?

@AltGr
Copy link
Contributor

AltGr commented Jun 29, 2017

The file to load is actually configured twice, for the two cases where:

  • ocp-indent is installed in the current switch (then that version should be used), line 8
  • ocp-indent is not in the current switch (then, we fallback to the version from the switch where opam-user-setup was run), on the line at the end. This is not done for other tools like merlin, which aren't compatible across OCaml compiler versions.

This is designed to give users ocp-indent support, without requiring them to install it in every opam switch.

It seems indeed that the path at the end failed to be updated correctly when ocp-indent's installation paths changed, but the previous one should be OK, and is the one that should be used in your case.

Can you try the load command by hand and see what happens ?

let s:opam_share_dir = system("opam config var share")
execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim"

@rohanjr
Copy link

rohanjr commented Jul 4, 2017

It turned out that ocp-indent wasn't showing up on my path because the OPAM environment was not being set up. The problem was solved for me by adding the line

eval `opam config env`

to my .profile. Thanks for the help.

@ScientificX
Copy link

I had this issue recently on spacemacs fixed by adding the results of opam config env to ~/.spacemacs.env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants