Skip to content

Commit 953a0a4

Browse files
committed
refactor: extract LSP command handler and make feature opt-in
Move LSP server initialization into dedicated command handler module. Remove tower-lsp and tokio from default features to avoid bundling unused code when LSP is not needed.
1 parent 8b6c2ed commit 953a0a4

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

ci/src/cli/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use codeinput::utils::app_config::AppConfig;
1616
use codeinput::utils::error::Result;
1717
use codeinput::utils::types::LogLevel;
1818

19-
#[cfg(feature = "lsp")]
20-
use codeinput::lsp::server::run_lsp_server;
2119

2220
#[derive(Parser, Debug)]
2321
#[command(
@@ -294,12 +292,7 @@ pub fn cli_match() -> Result<()> {
294292
}
295293
Commands::Config => commands::config::run()?,
296294
#[cfg(feature = "lsp")]
297-
Commands::Lsp { stdio: _ } => {
298-
let rt = tokio::runtime::Runtime::new()?;
299-
rt.block_on(async {
300-
run_lsp_server().await
301-
})?;
302-
}
295+
Commands::Lsp { stdio: _ } => commands::lsp::run()?,
303296
}
304297

305298
Ok(())

codeinput/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ full = [
5757
"clap",
5858
"chrono",
5959
"utoipa",
60-
"tower-lsp",
61-
"tokio",
6260
"url",
6361
]
6462
nightly = []

codeinput/src/core/commands/lsp.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! LSP command handler
2+
//!
3+
//! Starts the Language Server Protocol server for IDE integration.
4+
5+
use crate::utils::error::Result;
6+
7+
#[cfg(feature = "tower-lsp")]
8+
use crate::lsp::server::run_lsp_server;
9+
10+
/// Run the LSP server
11+
#[cfg(feature = "tower-lsp")]
12+
pub fn run() -> Result<()> {
13+
let rt = tokio::runtime::Runtime::new()?;
14+
rt.block_on(async { run_lsp_server().await })
15+
}

codeinput/src/core/commands/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ pub mod list_owners;
66
pub mod list_rules;
77
pub mod list_tags;
88
pub mod parse;
9+
10+
#[cfg(feature = "tower-lsp")]
11+
pub mod lsp;

0 commit comments

Comments
 (0)