How to get function completions from local module/file

I have a file util.ml which stores some functions like take and drop.
How to call this functions to other file
image
The error: Unbound module util
I’m using ocamlbuild and it builds properly; but ocamllsp is unable to locate the .cmo or .cmi files, I guess.

In addition to this, how to enable inlayHints - I’m using emacs and eglot.
So far, I tried this settings in my .dir-locals.el

;; .dir-locals.el
((nil
  . ((eglot-workspace-configuration
	  . (:ocamllsp (:duneDiagnostics (:enable false))
				   (:inlayHints (:enable true)))))

If you are using ocamlbuild then I believe that you need to write a .merlin file by hand.

Thanks for answering!
I had tried .merlin approach earlier but it didn’t work

# path to example.ml and util.ml
S src/
B _build/src/

Also, adding --fallback-read-dot-merlin flag to lsp config still no luck :slightly_frowning_face:
Relevent snippet:

(add-to-list 'eglot-server-programs
		  '(tuareg-mode . ("/home/user/.opam/project/bin/ocamllsp" "--fallback-read-dot-merlin"))) 

Is Util really directly in one of these directories ? Usually you rather want to write:

S src/**
B _build/**

It works here but I’m not using lsp, just the basic merlin emacs support with caml-mode.

Your solution works. After enabling merlin-mode, I am getting the completions from that file.
Is it possible to see type signatures like lsp for functions and modules?

To show types use c-c c-t.

1 Like