diff --git a/src/dot-merlin/dot_merlin_reader.ml b/src/dot-merlin/dot_merlin_reader.ml index e768d6cacb..fa8401dd31 100644 --- a/src/dot-merlin/dot_merlin_reader.ml +++ b/src/dot-merlin/dot_merlin_reader.ml @@ -326,7 +326,7 @@ let empty_config = { let prepend_config ~cwd ~cfg = List.fold_left ~init:cfg ~f:(fun cfg (d : Merlin_dot_protocol.Directive.Raw.t) -> match d with - | `B _ | `H _ | `S _ | `CMI _ | `CMT _ as directive -> + | `B _ | `S _ | `BH _ | `SH _ | `CMI _ | `CMT _ as directive -> { cfg with to_canonicalize = (cwd, directive) :: cfg.to_canonicalize } | `EXT _ | `SUFFIX _ | `FLG _ | `READER _ | (`EXCLUDE_QUERY_DIR | `USE_PPX_CACHE | `UNKNOWN_TAG _) as directive -> @@ -454,8 +454,9 @@ let postprocess cfg = let dirs = match directive with | `B path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `B p) - | `H path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `H p) | `S path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `S p) + | `BH path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `BH p) + | `SH path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `SH p) | `CMI path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `CMI p) | `CMT path -> List.map (expand ~stdlib dir path) ~f:(fun p -> `CMT p) in diff --git a/src/dot-protocol/merlin_dot_protocol.ml b/src/dot-protocol/merlin_dot_protocol.ml index ba7ea25d0c..6798632b68 100644 --- a/src/dot-protocol/merlin_dot_protocol.ml +++ b/src/dot-protocol/merlin_dot_protocol.ml @@ -31,7 +31,12 @@ open Merlin_utils.Std.Result module Directive = struct type include_path = - [ `B of string | `H of string | `S of string | `CMI of string | `CMT of string ] + [ `B of string + | `S of string + | `BH of string + | `SH of string + | `CMI of string + | `CMT of string ] type no_processing_required = [ `EXT of string list @@ -82,7 +87,8 @@ module Sexp = struct begin match tag with | "S" -> `S value | "B" -> `B value - | "H" -> `H value + | "SH" -> `SH value + | "BH" -> `BH value | "CMI" -> `CMI value | "CMT" -> `CMT value | "STDLIB" -> `STDLIB value @@ -112,8 +118,9 @@ module Sexp = struct let single s = [ Atom s ] in match t with | `B s -> ("B", single s) - | `H s -> ("H", single s) | `S s -> ("S", single s) + | `BH s -> ("BH", single s) + | `SH s -> ("SH", single s) | `CMI s -> ("CMI", single s) | `CMT s -> ("CMT", single s) | `EXT ss -> ("EXT", [ List (atoms_of_strings ss) ]) diff --git a/src/dot-protocol/merlin_dot_protocol.mli b/src/dot-protocol/merlin_dot_protocol.mli index 2acff7bbf3..96e34972d2 100644 --- a/src/dot-protocol/merlin_dot_protocol.mli +++ b/src/dot-protocol/merlin_dot_protocol.mli @@ -43,7 +43,12 @@ really do not want to load them. *) module Directive : sig type include_path = - [ `B of string | `H of string| `S of string | `CMI of string | `CMT of string ] + [ `B of string + | `S of string + | `BH of string + | `SH of string + | `CMI of string + | `CMT of string ] type no_processing_required = [ `EXT of string list diff --git a/src/kernel/mconfig.ml b/src/kernel/mconfig.ml index 3728dffcd5..6793f2984e 100644 --- a/src/kernel/mconfig.ml +++ b/src/kernel/mconfig.ml @@ -71,8 +71,9 @@ let marg_commandline f = type merlin = { build_path : string list; - hidden_path : string list; source_path : string list; + hidden_build_path : string list; + hidden_source_path : string list; cmi_path : string list; cmt_path : string list; extensions : string list; @@ -105,6 +106,8 @@ let dump_merlin x = `Assoc [ "build_path" , `List (List.map ~f:Json.string x.build_path); "source_path" , `List (List.map ~f:Json.string x.source_path); + "hidden_build_path" , `List (List.map ~f:Json.string x.hidden_build_path); + "hidden_source_path", `List (List.map ~f:Json.string x.hidden_source_path); "cmi_path" , `List (List.map ~f:Json.string x.cmi_path); "cmt_path" , `List (List.map ~f:Json.string x.cmt_path); "flags_applied", `List (List.map ~f:dump_flag_list x.flags_applied); @@ -235,10 +238,10 @@ let rec normalize t = let merge_merlin_config dot merlin ~failures ~config_path = { merlin with - build_path = dot.Mconfig_dot.build_path @ merlin.build_path; + build_path = dot.build_path @ merlin.build_path; source_path = dot.source_path @ merlin.source_path; - cmi_path = dot.cmi_path @ merlin.cmi_path; - cmt_path = dot.cmt_path @ merlin.cmt_path; + hidden_build_path = dot.hidden_build_path @ merlinhidden_build_path; + hidden_source_path = dot.hidden_source_path @ merlinhidden_source_path; exclude_query_dir = dot.exclude_query_dir || merlin.exclude_query_dir; use_ppx_cache = dot.use_ppx_cache || merlin.use_ppx_cache; extensions = dot.extensions @ merlin.extensions; @@ -276,6 +279,18 @@ let merlin_flags = [ {merlin with source_path = dir :: merlin.source_path}), " Add to merlin source path" ); + ( + "-hidden-build-path", + marg_path (fun dir merlin -> + {merlin with hidden_build_path = dir :: merlin.hidden_build_path}), + " Add to merlin hidden build path" + ); + ( + "-hidden-source-path", + marg_path (fun dir merlin -> + {merlin with hidden_source_path = dir :: merlin.hidden_source_path}), + " Add to merlin hidden source path" + ); ( "-cmi-path", marg_path (fun dir merlin -> @@ -617,8 +632,9 @@ let initial = { }; merlin = { build_path = []; - hidden_path = []; source_path = []; + hidden_build_path = []; + hidden_source_path = []; cmi_path = []; cmt_path = []; extensions = []; @@ -764,8 +780,8 @@ let build_path config = ( result' ) -let hidden_path config = - config.merlin.hidden_path @ config.ocaml.hidden_dirs +let hidden_build_path config = + config.merlin.hidden_build_path @ config.ocaml.hidden_dirs let cmt_path config = ( let dirs = diff --git a/src/kernel/mconfig.mli b/src/kernel/mconfig.mli index 2aa395b7a4..0111f6c125 100644 --- a/src/kernel/mconfig.mli +++ b/src/kernel/mconfig.mli @@ -29,8 +29,9 @@ val dump_ocaml : ocaml -> json type merlin = { build_path : string list; - hidden_path : string list; source_path : string list; + hidden_build_path : string list; + hidden_source_path : string list; cmi_path : string list; cmt_path : string list; extensions : string list; @@ -115,7 +116,7 @@ val source_path : t -> string list val build_path : t -> string list -val hidden_path : t -> string list +val hidden_build_path : t -> string list val cmt_path : t -> string list diff --git a/src/kernel/mconfig_dot.ml b/src/kernel/mconfig_dot.ml index a4d7ff1a9c..a5303f7a53 100644 --- a/src/kernel/mconfig_dot.ml +++ b/src/kernel/mconfig_dot.ml @@ -34,8 +34,9 @@ type directive = Merlin_dot_protocol.directive type config = { build_path : string list; - hidden_path : string list; source_path : string list; + hidden_build_path : string list; + hidden_source_path : string list; cmi_path : string list; cmt_path : string list; flags : string list with_workdir list; @@ -49,7 +50,8 @@ type config = { let empty_config = { build_path = []; - hidden_path = []; + hidden_build_path =[]; + hidden_source_path = []; source_path = []; cmi_path = []; cmt_path = []; @@ -236,8 +238,9 @@ let prepend_config ~dir:cwd configurator (directives : directive list) config = List.fold_left ~init:(config, []) ~f:(fun (config, errors) -> function | `B path -> {config with build_path = path :: config.build_path}, errors - | `H path -> {config with hidden_path = path :: config.hidden_path}, errors | `S path -> {config with source_path = path :: config.source_path}, errors + | `BH path -> {config with hidden_build_path = path :: config.hidden_build_path}, errors + | `SH path -> {config with hidden_source_path = path :: config.hidden_source_path}, errors | `CMI path -> {config with cmi_path = path :: config.cmi_path}, errors | `CMT path -> {config with cmt_path = path :: config.cmt_path}, errors | `EXT exts -> @@ -270,8 +273,9 @@ let postprocess_config config = let clean list = List.rev (List.filter_dup list) in { build_path = clean config.build_path; - hidden_path = clean config.hidden_path; source_path = clean config.source_path; + hidden_build_path = clean config.hidden_build_path; + hidden_source_path = clean config.hidden_source_path; cmi_path = clean config.cmi_path; cmt_path = clean config.cmt_path; extensions = clean config.extensions; diff --git a/src/kernel/mconfig_dot.mli b/src/kernel/mconfig_dot.mli index 8e10e2e648..b31f31b36f 100644 --- a/src/kernel/mconfig_dot.mli +++ b/src/kernel/mconfig_dot.mli @@ -36,8 +36,9 @@ end type config = { build_path : string list; - hidden_path : string list; source_path : string list; + hidden_build_path : string list; + hidden_source_path : string list; cmi_path : string list; cmt_path : string list; flags : string list with_workdir list; diff --git a/src/kernel/mocaml.ml b/src/kernel/mocaml.ml index 833db64fe8..95f87afc24 100644 --- a/src/kernel/mocaml.ml +++ b/src/kernel/mocaml.ml @@ -47,7 +47,7 @@ let setup_reader_config config = ( let setup_typer_config config = ( setup_reader_config config; let visible = Mconfig.build_path config in - let hidden = Mconfig.hidden_path config in + let hidden = Mconfig.hidden_build_path config in Load_path.(init ~auto_include:no_auto_include ~visible ~hidden); ) diff --git a/tests/test-dirs/config/dot-merlin-reader/quoting.t b/tests/test-dirs/config/dot-merlin-reader/quoting.t index b9ae8c7eee..f8d0604e58 100644 --- a/tests/test-dirs/config/dot-merlin-reader/quoting.t +++ b/tests/test-dirs/config/dot-merlin-reader/quoting.t @@ -14,6 +14,8 @@ { "build_path": [], "source_path": [], + "hidden_build_path": [], + "hidden_source_path": [], "cmi_path": [], "cmt_path": [], "flags_applied": [