add djls-python crate (#1)

* add djls-pyenv crate

* add implementation

* remove newline

* rename field

* rename crate
This commit is contained in:
Josh Thomas 2024-12-05 11:33:54 -06:00 committed by GitHub
parent 17b7974b7d
commit 931c0bc9fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 359 additions and 1 deletions

View file

@ -3,9 +3,12 @@ use tower_lsp::jsonrpc::Result as LspResult;
use tower_lsp::lsp_types::*;
use tower_lsp::{Client, LanguageServer, LspService, Server};
use djls_python::PythonEnvironment;
#[derive(Debug)]
struct Backend {
client: Client,
python: PythonEnvironment,
}
#[tower_lsp::async_trait]
@ -30,6 +33,10 @@ impl LanguageServer for Backend {
self.client
.log_message(MessageType::INFO, "server initialized!")
.await;
self.client
.log_message(MessageType::INFO, format!("\n{}", self.python))
.await;
}
async fn shutdown(&self) -> LspResult<()> {
@ -39,10 +46,12 @@ impl LanguageServer for Backend {
#[tokio::main]
async fn main() -> Result<()> {
let python = PythonEnvironment::initialize()?;
let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout();
let (service, socket) = LspService::build(|client| Backend { client }).finish();
let (service, socket) = LspService::build(|client| Backend { client, python }).finish();
Server::new(stdin, stdout, socket).serve(service).await;