Language Server Index Format for OCaml
Export OCaml type hovers and jump-to-definitions in LSIF
Note: development is early work-in-progress; the tool is released in the interest of early adopters who may find it immediately useful for open source projects.
What is LSIF?
The Language Server Index Format (LSIF) is a format for storing code intelligence data like type hovers and jump-to-definitions. See LSIF and how it relates to LSP for more details. Platforms like Sourcegraph use LSIF to surface this information in your browser.
Quickstart : generate LSIF dump
Pin and install
opam pin add merlin-lsif https://github.com/rvantonder/merlin.git\#lsif. This installs an extension of merlin that dumps type and definition data. Installing
merlin-lsifwill not conflict with existing
Pin and install
opam pin add lsif-ocaml https://github.com/rvantonder/lsif-ocaml.git
Compile your OCaml project. Note:
.merlinfiles to work
At the root of your directory, run
lsif-ocaml -only-type-hovers > data.lsif
Optionally delete the
*.lsif.infiles in your repository with
find . -name *.lsif.in | xargs rm, or keep them around and update your
data.lsiffor changed files in new commits.
Generating LSIF takes a while, how can I make it faster?
Initially generating an LSIF file can take some time (20 minutes on a Macbook for large projects). You can speed it up with
lsif-ocaml-dump -p to generate
*.lsif.in files in a (less stable) parallel frenzy. Note that once every
.ml* file is processed,
*.lsif.in files only need to be updated for changed files. Easily regenerate a smaller number of files by running
lsif-ocaml-dump in subdirectories, or with, e.g.,:
cat updated-file.ml | ocamlmerlin-with-lsif server lsif update-file.ml -dot-merlin ./path/where/update-file/lives/.merlin > updated-file.ml.lsif.in