@@ -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