Skip to content
Merged
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
1 change: 0 additions & 1 deletion crates/ty_ide/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use ruff_text_size::{Ranged, TextRange, TextSize};
use crate::Db;
use crate::find_node::covering_node;

#[derive(Debug, Clone)]
pub struct Completion {
pub label: String,
}
Expand Down
20 changes: 7 additions & 13 deletions crates/ty_server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use self::schedule::spawn_main_loop;
use crate::PositionEncoding;
use crate::session::{AllSettings, ClientSettings, Experimental, Session};
use crate::session::{AllSettings, ClientSettings, Session};
use lsp_server::Connection;
use lsp_types::{
ClientCapabilities, DiagnosticOptions, DiagnosticServerCapabilities, HoverProviderCapability,
Expand Down Expand Up @@ -53,8 +53,7 @@ impl Server {

let client_capabilities = init_params.capabilities;
let position_encoding = Self::find_best_position_encoding(&client_capabilities);
let server_capabilities =
Self::server_capabilities(position_encoding, global_settings.experimental.as_ref());
let server_capabilities = Self::server_capabilities(position_encoding);

let connection = connection.initialize_finish(
id,
Expand Down Expand Up @@ -154,10 +153,7 @@ impl Server {
.unwrap_or_default()
}

fn server_capabilities(
position_encoding: PositionEncoding,
experimental: Option<&Experimental>,
) -> ServerCapabilities {
fn server_capabilities(position_encoding: PositionEncoding) -> ServerCapabilities {
ServerCapabilities {
position_encoding: Some(position_encoding.into()),
diagnostic_provider: Some(DiagnosticServerCapabilities::Options(DiagnosticOptions {
Expand All @@ -177,12 +173,10 @@ impl Server {
inlay_hint_provider: Some(lsp_types::OneOf::Right(
InlayHintServerCapabilities::Options(InlayHintOptions::default()),
)),
completion_provider: experimental
.is_some_and(Experimental::is_completions_enabled)
.then_some(lsp_types::CompletionOptions {
trigger_characters: Some(vec!['.'.to_string()]),
..Default::default()
}),
completion_provider: Some(lsp_types::CompletionOptions {
trigger_characters: Some(vec!['.'.to_string()]),
..Default::default()
}),
..Default::default()
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/ty_server/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub(crate) use self::capabilities::ResolvedClientCapabilities;
pub use self::index::DocumentQuery;
pub(crate) use self::settings::AllSettings;
pub use self::settings::ClientSettings;
pub(crate) use self::settings::Experimental;
use crate::document::{DocumentKey, DocumentVersion, NotebookDocument};
use crate::session::request_queue::RequestQueue;
use crate::system::{AnySystemPath, LSPSystem};
Expand Down
24 changes: 0 additions & 24 deletions crates/ty_server/src/session/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,11 @@ use serde::Deserialize;
/// Maps a workspace URI to its associated client settings. Used during server initialization.
pub(crate) type WorkspaceSettingsMap = FxHashMap<Url, ClientSettings>;

#[derive(Debug, Deserialize, Default)]
#[cfg_attr(test, derive(PartialEq, Eq))]
#[serde(rename_all = "camelCase")]
struct Completions {
enable: Option<bool>,
}

#[derive(Debug, Deserialize, Default)]
#[cfg_attr(test, derive(PartialEq, Eq))]
#[serde(rename_all = "camelCase")]
pub(crate) struct Experimental {
completions: Option<Completions>,
}

impl Experimental {
/// Returns `true` if completions are enabled in the settings.
pub(crate) fn is_completions_enabled(&self) -> bool {
self.completions
.as_ref()
.is_some_and(|completions| completions.enable.unwrap_or_default())
}
}

/// This is a direct representation of the settings schema sent by the client.
#[derive(Debug, Deserialize, Default)]
#[cfg_attr(test, derive(PartialEq, Eq))]
#[serde(rename_all = "camelCase")]
pub struct ClientSettings {
pub(crate) experimental: Option<Experimental>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is, technically, a breaking change. I think it's fine, considering where we're at with ty.

We'll also need to update the ty-vscode extension to no longer list this option and update the documentation as well.

// These settings are only needed for tracing, and are only read from the global configuration.
// These will not be in the resolved settings.
#[serde(flatten)]
Expand Down
Loading