-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle custom
PeekDocumentsRequest
to show macro expansions in a pe…
…eked editor
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as vscode from "vscode"; | ||
import * as langclient from "vscode-languageclient/node"; | ||
import { PeekDocumentsParams, PeekDocumentsRequest } from "./lspExtensions"; | ||
|
||
export function activatePeekDocuments(client: langclient.LanguageClient): vscode.Disposable { | ||
const peekDocuments = client.onRequest( | ||
PeekDocumentsRequest.method, | ||
async (params: PeekDocumentsParams) => { | ||
const locations = params.locations.map(uri => { | ||
const location = new vscode.Location( | ||
vscode.Uri.from({ | ||
scheme: "file", | ||
path: new URL(uri).pathname, | ||
}), | ||
new vscode.Position(0, 0) | ||
); | ||
|
||
return location; | ||
}); | ||
|
||
await vscode.commands.executeCommand( | ||
"editor.action.peekLocations", | ||
vscode.Uri.from({ | ||
scheme: "file", | ||
path: new URL(params.uri).pathname, | ||
}), | ||
new vscode.Position(params.position.line, params.position.character), | ||
locations, | ||
"peek" | ||
); | ||
|
||
return { success: true }; | ||
} | ||
); | ||
|
||
return peekDocuments; | ||
} |