Last active
February 12, 2023 05:40
-
-
Save unhammer/c1ac7320141f09ac38e0 to your computer and use it in GitHub Desktop.
Create .merlin file for a project with all your ocamlfind packages and .opam sources in there
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if test -f .merlin; then | |
echo ".merlin already exists, bailing out ..." >&2 | |
exit 1 | |
else | |
# You could add your default EXT's and such to this list: | |
cat >.merlin <<EOF | |
S . | |
B _build | |
EOF | |
# Add PKG's: | |
ocamlfind list \ | |
| awk '{ print "PKG "$1 }' >>.merlin | |
# See https://github.com/the-lambda-church/merlin/wiki/Letting-merlin-locate-go-to-stuff-in-.opam | |
find ~/.opam -name '*.cmt' -print0 \ | |
| xargs -0 -I{} dirname '{}' \ | |
| sort -u \ | |
| awk '{ print "S "$0"\nB "$0 }' >> .merlin | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Super useful. Thanks to both of you!
Here is a slightly updated version that works with opam switches.