-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
21: Upgrade frontend to work with Aya language server r=ice1000 a=imkiva Changes: - Add middleware to workaround microsoft/vscode-languageserver-node#495 - Provide light and dark colors for semantic highlight - Upgrade some dependencies Co-authored-by: imkiva <imkiva@islovely.icu>
- Loading branch information
Showing
11 changed files
with
695 additions
and
1,049 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 @@ | ||
import { DocumentSelector } from "vscode-languageclient"; | ||
|
||
export const AYA_SELECTOR: DocumentSelector = [ | ||
{ language: 'aya', scheme: 'file' }, | ||
]; |
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 |
---|---|---|
@@ -1,24 +1,29 @@ | ||
import * as vscode from 'vscode'; | ||
import * as daemon from './server-daemon'; | ||
import * as find from './find'; | ||
import { AYA_SELECTOR } from "./constant"; | ||
import { UnicodeCompletionProvider } from "./unicode"; | ||
|
||
export async function activate(context: vscode.ExtensionContext) { | ||
let lspLoadPath = await find.findAya(); | ||
if (lspLoadPath === null) return; | ||
|
||
const initTasks: PromiseLike<void>[] = []; | ||
|
||
initTasks.push(vscode.window.withProgress({ | ||
location: vscode.ProgressLocation.Notification, | ||
cancellable: false, | ||
title: "Loading Aya library", | ||
}, async progress => { | ||
await daemon.startDaemon(context, lspLoadPath!, progress); | ||
await daemon.startDaemon(context, progress); | ||
return new Promise(resolve => setTimeout(resolve, 5000)); | ||
})); | ||
|
||
context.subscriptions.push(vscode.languages.registerCompletionItemProvider( | ||
AYA_SELECTOR, | ||
new UnicodeCompletionProvider(), | ||
"\\" | ||
)); | ||
|
||
await Promise.all(initTasks); | ||
} | ||
|
||
// this method is called when your extension is deactivated | ||
export function deactivate() { } | ||
export function deactivate() { | ||
} |
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,38 @@ | ||
import { Middleware, ResolveCodeLensSignature } from "vscode-languageclient"; | ||
import * as vscode from "vscode"; | ||
|
||
export class AyaMiddleware implements Middleware { | ||
public resolveCodeLens( | ||
codeLens: vscode.CodeLens, | ||
token: vscode.CancellationToken, | ||
next: ResolveCodeLensSignature | ||
): vscode.ProviderResult<vscode.CodeLens> { | ||
// see: https://github.com/microsoft/vscode-languageserver-node/issues/495 | ||
const javaResolved = next(codeLens, token); | ||
if ((javaResolved as Thenable<vscode.CodeLens>).then) | ||
return (javaResolved as Thenable<vscode.CodeLens>).then(fixCodeLens); | ||
else if (javaResolved as vscode.CodeLens) | ||
return fixCodeLens(javaResolved as vscode.CodeLens); | ||
else return javaResolved; | ||
} | ||
} | ||
|
||
function fixCodeLens(codeLens: vscode.CodeLens): vscode.CodeLens { | ||
if (codeLens.command?.command === "editor.action.showReferences") { | ||
const [javaUri, javaRange, usages] = codeLens.command.arguments!; | ||
codeLens.command.arguments = [ | ||
vscode.Uri.parse(javaUri), | ||
new vscode.Position(javaRange.line, javaRange.character), | ||
usages.map((loc: { uri: string, range: vscode.Range }) => new vscode.Location( | ||
vscode.Uri.parse(loc.uri.toString()), | ||
new vscode.Range( | ||
loc.range.start.line, | ||
loc.range.start.character, | ||
loc.range.end.line, | ||
loc.range.end.character) | ||
)), | ||
]; | ||
} | ||
|
||
return codeLens; | ||
} |
Oops, something went wrong.