Skip to content

Commit

Permalink
Rename to cache_lifespan
Browse files Browse the repository at this point in the history
  • Loading branch information
3Rafal committed Nov 16, 2023
1 parent b4239c7 commit 03786ba
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
9 changes: 5 additions & 4 deletions ocaml-lsp-server/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ let () =
Printexc.record_backtrace true;
let version = ref false in
let read_dot_merlin = ref false in
let cache_period = ref None in
let cache_lifespan = ref None in
let arg = Lsp.Cli.Arg.create () in
let spec =
[ ("--version", Arg.Set version, "print version")
; ( "--fallback-read-dot-merlin"
, Arg.Set read_dot_merlin
, "read Merlin config from .merlin files. The `dot-merlin-reader` \
package must be installed" )
; ( "--cache-period", Arg.Int (fun period -> cache_period := Some period)
, "set the Merlin file cache period")
; ( "--merlin-cache-lifespan"
, Arg.Int (fun period -> cache_lifespan := Some period)
, "set the Merlin file cache lifespan")
]
@ Cli.Arg.spec arg
in
Expand Down Expand Up @@ -43,7 +44,7 @@ let () =
match
Exn_with_backtrace.try_with
(Ocaml_lsp_server.run channel ~read_dot_merlin:!read_dot_merlin
~cache_period:!cache_period)
~cache_lifespan:!cache_lifespan)
with
| Ok () -> ()
| Error exn ->
Expand Down
10 changes: 5 additions & 5 deletions ocaml-lsp-server/src/merlin_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module List = struct
let filter_dup lst = filter_dup' ~equiv:(fun x -> x) lst
end

let cache_period = ref None
let cache_lifespan = ref None

module Config = struct
type t =
Expand All @@ -62,7 +62,7 @@ module Config = struct
; reader : string list
; exclude_query_dir : bool
; use_ppx_cache : bool
; cache_period : int option
; cache_lifespan : int option
}

let empty =
Expand All @@ -77,7 +77,7 @@ module Config = struct
; reader = []
; exclude_query_dir = false
; use_ppx_cache = false
; cache_period = None
; cache_lifespan = None
}

(* Parses suffixes pairs that were supplied as whitespace separated pairs
Expand Down Expand Up @@ -137,7 +137,7 @@ module Config = struct
; reader = config.reader
; exclude_query_dir = config.exclude_query_dir
; use_ppx_cache = config.use_ppx_cache
; cache_period = config.cache_period
; cache_lifespan = config.cache_lifespan
}

let merge t (merlin : Mconfig.merlin) failures config_path =
Expand All @@ -154,7 +154,7 @@ module Config = struct
; flags_to_apply = t.flags @ merlin.flags_to_apply
; failures = failures @ merlin.failures
; config_path = Some config_path
; cache_period = Option.value !cache_period ~default:merlin.cache_period
; cache_lifespan = Option.value !cache_lifespan ~default:merlin.cache_lifespan
}
end

Expand Down
2 changes: 1 addition & 1 deletion ocaml-lsp-server/src/merlin_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type t

val should_read_dot_merlin : bool ref

val cache_period : int option ref
val cache_lifespan : int option ref

val config : t -> Mconfig.t Fiber.t

Expand Down
4 changes: 2 additions & 2 deletions ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -917,11 +917,11 @@ let run_in_directory =
let for_windows = !Merlin_utils.Std.System.run_in_directory in
fun () -> if Sys.win32 then for_windows else run_in_directory

let run channel ~read_dot_merlin ~cache_period () =
let run channel ~read_dot_merlin ~cache_lifespan () =
Merlin_utils.Lib_config.set_program_name "ocamllsp";
Merlin_utils.Lib_config.System.set_run_in_directory (run_in_directory ());
Merlin_config.should_read_dot_merlin := read_dot_merlin;
Merlin_config.cache_period := cache_period;
Merlin_config.cache_lifespan := cache_lifespan;

Unix.putenv "__MERLIN_MASTER_PID" (string_of_int (Unix.getpid ()));
Lev_fiber.run ~sigpipe:`Ignore (fun () ->
Expand Down
2 changes: 1 addition & 1 deletion ocaml-lsp-server/src/ocaml_lsp_server.mli
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val run : Lsp.Cli.Channel.t -> read_dot_merlin:bool -> cache_period:int option -> unit -> unit
val run : Lsp.Cli.Channel.t -> read_dot_merlin:bool -> cache_lifespan:int option -> unit -> unit

module Diagnostics = Diagnostics
module Version = Version

0 comments on commit 03786ba

Please sign in to comment.