Skip to content

Commit 740e578

Browse files
committed
Merge LowLevelJumpHover into format
2 parents 7f59afa + 632558e commit 740e578

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

server/src/server.ts

+32
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,15 @@ process.on("message", (a: m.RequestMessage | m.NotificationMessage) => {
219219
} else if (aa.method === "initialize") {
220220
// send the list of features we support
221221
let result: p.InitializeResult = {
222+
// This tells the client: "hey, we support the following operations".
223+
// Example: we want to expose "jump-to-definition".
224+
// By adding `definitionProvider: true`, the client will now send "jump-to-definition" requests.
222225
capabilities: {
223226
// TODO: incremental sync?
224227
textDocumentSync: v.TextDocumentSyncKind.Full,
225228
documentFormattingProvider: true,
229+
hoverProvider: true,
230+
definitionProvider: true,
226231
},
227232
};
228233
let response: m.ResponseMessage = {
@@ -264,6 +269,33 @@ process.on("message", (a: m.RequestMessage | m.NotificationMessage) => {
264269
};
265270
process.send!(response);
266271
}
272+
} else if (aa.method === p.HoverRequest.method) {
273+
let dummyHoverResponse: m.ResponseMessage = {
274+
jsonrpc: c.jsonrpcVersion,
275+
id: aa.id,
276+
// type result = Hover | null
277+
// type Hover = {contents: MarkedString | MarkedString[] | MarkupContent, range?: Range}
278+
result: { contents: "Time to go for a 20k run!" },
279+
};
280+
281+
process.send!(dummyHoverResponse);
282+
} else if (aa.method === p.DefinitionRequest.method) {
283+
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
284+
let dummyDefinitionResponse: m.ResponseMessage = {
285+
jsonrpc: c.jsonrpcVersion,
286+
id: aa.id,
287+
// result should be: Location | Array<Location> | Array<LocationLink> | null
288+
result: {
289+
uri: aa.params.textDocument.uri,
290+
range: {
291+
start: { line: 2, character: 4 },
292+
end: { line: 2, character: 12 },
293+
},
294+
},
295+
// error: code and message set in case an exception happens during the definition request.
296+
};
297+
298+
process.send!(dummyDefinitionResponse);
267299
} else if (aa.method === p.DocumentFormattingRequest.method) {
268300
// technically, a formatting failure should reply with the error. Sadly
269301
// the LSP alert box for these error replies sucks (e.g. doesn't actually

0 commit comments

Comments
 (0)