chore: more work on the lsp
This commit is contained in:
parent
7b1e9e063e
commit
d2d5a279ad
2
index.ts
2
index.ts
@ -15,6 +15,6 @@ const res = parseLsp(file);
|
|||||||
fs.writeFileSync('./res', res.text);
|
fs.writeFileSync('./res', res.text);
|
||||||
|
|
||||||
//const diag = await diagnosticsRequests(res);
|
//const diag = await diagnosticsRequests(res);
|
||||||
const diag = await getDiagnostics(file);
|
//const diag = await getDiagnostics(file);
|
||||||
|
|
||||||
//add_personal(['AutoML']);
|
//add_personal(['AutoML']);
|
||||||
|
@ -6,7 +6,7 @@ export async function add_personal(words: string[]): Promise<void> {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'authorization': process.env.AUTHORIZATION ?? '',
|
'authorization': process.env.AUTHORIZATION_MY_LTEX ?? '',
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
16
lsp.ts
16
lsp.ts
@ -187,11 +187,19 @@ async function handleJSON(req: RPCRequest) {
|
|||||||
const character = req.params.range.start.character;
|
const character = req.params.range.start.character;
|
||||||
const line = req.params.range.start.line;
|
const line = req.params.range.start.line;
|
||||||
|
|
||||||
|
if (!req.params.context?.diagnostics[0]) {
|
||||||
|
sendRPCMessage(req, [{
|
||||||
|
title: "No diagnostics found in this file"
|
||||||
|
}]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let item: GetDiagnosticsReturn | undefined = undefined;
|
let item: GetDiagnosticsReturn | undefined = undefined;
|
||||||
|
|
||||||
console.log(JSON.stringify(req.params));
|
console.log(JSON.stringify(req.params) + "\n\n\n");
|
||||||
|
console.log(JSON.stringify(req.params.context.diagnostics[0]) + "\n\n\n");
|
||||||
|
|
||||||
if (!req.params.context?.diagnostics || !req.params.context?.diagnostics[0] || typeof req.params.context?.diagnostics[0].data != 'number') {
|
if (typeof req.params.context?.diagnostics[0].data != 'number') {
|
||||||
for (const _item of saved) {
|
for (const _item of saved) {
|
||||||
if (_item.range.end.line >= line && _item.range.start.line <= line) {
|
if (_item.range.end.line >= line && _item.range.start.line <= line) {
|
||||||
if (_item.range.end.character >= character && _item.range.start.character <= line) {
|
if (_item.range.end.character >= character && _item.range.start.character <= line) {
|
||||||
@ -218,7 +226,7 @@ async function handleJSON(req: RPCRequest) {
|
|||||||
}]);
|
}]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const items: {
|
const items: {
|
||||||
title: string,
|
title: string,
|
||||||
edit?: {
|
edit?: {
|
||||||
@ -236,7 +244,7 @@ async function handleJSON(req: RPCRequest) {
|
|||||||
changes: {
|
changes: {
|
||||||
[reqO.params.textDocument.uri]: [
|
[reqO.params.textDocument.uri]: [
|
||||||
{
|
{
|
||||||
range: item!.range,
|
range: reqO.params.context.diagnostics[0].range,
|
||||||
newText: value
|
newText: value
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
24
lsp_run.ts
24
lsp_run.ts
@ -2,12 +2,24 @@ import { error, handleData, log } from "./lsp";
|
|||||||
|
|
||||||
console.log = log;
|
console.log = log;
|
||||||
|
|
||||||
process.stdin.resume();
|
log('Started the server logging');
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
log('Listening for Input')
|
||||||
|
process.stdin.resume();
|
||||||
|
} catch (e: any) {
|
||||||
|
log('failed to listen to the stdin');
|
||||||
|
log(e.toString());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
process.stdin.on('data', function(data) {
|
process.stdin.on('data', function(data) {
|
||||||
try {
|
log('Got the data function');
|
||||||
handleData(data);
|
try {
|
||||||
} catch (e) {
|
handleData(data);
|
||||||
error("TRY GOT ERROR:" + e)
|
} catch (e) {
|
||||||
}
|
log("got here")
|
||||||
|
error("TRY GOT ERROR:" + e)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user