Skip to content

Commit 915dcd5

Browse files
authored
feature: support --clientProcessId argument (#1074)
It does nothing for now, but it's in the standard so it's better to at least explicitly ignore it. Signed-off-by: Rudi Grinberg <[email protected]>
1 parent d35053c commit 915dcd5

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
- Fix the type of DocumentSelector in cram document registration (#1068)
2323

24+
- Accept the `--clientProcessId` command line argument. (#1074)
25+
2426
## Features
2527
- Add "Remove type annotation" code action. (#1039)
2628

lsp/src/cli.ml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,39 @@ module Arg = struct
1111
; mutable port : int option
1212
; mutable stdio : bool
1313
; mutable spec : (string * Arg.spec * string) list
14+
; mutable clientProcessId : int option
1415
}
1516

1617
let create () =
17-
let t = { pipe = None; port = None; stdio = false; spec = [] } in
18+
let t =
19+
{ pipe = None
20+
; port = None
21+
; stdio = false
22+
; spec = []
23+
; clientProcessId = None
24+
}
25+
in
1826
let spec =
1927
[ ("--pipe", Arg.String (fun p -> t.pipe <- Some p), "set pipe path")
2028
; ("--socket", Arg.Int (fun p -> t.port <- Some p), "set port")
2129
; ("--stdio", Arg.Unit (fun () -> t.stdio <- true), "set stdio")
2230
; ( "--node-ipc"
2331
, Arg.Unit (fun () -> raise @@ Arg.Bad "node-ipc isn't supported")
2432
, "not supported" )
33+
; ( "--clientProcessId"
34+
, Arg.Int (fun pid -> t.clientProcessId <- Some pid)
35+
, "set the pid of the lsp client" )
2536
]
2637
in
2738
t.spec <- spec;
2839
t
2940

3041
let spec t = t.spec
3142

32-
let read { pipe; port; stdio; spec = _ } : (Channel.t, string) result =
43+
let clientProcessId t = t.clientProcessId
44+
45+
let read { pipe; port; stdio; spec = _; clientProcessId = _ } :
46+
(Channel.t, string) result =
3347
match (pipe, port, stdio) with
3448
| None, None, _ -> Ok Stdio
3549
| Some p, None, false -> Ok (Pipe p)

lsp/src/cli.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ module Arg : sig
1313
val spec : t -> (string * Arg.spec * string) list
1414

1515
val read : t -> (Channel.t, string) result
16+
17+
val clientProcessId : t -> int option
1618
end

ocaml-lsp-server/bin/main.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ let () =
1616
@ Cli.Arg.spec arg
1717
in
1818
let usage =
19-
"ocamllsp [ --stdio | --socket SOCKET --port PORT | --pipe PIPE ]"
19+
"ocamllsp [ --stdio | --socket SOCKET --port PORT | --pipe PIPE ] [ \
20+
--clientProcessId pid ]"
2021
in
2122
Arg.parse
2223
spec

0 commit comments

Comments
 (0)