create djls-cli and migrate serving LSP to it (#20)

This commit is contained in:
Josh Thomas 2024-12-11 10:23:35 -06:00 committed by GitHub
parent 2cbc24b5f0
commit 4c10afb602
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 46 additions and 4 deletions

View file

@ -3,11 +3,12 @@ members = ["crates/*"]
resolver = "2" resolver = "2"
[workspace.dependencies] [workspace.dependencies]
djls = { path = "crates/djls" }
djls-ast = { path = "crates/djls-ast" } djls-ast = { path = "crates/djls-ast" }
djls-cli = { path = "crates/djls-cli" }
djls-django = { path = "crates/djls-django" } djls-django = { path = "crates/djls-django" }
djls-ipc = { path = "crates/djls-ipc" } djls-ipc = { path = "crates/djls-ipc" }
djls-python = { path = "crates/djls-python" } djls-python = { path = "crates/djls-python" }
djls-server = { path = "crates/djls-server" }
djls-worker = { path = "crates/djls-worker" } djls-worker = { path = "crates/djls-worker" }
anyhow = "1.0.94" anyhow = "1.0.94"

View file

@ -0,0 +1,18 @@
[package]
name = "djls-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
djls-django = { workspace = true }
djls-server = { workspace = true }
anyhow = { workspace = true }
tokio = { workspace = true }
clap = { version = "4.5.23", features = ["derive"] }
tower-lsp = { version = "0.20.0", features = ["proposed"] }
[[bin]]
name = "djls"
path = "src/main.rs"

View file

@ -0,0 +1,24 @@
use clap::{Parser, Subcommand};
#[derive(Debug, Parser)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand)]
enum Commands {
/// Start the LSP server
Serve,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
match cli.command {
Commands::Serve => djls_server::serve().await?,
}
Ok(())
}

View file

@ -1,5 +1,5 @@
[package] [package]
name = "djls" name = "djls-server"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

View file

@ -80,8 +80,7 @@ impl LanguageServer for TowerLspBackend {
} }
} }
#[tokio::main] pub async fn serve() -> Result<()> {
async fn main() -> Result<()> {
let django = DjangoProject::setup()?; let django = DjangoProject::setup()?;
let stdin = tokio::io::stdin(); let stdin = tokio::io::stdin();