-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lsp] [petanque] Allow access to
petanque
protocol from the lsp ser…
…ver. This will be very useful for quite a few users, in particular those willing to interact with Coq from an editor context. Things integrate pretty well, however we can still improve the codebase a bit; thus, this PR is wip, but usable for testing. Comments / todos: - note the lack of uniformity w.r.t. the cancellation token and Rq.serve, in particular `Rq.Immediate` and `Rq.query` with result `Now` should do the same. - the integration of start should be a bit better so we can use the `doc` provided in the handler callback.
- Loading branch information
Showing
12 changed files
with
183 additions
and
24 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
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
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,60 @@ | ||
import { window, InputBoxOptions, TextEditor } from "vscode"; | ||
import { BaseLanguageClient, RequestType } from "vscode-languageclient"; | ||
import { PetRunParams, PetStartParams } from "../lib/types"; | ||
|
||
const petStartReq = new RequestType<PetStartParams, number, void>( | ||
"petanque/start" | ||
); | ||
let client: BaseLanguageClient; | ||
|
||
export function petSetClient(newClient: BaseLanguageClient) { | ||
client = newClient; | ||
} | ||
|
||
export const petanqueStart = (editor: TextEditor) => { | ||
let uri = editor.document.uri.toString(); | ||
let pre_commands = null; | ||
|
||
// Imput theorem name | ||
let inputOptions: InputBoxOptions = { | ||
title: "Petanque Start", | ||
prompt: "Name of the theorem to start a session ", | ||
}; | ||
window | ||
.showInputBox(inputOptions) | ||
.then<PetStartParams>((thm_user) => { | ||
let thm = thm_user ?? "petanque_debug"; | ||
let params: PetStartParams = { uri, pre_commands, thm }; | ||
return Promise.resolve<PetStartParams>(params); | ||
}) | ||
.then((params: PetStartParams) => { | ||
client | ||
.sendRequest(petStartReq, params) | ||
.then((id) => | ||
window.setStatusBarMessage(`petanque/start succeed ${id}`, 5000) | ||
) | ||
.catch((error) => { | ||
let err_message = error.toString(); | ||
console.log(`error in save: ${err_message}`); | ||
window.showErrorMessage(err_message); | ||
}); | ||
}); | ||
}; | ||
|
||
const petRunReq = new RequestType<PetRunParams, any, void>("petanque/run"); | ||
|
||
export const petanqueRun = (editor: TextEditor) => { | ||
// XXX Read from user | ||
let params: PetRunParams = { st: 1, tac: "idtac." }; | ||
client | ||
.sendRequest(petRunReq, params) | ||
.then((answer: any) => { | ||
let res = JSON.stringify(answer); | ||
window.setStatusBarMessage(`petanque/run succeed ${res}`, 5000); | ||
}) | ||
.catch((error) => { | ||
let err_message = error.toString(); | ||
console.log(`error in save: ${err_message}`); | ||
window.showErrorMessage(err_message); | ||
}); | ||
}; |
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,2 @@ | ||
Theorem petanque_debug : True. | ||
Proof. now auto. Qed. |
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
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