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

ocaml layer without opam #7312

Closed
bschommer opened this issue Oct 7, 2016 · 9 comments
Closed

ocaml layer without opam #7312

bschommer opened this issue Oct 7, 2016 · 9 comments

Comments

@bschommer
Copy link
Contributor

It would be nice if the ocaml layer could be used without opam. A quick check shows that the problem is currently the opam-init. I would suggest adding some variables as alternatives for specifying other paths for the location of the merlin, etc.

@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2016

I'm not sure what you mean here. What problem? Is there some reason you can't just exclude the packages causing problems? That's the basic mechanism in Spacemacs for using only parts of a layer.

@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2016

I mean, it looks like tuareg and utop needs opam, so if you exclude tuareg and utop, won't that work?

@bschommer
Copy link
Contributor Author

Sorry that for the short problem report. Actually the ocaml layer works however the auto-completion offered by merlin does not.

In the funcs.el file the opam-init function takes care that the directory containing merlin.el, etc. is added to the load-path by querying opam where it installed merlin. The merlin-mode itself locates the needed binary by either querying opam itself or letting the user set it via a variable.

My simple workaround for this is to replace opam-init with:

(defun spacemacs//init-ocaml-opam ()
  ;; (if (executable-find "opam")
  ;;     (let* ((output (shell-command-to-string
  ;;                     "opam config var share 2> /dev/null"))
  ;;            (share (when (< 0 (length output))
  ;;                     (substring output 0 -1))))
  ;;         (when share
  ;;           (setq opam-share share
  ;;                 opam-load-path (concat share "/emacs/site-lisp")))
  ;;         (add-to-list 'load-path opam-load-path))
  ;;   (spacemacs-buffer/warning
  ;;    (concat "Cannot find \"opam\" executable. "
  ;;            "The ocaml layer won't work properly.")))
  (setq merlin-command "<merlin-prefix>/bin/ocamlmerlin")
  (add-to-list 'load-path "<merlin-prefix>/share/emacs/site-lisp")
  )

where merlin-prefix is my merlin installation path.

@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2016

Okay. Is there a reason you need to set merlin-command though? Spacemacs never sets it anywhere.

@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2016

Let me clarify. The code you have commented out

  • sets opam-share
  • sets opam-load-path
  • adds to load-path

While the code you have added

  • sets merlin-command
  • adds to load-path

Is there a reason for the discrepancies?

@bschommer
Copy link
Contributor Author

As far as I can see the opam-load-path as well as the opam-share are not needed if opam is not available. The merlin-command is need when merlin is installed manually instead of through opam:
https://github.com/the-lambda-church/merlin/wiki/emacs-from-scratch#installing-merlin-manually

@TheBB
Copy link
Collaborator

TheBB commented Oct 7, 2016

Okay, thanks.

@bschommer
Copy link
Contributor Author

Also opam-load-path and opam-share are not used anywhere a simple grep showed that they are only used in layers/+lang/ocaml/funcs.el

@bschommer
Copy link
Contributor Author

Fix is merged.

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

No branches or pull requests

4 participants