File tree Expand file tree Collapse file tree 6 files changed +20
-4
lines changed Expand file tree Collapse file tree 6 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ module Arg = struct
12
12
; mutable stdio : bool
13
13
; mutable spec : (string * Arg .spec * string ) list
14
14
; mutable clientProcessId : int option
15
+ ; mutable cachePeriod : int option
15
16
}
16
17
17
18
let port t ~name ~description =
@@ -30,6 +31,7 @@ module Arg = struct
30
31
; stdio = false
31
32
; spec = []
32
33
; clientProcessId = None
34
+ ; cachePeriod = None
33
35
}
34
36
in
35
37
let spec =
@@ -52,7 +54,7 @@ module Arg = struct
52
54
53
55
let clientProcessId t = t.clientProcessId
54
56
55
- let channel { pipe; port; stdio; spec = _ ; clientProcessId = _ } :
57
+ let channel { pipe; port; stdio; spec = _ ; clientProcessId = _ ; cachePeriod = _ } :
56
58
(Channel. t , string ) result =
57
59
match (pipe, port, stdio) with
58
60
| None , None , _ -> Ok Stdio
Original file line number Diff line number Diff line change @@ -5,13 +5,16 @@ let () =
5
5
Printexc. record_backtrace true ;
6
6
let version = ref false in
7
7
let read_dot_merlin = ref false in
8
+ let cache_period = ref None in
8
9
let arg = Lsp.Cli.Arg. create () in
9
10
let spec =
10
11
[ (" --version" , Arg. Set version, " print version" )
11
12
; ( " --fallback-read-dot-merlin"
12
13
, Arg. Set read_dot_merlin
13
14
, " read Merlin config from .merlin files. The `dot-merlin-reader` \
14
15
package must be installed" )
16
+ ; ( " --cache-period" , Arg. Int (fun period -> cache_period := Some period)
17
+ , " set the Merlin file cache period" )
15
18
]
16
19
@ Cli.Arg. spec arg
17
20
in
@@ -39,7 +42,8 @@ let () =
39
42
let module Exn_with_backtrace = Stdune. Exn_with_backtrace in
40
43
match
41
44
Exn_with_backtrace. try_with
42
- (Ocaml_lsp_server. run channel ~read_dot_merlin: ! read_dot_merlin)
45
+ (Ocaml_lsp_server. run channel ~read_dot_merlin: ! read_dot_merlin
46
+ ~cache_period: ! cache_period)
43
47
with
44
48
| Ok () -> ()
45
49
| Error exn ->
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ module List = struct
47
47
let filter_dup lst = filter_dup' ~equiv: (fun x -> x) lst
48
48
end
49
49
50
+ let cache_period = ref None
51
+
50
52
module Config = struct
51
53
type t =
52
54
{ build_path : string list
@@ -60,6 +62,7 @@ module Config = struct
60
62
; reader : string list
61
63
; exclude_query_dir : bool
62
64
; use_ppx_cache : bool
65
+ ; cache_period : int option
63
66
}
64
67
65
68
let empty =
@@ -74,6 +77,7 @@ module Config = struct
74
77
; reader = []
75
78
; exclude_query_dir = false
76
79
; use_ppx_cache = false
80
+ ; cache_period = None
77
81
}
78
82
79
83
(* Parses suffixes pairs that were supplied as whitespace separated pairs
@@ -133,6 +137,7 @@ module Config = struct
133
137
; reader = config.reader
134
138
; exclude_query_dir = config.exclude_query_dir
135
139
; use_ppx_cache = config.use_ppx_cache
140
+ ; cache_period = config.cache_period
136
141
}
137
142
138
143
let merge t (merlin : Mconfig.merlin ) failures config_path =
@@ -149,6 +154,7 @@ module Config = struct
149
154
; flags_to_apply = t.flags @ merlin.flags_to_apply
150
155
; failures = failures @ merlin.failures
151
156
; config_path = Some config_path
157
+ ; cache_period = Option. value ! cache_period ~default: merlin.cache_period
152
158
}
153
159
end
154
160
Original file line number Diff line number Diff line change 6
6
7
7
val should_read_dot_merlin : bool ref
8
8
9
+ val cache_period : int option ref
10
+
9
11
val config : t -> Mconfig .t Fiber .t
10
12
11
13
val destroy : t -> unit Fiber .t
Original file line number Diff line number Diff line change @@ -917,10 +917,12 @@ let run_in_directory =
917
917
let for_windows = ! Merlin_utils.Std.System. run_in_directory in
918
918
fun () -> if Sys. win32 then for_windows else run_in_directory
919
919
920
- let run channel ~read_dot_merlin () =
920
+ let run channel ~read_dot_merlin ~ cache_period () =
921
921
Merlin_utils.Lib_config. set_program_name " ocamllsp" ;
922
922
Merlin_utils.Lib_config.System. set_run_in_directory (run_in_directory () );
923
923
Merlin_config. should_read_dot_merlin := read_dot_merlin;
924
+ Merlin_config. cache_period := cache_period;
925
+
924
926
Unix. putenv " __MERLIN_MASTER_PID" (string_of_int (Unix. getpid () ));
925
927
Lev_fiber. run ~sigpipe: `Ignore (fun () ->
926
928
let * input, output = stream_of_channel channel in
Original file line number Diff line number Diff line change 1
- val run : Lsp.Cli.Channel .t -> read_dot_merlin :bool -> unit -> unit
1
+ val run : Lsp.Cli.Channel .t -> read_dot_merlin :bool -> cache_period : int option -> unit -> unit
2
2
3
3
module Diagnostics = Diagnostics
4
4
module Version = Version
You can’t perform that action at this time.
0 commit comments