lsp progress

This commit is contained in:
2024-06-06 04:23:24 +02:00
parent ee4b8e5891
commit a11ca49c35
2 changed files with 23 additions and 12 deletions
+23 -11
View File
@@ -1,24 +1,36 @@
use lsp_types;
use once_cell::sync::Lazy;
use regex::Regex;
use std::io::{stdin, stdout, Read};
use serde_json::{self, Value};
use std::{
fs::{self, File},
io::{stdin, Read, Write},
path::Path,
};
pub fn run_lsp_server() {
let clpattern = Lazy::new(|| Regex::new(r"Content-Length: (\d+)\n").unwrap());
let mut sin = stdin();
let mut sout = stdout();
if Path::new("/Users/klestiselimaj/work/wyst/log.txt").exists() {
fs::remove_file("/Users/klestiselimaj/work/wyst/log.txt");
}
let mut file = File::create("/Users/klestiselimaj/work/wyst/log.txt").expect("err_log");
let clpattern = Lazy::new(|| Regex::new(r"^Content-Length: (\d+)").unwrap());
let mut reader = stdin();
// let mut sout = stdout();
println!("ok");
writeln!(file, "It's running!");
loop {
let mut input = String::new();
let _ = sin.read_line(&mut input);
let _ = reader.read_line(&mut input);
writeln!(file, "{}", &input);
if let Some(caps) = clpattern.captures(&input) {
let conent_len = *(&caps[1].parse::<usize>().unwrap());
let conent_len = *(&caps[1].parse::<usize>().unwrap()) + 2;
writeln!(file, "ok {}", conent_len);
let mut buf = vec![0u8; conent_len];
sin.read_exact(&mut buf);
let _ = reader.read_exact(&mut buf);
let json_string = String::from_utf8(buf).expect("Our bytes should be valid utf8");
writeln!(file, "{}", &json_string);
let client_json: Value = serde_json::from_str(&json_string).expect("err_json");
writeln!(file, "bruh {}", &client_json["method"].as_str().unwrap());
}
}
}
}
-1
View File
@@ -7,7 +7,6 @@ use clap::Parser;
use parser::new_vars;
use std::{fs, path::Path};
use transpiler::Transpiler;
mod lspcom;
use crate::lsp::run_lsp_server;