Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src-tauri/crates/lsp/src/commands/discovery.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! LSP Discovery Commands
//!
//! Tauri commands for detecting installed language servers.
//! Helpers for detecting installed language servers.

use super::cache;
use crate::command_detection::command_exists;
Expand Down Expand Up @@ -66,7 +66,6 @@ fn is_uninstall_supported(install_hint: &str) -> bool {

/// Check which language servers are installed on the system
/// Returns full info including display names (single source of truth)
#[tauri::command]
pub async fn lsp_check_installed() -> Vec<LanguageServerInfo> {
tokio::task::spawn_blocking(|| {
let result: Vec<LanguageServerInfo> = LANGUAGE_DISPLAY_NAMES
Expand Down Expand Up @@ -96,7 +95,6 @@ pub async fn lsp_check_installed() -> Vec<LanguageServerInfo> {
}

/// Return cached LSP servers if fresh, otherwise empty (caller should fetch fresh).
#[tauri::command]
pub fn lsp_get_cached() -> Vec<LanguageServerInfo> {
cache::load_lsp().unwrap_or_default()
}
Expand All @@ -106,7 +104,6 @@ pub fn lsp_get_cached() -> Vec<LanguageServerInfo> {
/// Each entry is `(language_id, install_hint)`. A server that handles multiple
/// language IDs (e.g. typescript-language-server handles both `typescript` and
/// `javascript`) emits one entry per language ID, all sharing the same hint.
#[tauri::command]
pub fn lsp_get_supported_languages() -> Vec<(String, String)> {
servers::STATIC_SERVERS
.iter()
Expand Down
4 changes: 1 addition & 3 deletions src-tauri/crates/lsp/src/commands/install.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! LSP Install/Uninstall Commands
//!
//! Tauri commands for generating install and uninstall commands
//! Helpers for generating install and uninstall commands
//! for language servers.

use super::package_manager::{
Expand Down Expand Up @@ -52,7 +52,6 @@ pub struct UninstallCommandResult {

/// Get the install command for a language server
/// Returns the command that should be executed in a terminal
#[tauri::command]
pub fn lsp_get_install_command(language: String) -> InstallCommandResult {
let install_hint = match install_hint_for_language(&language) {
Ok(hint) => hint,
Expand Down Expand Up @@ -118,7 +117,6 @@ pub fn lsp_get_install_command(language: String) -> InstallCommandResult {
}

/// Get the uninstall command for a language server
#[tauri::command]
pub fn lsp_get_uninstall_command(language: String) -> UninstallCommandResult {
let install_hint = match install_hint_for_language(&language) {
Ok(hint) => hint,
Expand Down
8 changes: 3 additions & 5 deletions src-tauri/crates/lsp/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! LSP Tauri Commands
//! LSP command helpers
//!
//! Exposes LSP functionality to the frontend via Tauri commands.
//! Library helpers used by agent-core (`manage_lsp`) and tests. These
//! functions are not registered as Tauri IPC commands.
//!
//! Organized into submodules by responsibility:
//! - `server`: LSP server lifecycle (start/stop/status/notifications)
Expand All @@ -25,9 +26,6 @@ use super::manager::LspManager;
// Re-export state type
pub type LspManagerState = Arc<Mutex<LspManager>>;

// Re-export all items from submodules to ensure Tauri command macros work correctly.
// The #[tauri::command] macro generates __cmd__ prefixed functions that need to be
// accessible from the parent module for generate_handler! to work.
pub use discovery::*;
pub use install::*;
pub use server::*;
17 changes: 1 addition & 16 deletions src-tauri/crates/lsp/src/commands/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! LSP Server Lifecycle Commands
//!
//! Tauri commands for managing LSP server processes:
//! Helpers for managing LSP server processes:
//! - Starting/stopping servers per language
//! - Document notifications (open/change/close)
//! - Retrieving diagnostics and server status
Expand All @@ -13,7 +13,6 @@ use super::LspManagerState;
use crate::config::{self, CustomServerDef, LspConfig, ServerOverride};

/// Start an LSP server for a specific language
#[tauri::command]
pub async fn lsp_start_server(
language: String,
root_path: String,
Expand All @@ -27,7 +26,6 @@ pub async fn lsp_start_server(
}

/// Stop an LSP server for a specific language
#[tauri::command]
pub async fn lsp_stop_server(
language: String,
lsp_manager: State<'_, LspManagerState>,
Expand All @@ -37,7 +35,6 @@ pub async fn lsp_stop_server(
}

/// Notify LSP that a document was opened
#[tauri::command]
pub async fn lsp_did_open(
language: String,
uri: String,
Expand All @@ -50,7 +47,6 @@ pub async fn lsp_did_open(
}

/// Notify LSP that a document changed
#[tauri::command]
pub async fn lsp_did_change(
language: String,
uri: String,
Expand All @@ -63,7 +59,6 @@ pub async fn lsp_did_change(
}

/// Notify LSP that a document was closed
#[tauri::command]
pub async fn lsp_did_close(
language: String,
uri: String,
Expand All @@ -74,7 +69,6 @@ pub async fn lsp_did_close(
}

/// Shutdown all LSP servers
#[tauri::command]
pub async fn lsp_shutdown(lsp_manager: State<'_, LspManagerState>) -> Result<(), String> {
let manager = lsp_manager.lock().await;
manager.shutdown().await
Expand All @@ -94,7 +88,6 @@ pub struct BrokenServerInfo {

/// Snapshot of every server currently in broken-cooldown. Servers whose
/// cooldown has already expired are filtered out by the manager.
#[tauri::command]
pub async fn lsp_list_broken_servers(
lsp_manager: State<'_, LspManagerState>,
) -> Result<Vec<BrokenServerInfo>, String> {
Expand All @@ -115,7 +108,6 @@ pub async fn lsp_list_broken_servers(
/// the next `start_server` call will retry instead of being rejected
/// by the cooldown short-circuit. Returns the number of entries
/// cleared.
#[tauri::command]
pub async fn lsp_revive_server(
server_id: String,
lsp_manager: State<'_, LspManagerState>,
Expand All @@ -125,7 +117,6 @@ pub async fn lsp_revive_server(
}

/// Clear every broken-cooldown entry. Returns the count cleared.
#[tauri::command]
pub async fn lsp_revive_all(lsp_manager: State<'_, LspManagerState>) -> Result<usize, String> {
let manager = lsp_manager.lock().await;
Ok(manager.revive_all().await)
Expand All @@ -138,7 +129,6 @@ pub async fn lsp_revive_all(lsp_manager: State<'_, LspManagerState>) -> Result<u
/// `language`. An empty `Vec` is returned when no server is running
/// for that language — the frontend treats it as "open the drawer on
/// an inactive row" rather than an error.
#[tauri::command]
pub async fn lsp_get_server_log(
language: String,
lsp_manager: State<'_, LspManagerState>,
Expand Down Expand Up @@ -176,14 +166,12 @@ impl From<LspConfig> for GlobalLspConfig {
}

/// Get the global LSP configuration.
#[tauri::command]
pub async fn lsp_get_global_config() -> Result<GlobalLspConfig, String> {
let config = config::global_config().read().await;
Ok(GlobalLspConfig::from(config.clone()))
}

/// Update the global LSP configuration.
#[tauri::command]
pub async fn lsp_set_global_config(config: GlobalLspConfig) -> Result<(), String> {
config::update_config(|cfg| {
cfg.auto_install = config.auto_install;
Expand All @@ -195,7 +183,6 @@ pub async fn lsp_set_global_config(config: GlobalLspConfig) -> Result<(), String
}

/// Set the auto-install toggle.
#[tauri::command]
pub async fn lsp_set_auto_install(enabled: bool) -> Result<(), String> {
config::update_config(|cfg| {
cfg.auto_install = enabled;
Expand All @@ -205,7 +192,6 @@ pub async fn lsp_set_auto_install(enabled: bool) -> Result<(), String> {
}

/// Enable or disable a specific server.
#[tauri::command]
pub async fn lsp_set_server_enabled_global(server_id: String, enabled: bool) -> Result<(), String> {
config::update_config(|cfg| {
let override_config = cfg
Expand All @@ -225,7 +211,6 @@ pub async fn lsp_set_server_enabled_global(server_id: String, enabled: bool) ->
}

/// Reload the global config from disk.
#[tauri::command]
pub async fn lsp_reload_global_config() -> Result<GlobalLspConfig, String> {
config::reload_config().await.map_err(|e| e.to_string())?;
let config = config::global_config().read().await;
Expand Down
5 changes: 1 addition & 4 deletions src-tauri/crates/lsp/src/workspace_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,16 @@ pub fn set_server_enabled(
}

// ============================================
// Tauri Commands
// Public helpers
// ============================================

/// Get the LSP configuration for a workspace
#[tauri::command]
pub fn lsp_get_workspace_config(workspace_path: String) -> WorkspaceLspConfig {
let settings = load_workspace_settings(&workspace_path);
settings.lsp.into()
}

/// Set whether a language server is enabled for a workspace
#[tauri::command]
pub fn lsp_set_server_enabled(
workspace_path: String,
language: String,
Expand All @@ -180,7 +178,6 @@ pub fn lsp_set_server_enabled(
}

/// Check if a specific language server is enabled for a workspace
#[tauri::command]
pub fn lsp_is_server_enabled(workspace_path: String, language: String) -> bool {
is_server_enabled(&workspace_path, &language)
}
Expand Down
Loading