-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: generate .merlin files #1
Comments
Indeed, that's on the todo list. BTW I haven't looked at what merlin files look like, but I believe it should be straightforward to add, if you are interested in contributing I can give you some pointers |
Doesn't jenga-rules already do this? e.g. https://github.com/janestreet/jenga-rules/blob/master/lib/root.ml#L4747 Or is the idea to make sure they're installed even when not using full jenga? |
The plan is to eventually stop supporting |
If no one wants to work on this, I'd be glad to take it on |
@rdavison that would be welcome! All the rules are in To add a rule, you need to use add_rule (
<compute the contents of .merlin>
>>>
Build.echo (Path.relative dir ".merlin")
)
add_rule (
requires
>>>
Build.arr (fun libs ->
let paths = Lib.include_paths libs in
String.concat ~sep:" " (List.map (Path.Set.elements paths) ~f:(fun path ->
Path.reach path ~from:dir ^ "\n"))
>>>
Build.echo (Path.relative dir ".merlin")
)
Note that this would generate match Path.extract_build_context dir with
| Some ("default", dir (* here dir is the path relative to `_build/default` *)) ->
add_rule (...)
| _ -> () Once that is done, you'll be able to call |
Sounds good, I'll play around with it a bit tonight and we'll see how far I get. Appreciate for the write up! |
So just to leave some feedback and progress update, I'm still working on it, actually, and I've found a bit strange behavior that I'm not fully sure how to interpret. It appears that if I compose the let requires =
requires ~dir ~dep_kind ~item:lib.name
~libraries:lib.libraries
~preprocess:lib.preprocess
~virtual_deps:lib.virtual_deps
in
add_rule (
requires
>>>
Build.arr (fun libs ->
print_endline "never executed"
) But digging deeper into the actual let requires ~dir ~dep_kind ~item ~libraries ~preprocess ~virtual_deps =
let all_pps =
Preprocess_map.pps preprocess
|> Pp_set.elements
|> List.map ~f:Pp.to_string
in
let vrequires = Lib_db.vrequires ~dir ~item in
add_rule
(Build.record_lib_deps ~dir ~kind:dep_kind (List.map virtual_deps ~f:Lib_dep.direct)
>>>
Build.fanout
(Lib_db.closure ~dir ~dep_kind libraries)
(Lib_db.closed_ppx_runtime_deps_of ~dir ~dep_kind
(List.map all_pps ~f:Lib_dep.direct))
>>>
Build.arr (fun (libs, rt_deps) ->
Lib.remove_dups_preserve_order (libs @ rt_deps))
>>>
--> Build.fanout
--> (Build.arr (fun libs ->
--> let paths = Lib.include_paths libs in
--> let concat =
--> String.concat ~sep:" " (List.map (Path.Set.elements paths) ~f:(fun path ->
--> Path.reach path ~from:dir ^ "\n"))
--> in
--> concat) >>> Build.echo (Path.relative dir ".merlin"))
--> (Build.store_vfile vrequires)
--> >>>
--> Build.arr (fun ((),()) -> ()));
Build.vpath vrequires Also, it appears that in order to get completion within a library, one must include an
|
Update: After writing this, I took a second look at your original write-up and noticed that you mentioned that in order to generate the files, then jbuilder would have to be called with the target, which for example could be |
This is now done |
This would be especially awesome if the janestreet packages were released with these .merlin files checked in to ease browsing code.
The text was updated successfully, but these errors were encountered: