You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lsp4clj reads and writes from stdio, parsing JSON-RPC according to the LSP spec. It provides tools to allow server implementors to receive, process, and respond to any of the methods defined in the LSP spec, and to send their own requests and notifications to clients.
7
+
lsp4clj reads and writes from io streams, parsing JSON-RPC according to the LSP spec. It provides tools to allow server implementors to receive, process, and respond to any of the methods defined in the LSP spec, and to send their own requests and notifications to clients.
8
8
9
9
## Usage
10
10
@@ -119,15 +119,25 @@ First, if the server's input is closed, it will shut down too. Second, if you ca
119
119
120
120
Whenaservershutsdownitstopsreadinginput, finishesprocessingthemessagesithasinflight, andthenclosesisoutput.Finallyitclosesits `:log-ch` and `:trace-ch`.Assuch, itshouldprobablynotbeshutdownuntiltheLSP `exit` notification (as opposed to the `shutdown` request) toensureallmessagesarereceived. `lsp4clj.server/shutdown` willnotreturnuntilallmessageshavebeenprocessed, oruntil10secondshavepassed, whicheverhappenssooner.Itwillreturn `:done` inthefirstcaseand `:timeout` inthesecond.
121
121
122
-
### Socketserver
122
+
##Othertypesofservers
123
123
124
-
The `stdio-server` isthemostcommonlyused, butthelibraryalsoprovidesa `lsp4clj.socket-server/server`.
`lsp4clj.io-server/server` acceptsapairofoptions `:in` and `:out`.Thesewillbecoercedtoa `java.io.InputStream` and `java.io.OutputStream` via `clojure.java.io/input-stream` and `clojure.java.io/output-stream`, respectively.Theexampleaboveworksbecausea `java.net.Socket` canbecoercedtobothaninputandoutputstreamviathismechanism.
139
+
140
+
Asimilarapproachcanbeusedtoconnectoverpipes.
131
141
132
142
## Developmentdetails
133
143
@@ -156,7 +166,11 @@ You may also find `lsp4clj.server/chan-server` a useful alternative to `stdio-se
Fromexperience, it'sdismayinglyeasytoleaveinanerrant `prn` or `time` andendupwithanon-responsiveclient.Forthisreason, wehighlyrecommendsupportingcommunicationoversockets (see [other types of servers](#other-types-of-servers)) whichareimmunetothisproblem.However, sincethechoiceofwhethertousesocketsorstdioisultimatelyuptotheclient, youmayhavenochoicebuttosupportboth.
172
+
173
+
lsp4cljprovidesonetooltoavoidaccidentalwritestostdout (or rather to `*out*`, which is usually the same as `System.out`).Toprotectablockofcodefromwritingto `*out*`, wrapitwith `lsp4clj.server/discarding-stdout`.The `receive-notification` and `receive-request` multimethodsarealreadyprotectedthisway, buttasksstartedoutsideofthesemultimethodsorthatruninseparatethreadsneedthisprotectionadded.
0 commit comments