Skip to content

Commit

Permalink
Add autocorrect server command to start LSP server. (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee authored May 22, 2024
1 parent d77e63e commit 69e32a5
Show file tree
Hide file tree
Showing 9 changed files with 439 additions and 22 deletions.
43 changes: 26 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
[workspace]
# https://github.com/seanmonstar/reqwest/issues/1300#issuecomment-1368265203
resolver = "2"
default-members = [
"autocorrect",
"autocorrect-derive",
"autocorrect-wasm",
"autocorrect-cli",
]
exclude = [
"autocorrect-tauri",
"autocorrect",
"autocorrect-derive",
"autocorrect-wasm",
"autocorrect-cli",
"autocorrect-lsp",
]
members = [
"autocorrect",
"autocorrect-wasm",
"autocorrect-derive",
"autocorrect-cli",
"autocorrect-py",
"autocorrect-node",
"autocorrect-rb/ext/autocorrect",
"autocorrect-java",
"autocorrect",
"autocorrect-wasm",
"autocorrect-derive",
"autocorrect-cli",
"autocorrect-py",
"autocorrect-node",
"autocorrect-rb/ext/autocorrect",
"autocorrect-java",
"autocorrect-lsp",
]

# https://github.com/seanmonstar/reqwest/issues/1300#issuecomment-1368265203
resolver = "2"
[workspace.dependencies]
autocorrect = { path = "autocorrect" }
autocorrect-derive = { path = "autocorrect-derive" }
autocorrect-wasm = { path = "autocorrect-wasm" }
autocorrect-cli = { path = "autocorrect-cli" }
autocorrect-lsp = { path = "autocorrect-lsp" }

serde = { version = "1", features = ["derive"] }
serde_json = "1.0.64"
anyhow = "1.0.86"
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ run:
cargo run -- --lint --config $(WORKDIR)/.autocorrectrc.template --no-diff-bg-color
run\:json:
cargo run -- --lint --format json
server:
cargo run -- server
build:
cargo build --manifest-path autocorrect-cli/Cargo.toml --release --target aarch64-apple-darwin
ls -lha target/aarch64-apple-darwin/release/autocorrect
Expand Down
4 changes: 3 additions & 1 deletion autocorrect-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ name = "autocorrect"
path = "src/main.rs"

[dependencies]
autocorrect = { path = "../autocorrect", version = ">1.0.0" }
autocorrect.workspace = true
autocorrect-lsp.workspace = true

clap = { version = "4", features = ['derive'] }
ignore = "0.4"
log = "0.4"
Expand Down
2 changes: 2 additions & 0 deletions autocorrect-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ pub(crate) enum Commands {
about = "Update AutoCorrect to latest version."
)]
Update {},
#[command(name = "server", about = "Start AutoCorrect LSP server.")]
Server {},
}

impl Cli {
Expand Down
5 changes: 5 additions & 0 deletions autocorrect-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ where
}
return;
}
Some(cli::Commands::Server {}) => {
log::info!("Starting AutoCorrect LSP server...");
autocorrect_lsp::start().await;
return;
}
_ => {}
}

Expand Down
15 changes: 15 additions & 0 deletions autocorrect-lsp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "autocorrect-lsp"
version = "2.9.4"
edition = "2021"

[dependencies]
autocorrect.workspace = true

tokio = { version = "1.37.0", features = [
"io-util",
"io-std",
"macros",
"rt-multi-thread",
] }
tower-lsp = "0.20.0"
Loading

0 comments on commit 69e32a5

Please sign in to comment.