MCPcopy Create free account
hub / github.com/arctic-cli/interface / create

Function create

packages/arctic/src/lsp/client.ts:39–216  ·  view source on GitHub ↗
(input: { serverID: string; server: LSPServer.Handle; root: string })

Source from the content-addressed store, hash-verified

37 }
38
39 export async function create(input: { serverID: string; server: LSPServer.Handle; root: string }) {
40 const l = log.clone().tag("serverID", input.serverID)
41 l.info("starting client")
42
43 const connection = createMessageConnection(
44 new StreamMessageReader(input.server.process.stdout as any),
45 new StreamMessageWriter(input.server.process.stdin as any),
46 )
47
48 const diagnostics = new Map<string, Diagnostic[]>()
49 connection.onNotification("textDocument/publishDiagnostics", (params) => {
50 const path = fileURLToPath(params.uri)
51 l.info("textDocument/publishDiagnostics", {
52 path,
53 })
54 const exists = diagnostics.has(path)
55 diagnostics.set(path, params.diagnostics)
56 if (!exists && input.serverID === "typescript") return
57 Bus.publish(Event.Diagnostics, { path, serverID: input.serverID })
58 })
59 connection.onRequest("window/workDoneProgress/create", (params) => {
60 l.info("window/workDoneProgress/create", params)
61 return null
62 })
63 connection.onRequest("workspace/configuration", async () => {
64 // Return server initialization options
65 return [input.server.initialization ?? {}]
66 })
67 connection.onRequest("client/registerCapability", async () => {})
68 connection.onRequest("client/unregisterCapability", async () => {})
69 connection.onRequest("workspace/workspaceFolders", async () => [
70 {
71 name: "workspace",
72 uri: pathToFileURL(input.root).href,
73 },
74 ])
75 connection.listen()
76
77 l.info("sending initialize")
78 await withTimeout(
79 connection.sendRequest("initialize", {
80 rootUri: pathToFileURL(input.root).href,
81 processId: input.server.process.pid,
82 workspaceFolders: [
83 {
84 name: "workspace",
85 uri: pathToFileURL(input.root).href,
86 },
87 ],
88 initializationOptions: {
89 ...input.server.initialization,
90 },
91 capabilities: {
92 window: {
93 workDoneProgress: true,
94 },
95 workspace: {
96 configuration: true,

Callers

nothing calls this directly

Calls 3

withTimeoutFunction · 0.90
setMethod · 0.45
publishMethod · 0.45

Tested by

no test coverage detected