Skip to content

Commit

Permalink
config: accept INDEX_FILE directive
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Nov 15, 2023
1 parent 6462cf3 commit a2d483a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/dot-merlin/dot_merlin_reader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ type config = {
pass_forward : Merlin_dot_protocol.Directive.no_processing_required list;
to_canonicalize : (string * Merlin_dot_protocol.Directive.include_path) list;
stdlib : string option;
index_file : string option;
packages_to_load : string list;
findlib : string option;
findlib_path : string list;
Expand All @@ -315,6 +316,7 @@ let empty_config = {
pass_forward = [];
to_canonicalize = [];
stdlib = None;
index_file = None;
packages_to_load = [];
findlib = None;
findlib_path = [];
Expand All @@ -339,6 +341,14 @@ let prepend_config ~cwd ~cfg =
log ~title:"conflicting paths for stdlib" "%s\n%s" p canon_path
end;
{ cfg with stdlib = Some canon_path }
| `INDEX_FILE path ->
let canon_path = canonicalize_filename ~cwd path in
begin match cfg.index_file with
| None -> ()
| Some p ->
log ~title:"conflicting paths for index file" "%s\n%s" p canon_path
end;
{ cfg with index_file = Some canon_path }
| `FINDLIB path ->
let canon_path = canonicalize_filename ~cwd path in
begin match cfg.stdlib with
Expand Down
3 changes: 3 additions & 0 deletions src/dot-protocol/merlin_dot_protocol.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module Directive = struct
[ `EXT of string list
| `FLG of string list
| `STDLIB of string
| `INDEX_FILE of string
| `SUFFIX of string
| `READER of string list
| `EXCLUDE_QUERY_DIR
Expand Down Expand Up @@ -85,6 +86,7 @@ module Sexp = struct
| "CMI" -> `CMI value
| "CMT" -> `CMT value
| "STDLIB" -> `STDLIB value
| "INDEX_FILE" -> `INDEX_FILE value
| "SUFFIX" -> `SUFFIX value
| "ERROR" -> `ERROR_MSG value
| "FLG" ->
Expand Down Expand Up @@ -117,6 +119,7 @@ module Sexp = struct
| `EXT ss -> ("EXT", [ List (atoms_of_strings ss) ])
| `FLG ss -> ("FLG", [ List (atoms_of_strings ss) ])
| `STDLIB s -> ("STDLIB", single s)
| `INDEX_FILE s -> ("INDEX_FILE", single s)
| `SUFFIX s -> ("SUFFIX", single s)
| `READER ss -> ("READER", [ List (atoms_of_strings ss) ])
| `EXCLUDE_QUERY_DIR -> ("EXCLUDE_QUERY_DIR", [])
Expand Down
1 change: 1 addition & 0 deletions src/dot-protocol/merlin_dot_protocol.mli
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module Directive : sig
[ `EXT of string list
| `FLG of string list
| `STDLIB of string
| `INDEX_FILE of string
| `SUFFIX of string
| `READER of string list
| `EXCLUDE_QUERY_DIR
Expand Down
4 changes: 4 additions & 0 deletions src/kernel/mconfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type merlin = {
extensions : string list;
suffixes : (string * string) list;
stdlib : string option;
index_file : string option;
reader : string list;
protocol : [`Json | `Sexp];
log_file : string option;
Expand Down Expand Up @@ -115,6 +116,7 @@ let dump_merlin x =
]) x.suffixes
);
"stdlib" , Json.option Json.string x.stdlib;
"index_file" , Json.option Json.string x.index_file;
"reader" , `List (List.map ~f:Json.string x.reader);
"protocol" , (match x.protocol with
| `Json -> `String "json"
Expand Down Expand Up @@ -251,6 +253,7 @@ let get_external_config path t =
extensions = dot.extensions @ merlin.extensions;
suffixes = dot.suffixes @ merlin.suffixes;
stdlib = (if dot.stdlib = None then merlin.stdlib else dot.stdlib);
index_file = dot.index_file;
reader =
if dot.reader = []
then merlin.reader
Expand Down Expand Up @@ -623,6 +626,7 @@ let initial = {
extensions = [];
suffixes = [(".ml", ".mli"); (".re", ".rei")];
stdlib = None;
index_file = None;
reader = [];
protocol = `Json;
log_file = None;
Expand Down
3 changes: 2 additions & 1 deletion src/kernel/mconfig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type merlin = {
extensions : string list;
suffixes : (string * string) list;
stdlib : string option;
index_file : string option;
reader : string list;
protocol : [`Json | `Sexp];
log_file : string option;
Expand All @@ -57,7 +58,7 @@ val dump_merlin : merlin -> json

(** {1 Some flags affecting queries} *)

module Verbosity : sig
module Verbosity : sig
type t = Smart | Lvl of int

(** the default value for verbosity, i.e., [Lvl 0] *)
Expand Down
9 changes: 7 additions & 2 deletions src/kernel/mconfig_dot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type config = {
extensions : string list;
suffixes : (string * string) list;
stdlib : string option;
index_file : string option;
reader : string list;
exclude_query_dir : bool;
use_ppx_cache : bool;
Expand All @@ -55,6 +56,7 @@ let empty_config = {
suffixes = [];
flags = [];
stdlib = None;
index_file = None;
reader = [];
exclude_query_dir = false;
use_ppx_cache = false;
Expand Down Expand Up @@ -246,6 +248,8 @@ let prepend_config ~dir:cwd configurator (directives : directive list) config =
{config with flags = flags :: config.flags}, errors
| `STDLIB path ->
{config with stdlib = Some path}, errors
| `INDEX_FILE path ->
{config with index_file = Some path}, errors
| `READER reader ->
{config with reader}, errors
| `EXCLUDE_QUERY_DIR ->
Expand Down Expand Up @@ -273,8 +277,9 @@ let postprocess_config config =
extensions = clean config.extensions;
suffixes = clean config.suffixes;
flags = clean config.flags;
stdlib = config.stdlib;
reader = config.reader;
stdlib = config.stdlib;
index_file = config.index_file;
reader = config.reader;
exclude_query_dir = config.exclude_query_dir;
use_ppx_cache = config.use_ppx_cache;
}
Expand Down
1 change: 1 addition & 0 deletions src/kernel/mconfig_dot.mli
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type config = {
extensions : string list;
suffixes : (string * string) list;
stdlib : string option;
index_file : string option;
reader : string list;
exclude_query_dir : bool;
use_ppx_cache : bool;
Expand Down

0 comments on commit a2d483a

Please sign in to comment.