ocaml / merlin

Context sensitive completion for OCaml in Vim and Emacs
https://ocaml.github.io/merlin/
MIT License
1.58k stars 233 forks source link

emacs mode: merlin-type-enclosing, highlight expression. #331

Closed dbuenzli closed 9 years ago

dbuenzli commented 9 years ago

Should temporarily highlight the expression whose type is being show. See e.g. caml-mode's mode implementation of the feature.

let-def commented 9 years ago

That's already the case, in both tuareg-mode and caml-mode, using merlin-type-face.

dbuenzli commented 9 years ago

What should be done then ? It doesn't work here. I had a look in the customization group and that's what's in there:

((t
  (:inherit
   (caml-types-expr-face))))

That's the way I invoke caml-mode and merlin-mode (i.e. nothing fancy is done):

(autoload 'caml-mode "caml" "Major mode for editing OCaml code." t)
(add-hook 'caml-mode-hook
          (lambda ()
;            (electric-indent-local-mode -1)
            ;; Remove trailing white-space
            (add-to-list 'write-file-functions
                         'delete-trailing-whitespace)))
(autoload 'run-caml "inf-caml" "Run an inferior OCaml process." t)
(autoload 'camldebug "camldebug" "Run ocamldebug on program." t)
(add-to-list 'interpreter-mode-alist '("ocamlrun" . caml-mode))
(add-to-list 'interpreter-mode-alist '("ocaml" . caml-mode))
(if window-system (require 'caml-font))

; merlin-iedit
(add-to-list 'load-path "~/.emacs.d/iedit")
(require 'merlin-iedit)

; merlin
(require 'merlin)
(add-to-list 'company-backends 'merlin-company-backend)
(add-hook 'caml-mode-hook 'merlin-mode t)
(setq merlin-use-auto-complete-mode 'easy)
(setq merlin-command 'opam)
(setq merlin-error-on-single-line t)
gsg commented 9 years ago

Perhaps the face you are using happens to have the same background colour as the frame?

You can test this easily:

If it is, you just need to adjust your theme a little for visibility.

dbuenzli commented 9 years ago

Thanks @gsg but that didn't do it. I have no particular theme, everything is "factory" defaults. In fact the problem is this. It seems that caml-types-expr-face is not defined until the first time you usecaml-mode's caml-types-show-types command. If I use it once then merlin highlights correctly. So here's the way I fixed it:

; merlin
(require 'merlin)
(require 'caml-types)

@def-lkb I don't really know how merlin and the ocaml modes interact, can maybe merlin require the thing for me ?

let-def commented 9 years ago

@dbuenzli done (in merlin-simplify branch, which should become master this week)

dbuenzli commented 9 years ago

Thanks !