lsp progress
This commit is contained in:
+22
-10
@@ -1,24 +1,36 @@
|
|||||||
use lsp_types;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
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() {
|
pub fn run_lsp_server() {
|
||||||
let clpattern = Lazy::new(|| Regex::new(r"Content-Length: (\d+)\n").unwrap());
|
if Path::new("/Users/klestiselimaj/work/wyst/log.txt").exists() {
|
||||||
let mut sin = stdin();
|
fs::remove_file("/Users/klestiselimaj/work/wyst/log.txt");
|
||||||
let mut sout = stdout();
|
}
|
||||||
|
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 {
|
loop {
|
||||||
let mut input = String::new();
|
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) {
|
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];
|
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");
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ use clap::Parser;
|
|||||||
use parser::new_vars;
|
use parser::new_vars;
|
||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
use transpiler::Transpiler;
|
use transpiler::Transpiler;
|
||||||
mod lspcom;
|
|
||||||
|
|
||||||
use crate::lsp::run_lsp_server;
|
use crate::lsp::run_lsp_server;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user