-
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.
Merge pull request #778 from ejgallego/petanque_lsp
[lsp] [petanque] Allow access to `petanque` protocol from the lsp server
- Loading branch information
Showing
21 changed files
with
288 additions
and
65 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
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
Oops, something went wrong.