Seems like Merlin cannot “Jump to definition” to functions generated by ppx_deriving. I wonder why this is? Not sure if this is an error in my setup, a bug in Merlin, an omission in ppx_deriving or just something that is not just implemented yet?
I have merlin 5.3-502 and ppx_deriving 6.03 and ocaml 5.2.0.
Merlin cannot jump to the definition because there is no textual definition to speak of.
PPXs work by mapping over compiler parsetree values so the function generated by ppx_deriving only exist compiled files.
Having the generated definition shown somehow is technically possible though, but i’m guessing this is not a trivial thing to do and would require special support.
If you are using dune, then in the _build directory (I think) you may find files with the generated “code”: but usually they are not human readable. You may find useful the following link:
There, it is commented a feature named [@@deriving_inline] and it is explained:
Some derivers are only needed for boilerplate generation. When that’s the case, there is no strong requirement for them to be included as a hard dependency: the added boilerplate code can be pretty printed and added to the source code by the PPX. This mechanism can be implemented using Dune and ppxlib.
In that cases, it might be possible to promote part of the changes to the source code as explained in that section, although I think it is generally not a recommended practice in most of the situations. Further details are in that ocaml.org page above mentioned.
Thanks for the explanations! Actually, I don’t really care about the definition of the generated functions: I just want to know where they come from. So for me, just jumping to the ppx_deriving attribute would be useful.
Thanks a lot for taking the time to make a reproduction. Would you mind opening an issue on Merlin’s tracker with a link to the repro ? That would be very useful to remind us to have a look