Skip to content
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ tracing-appender = "0.2"
tree-sitter-proto = "0.6"
walkdir = "2.5"
hard-xml = "1.41"
tempfile = "3.27"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
basic-toml = "0.1"
Expand All @@ -34,6 +33,7 @@ const_format = "0.2"

[dev-dependencies]
insta = { version = "1.47", features = ["yaml", "redactions"] }
tempfile = "3.27.0"

[profile.release]
strip = "debuginfo" # Removes heavy debug data but keeps function names for panic logs
Expand All @@ -42,3 +42,6 @@ codegen-units = 1 # Maximizes LLVM optimization passes

[lints.clippy]
pedantic = "warn"
large_futures = "warn"
large_types_passed_by_value = "warn"
inefficient_to_string = "warn"
54 changes: 54 additions & 0 deletions src/config/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use async_lsp::lsp_types::{InitializeParams, WorkDoneProgressOptions};

/// A flat, optimized summary of client editor capabilities
/// compiled once during the LSP initialization handshake.
#[derive(Debug, Clone, Copy, Default)]
pub struct ClientCapabilitiesSummary {
/// True if the editor supports work done UI progress bars.
pub supports_work_done_progress: bool,

/// True if the editor allows the server to dynamically register `didChangeWatchedFiles`.
pub supports_watched_files_dynamic_registration: bool,

/// True if the editor can process modern directory-relative absolute glob patterns (LSP 3.17+).
pub supports_relative_patterns: bool,
}

impl From<&InitializeParams> for ClientCapabilitiesSummary {
fn from(value: &InitializeParams) -> Self {
let supports_work_done_progress = Self::build_work_done_progress_options(value)
.work_done_progress
.unwrap_or_default();

let capabilies = &value.capabilities;
let watched_files_caps = capabilies
.workspace
.as_ref()
.and_then(|w| w.did_change_watched_files.as_ref());
let supports_watched_files_dynamic_registration = watched_files_caps
.and_then(|cw| cw.dynamic_registration)
.unwrap_or_default();
let supports_relative_patterns = watched_files_caps
.and_then(|cw| cw.relative_pattern_support)
.unwrap_or(false);

Self {
supports_work_done_progress,
supports_watched_files_dynamic_registration,
supports_relative_patterns,
}
}
}

impl ClientCapabilitiesSummary {
#[inline]
pub fn build_work_done_progress_options(params: &InitializeParams) -> WorkDoneProgressOptions {
let work_done_progress = params
.capabilities
.window
.as_ref()
.and_then(|w| w.work_done_progress);

WorkDoneProgressOptions { work_done_progress }
}
}
24 changes: 10 additions & 14 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::path::PathBuf;

use serde::{Deserialize, Serialize};

pub(super) mod client;
mod workspace;

pub use workspace::WorkspaceProtoConfigs;

use serde::{Deserialize, Serialize};
pub use workspace::configure_workspace_folders;

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default)]
Expand All @@ -21,15 +25,15 @@ pub struct Config {
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(default)]
pub struct PathConfig {
pub clang_format: String,
pub protoc: String,
pub clang_format: PathBuf,
pub protoc: PathBuf,
}

impl Default for PathConfig {
fn default() -> Self {
Self {
clang_format: default_clang_format_path(),
protoc: default_protoc_path(),
clang_format: "clang-format".into(),
protoc: "protoc".into(),
}
}
}
Expand All @@ -44,11 +48,3 @@ pub struct RenameConfig {
/// convention.
pub chain_rpc_request_response: bool,
}

fn default_clang_format_path() -> String {
"clang-format".to_string()
}

fn default_protoc_path() -> String {
"protoc".to_string()
}
Loading
Loading