swap from IPC architecture to PyO3 library (#45)

This commit is contained in:
Josh Thomas 2024-12-23 10:12:10 -06:00 committed by GitHub
parent df30aafde5
commit a73e912e0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 136 additions and 2224 deletions

View file

@ -6,8 +6,6 @@ mod tasks;
use crate::notifier::TowerLspNotifier;
use crate::server::{DjangoLanguageServer, LspNotification, LspRequest};
use anyhow::Result;
use djls_django::DjangoProject;
use djls_ipc::PythonProcess;
use std::sync::Arc;
use tokio::sync::RwLock;
use tower_lsp::jsonrpc::Result as LspResult;
@ -81,15 +79,13 @@ impl LanguageServer for TowerLspBackend {
}
}
pub async fn serve(python: PythonProcess) -> Result<()> {
let django = DjangoProject::setup(python)?;
pub async fn serve() -> Result<()> {
let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout();
let (service, socket) = LspService::build(|client| {
let notifier = Box::new(TowerLspNotifier::new(client.clone()));
let server = DjangoLanguageServer::new(django, notifier);
let server = DjangoLanguageServer::new(notifier);
TowerLspBackend {
server: Arc::new(RwLock::new(server)),
}

View file

@ -2,7 +2,6 @@ use crate::documents::Store;
use crate::notifier::Notifier;
use crate::tasks::DebugTask;
use anyhow::Result;
use djls_django::DjangoProject;
use djls_worker::Worker;
use std::sync::Arc;
use std::time::Duration;
@ -24,18 +23,16 @@ pub enum LspNotification {
}
pub struct DjangoLanguageServer {
django: DjangoProject,
notifier: Arc<Box<dyn Notifier>>,
documents: Store,
worker: Worker,
}
impl DjangoLanguageServer {
pub fn new(django: DjangoProject, notifier: Box<dyn Notifier>) -> Self {
pub fn new(notifier: Box<dyn Notifier>) -> Self {
let notifier = Arc::new(notifier);
Self {
django,
notifier,
documents: Store::new(),
worker: Worker::new(),
@ -125,10 +122,6 @@ impl DjangoLanguageServer {
LspNotification::Initialized(_) => {
self.notifier
.log_message(MessageType::INFO, "server initialized!")?;
self.notifier
.log_message(MessageType::INFO, &format!("\n{}", self.django.py()))?;
self.notifier
.log_message(MessageType::INFO, &format!("\n{}", self.django))?;
Ok(())
}
LspNotification::Shutdown => Ok(()),