Get clangd working for C/C++/Objective-C

This commit is contained in:
Radon Rosborough 2020-07-05 12:54:05 -06:00
parent 404aeef235
commit 67cb37423c
4 changed files with 17 additions and 1 deletions

View File

@ -250,7 +250,9 @@ export class Session {
this.lsp.reader.listen((data) => {
this.ws.send(JSON.stringify({ event: "lspOutput", output: data }));
});
this.ws.send(JSON.stringify({ event: "lspStarted" }));
this.ws.send(
JSON.stringify({ event: "lspStarted", root: `/tmp/riju/${this.uuid}` })
);
}
};
cleanup = async () => {

View File

@ -147,6 +147,7 @@ implement main0 () = ()
main: "main.c",
compile: "clang -Wall -Wextra main.c -o main",
run: "./main",
lsp: "clangd",
template: `#include <stdio.h>
int main() {

View File

@ -22,6 +22,7 @@ const DEBUG = window.location.hash === "#debug";
interface RijuConfig {
id: string;
monacoLang: string;
main: string;
lspInit?: any;
lspConfig?: any;
template: string;
@ -151,6 +152,17 @@ async function main() {
term.write(message.output);
return;
case "lspStarted":
if (typeof message.root !== "string") {
console.error("Unexpected message from server:", message);
return;
}
editor.setModel(
monaco.editor.createModel(
editor.getModel()!.getValue(),
undefined,
monaco.Uri.parse(`file://${message.root}/${config.main}`)
)
);
const connection = createMessageConnection(
new RijuMessageReader(socket!),
new RijuMessageWriter(socket!)

View File

@ -30,6 +30,7 @@ beef
# C/C++
clang
clangd
# C#
mono-mcs