Skip to content

Commit 4c10afb

Browse files
create djls-cli and migrate serving LSP to it (#20)
1 parent 2cbc24b commit 4c10afb

File tree

9 files changed

+46
-4
lines changed

9 files changed

+46
-4
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ members = ["crates/*"]
33
resolver = "2"
44

55
[workspace.dependencies]
6-
djls = { path = "crates/djls" }
76
djls-ast = { path = "crates/djls-ast" }
7+
djls-cli = { path = "crates/djls-cli" }
88
djls-django = { path = "crates/djls-django" }
99
djls-ipc = { path = "crates/djls-ipc" }
1010
djls-python = { path = "crates/djls-python" }
11+
djls-server = { path = "crates/djls-server" }
1112
djls-worker = { path = "crates/djls-worker" }
1213

1314
anyhow = "1.0.94"

crates/djlc-cli/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "djls-cli"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
djls-django = { workspace = true }
8+
djls-server = { workspace = true }
9+
10+
anyhow = { workspace = true }
11+
tokio = { workspace = true }
12+
13+
clap = { version = "4.5.23", features = ["derive"] }
14+
tower-lsp = { version = "0.20.0", features = ["proposed"] }
15+
16+
[[bin]]
17+
name = "djls"
18+
path = "src/main.rs"

crates/djlc-cli/src/main.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use clap::{Parser, Subcommand};
2+
3+
#[derive(Debug, Parser)]
4+
struct Cli {
5+
#[command(subcommand)]
6+
command: Commands,
7+
}
8+
9+
#[derive(Debug, Subcommand)]
10+
enum Commands {
11+
/// Start the LSP server
12+
Serve,
13+
}
14+
15+
#[tokio::main]
16+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
17+
let cli = Cli::parse();
18+
19+
match cli.command {
20+
Commands::Serve => djls_server::serve().await?,
21+
}
22+
23+
Ok(())
24+
}

crates/djls/Cargo.toml renamed to crates/djls-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "djls"
2+
name = "djls-server"
33
version = "0.1.0"
44
edition = "2021"
55

File renamed without changes.

crates/djls/src/main.rs renamed to crates/djls-server/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ impl LanguageServer for TowerLspBackend {
8080
}
8181
}
8282

83-
#[tokio::main]
84-
async fn main() -> Result<()> {
83+
pub async fn serve() -> Result<()> {
8584
let django = DjangoProject::setup()?;
8685

8786
let stdin = tokio::io::stdin();
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)