Clean up edit predictions settings (#24692)
This PR does some clean up for the edit predictions settings: - Removed `editor.show_edit_predictions_in_menu` - Renamed `edit_predictions.inline_preview` to `edit_predictions.mode` Release Notes: - N/A --------- Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
parent
636253d2dc
commit
a2592a3a37
6 changed files with 36 additions and 46 deletions
|
@ -168,9 +168,6 @@
|
||||||
/// Whether to show the signature help after completion or a bracket pair inserted.
|
/// Whether to show the signature help after completion or a bracket pair inserted.
|
||||||
/// If `auto_signature_help` is enabled, this setting will be treated as enabled also.
|
/// If `auto_signature_help` is enabled, this setting will be treated as enabled also.
|
||||||
"show_signature_help_after_edits": false,
|
"show_signature_help_after_edits": false,
|
||||||
/// Whether to show the edit predictions next to the completions provided by a language server.
|
|
||||||
/// Only has an effect if edit prediction provider supports it.
|
|
||||||
"show_edit_predictions_in_menu": true,
|
|
||||||
// Whether to show wrap guides (vertical rulers) in the editor.
|
// Whether to show wrap guides (vertical rulers) in the editor.
|
||||||
// Setting this to true will show a guide at the 'preferred_line_length' value
|
// Setting this to true will show a guide at the 'preferred_line_length' value
|
||||||
// if 'soft_wrap' is set to 'preferred_line_length', and will show any
|
// if 'soft_wrap' is set to 'preferred_line_length', and will show any
|
||||||
|
@ -795,11 +792,11 @@
|
||||||
],
|
],
|
||||||
// When to show edit predictions previews in buffer.
|
// When to show edit predictions previews in buffer.
|
||||||
// This setting takes two possible values:
|
// This setting takes two possible values:
|
||||||
// 1. Display inline when there are no language server completions available.
|
// 1. Display inline when holding modifier key (alt by default).
|
||||||
// "inline_preview": "auto"
|
// "mode": "auto"
|
||||||
// 2. Display inline when holding modifier key (alt by default).
|
// 2. Display inline when there are no language server completions available.
|
||||||
// "inline_preview": "when_holding_modifier"
|
// "mode": "eager_preview"
|
||||||
"inline_preview": "auto"
|
"mode": "auto"
|
||||||
},
|
},
|
||||||
// Settings specific to journaling
|
// Settings specific to journaling
|
||||||
"journal": {
|
"journal": {
|
||||||
|
|
|
@ -95,8 +95,8 @@ use itertools::Itertools;
|
||||||
use language::{
|
use language::{
|
||||||
language_settings::{self, all_language_settings, language_settings, InlayHintSettings},
|
language_settings::{self, all_language_settings, language_settings, InlayHintSettings},
|
||||||
markdown, point_from_lsp, AutoindentMode, BracketPair, Buffer, Capability, CharKind, CodeLabel,
|
markdown, point_from_lsp, AutoindentMode, BracketPair, Buffer, Capability, CharKind, CodeLabel,
|
||||||
CompletionDocumentation, CursorShape, Diagnostic, EditPreview, HighlightedText, IndentKind,
|
CompletionDocumentation, CursorShape, Diagnostic, EditPredictionsMode, EditPreview,
|
||||||
IndentSize, InlineCompletionPreviewMode, Language, OffsetRangeExt, Point, Selection,
|
HighlightedText, IndentKind, IndentSize, Language, OffsetRangeExt, Point, Selection,
|
||||||
SelectionGoal, TextObject, TransactionId, TreeSitterOptions,
|
SelectionGoal, TextObject, TransactionId, TreeSitterOptions,
|
||||||
};
|
};
|
||||||
use language::{point_to_lsp, BufferRow, CharClassifier, Runnable, RunnableRange};
|
use language::{point_to_lsp, BufferRow, CharClassifier, Runnable, RunnableRange};
|
||||||
|
@ -5047,7 +5047,6 @@ impl Editor {
|
||||||
);
|
);
|
||||||
|
|
||||||
let show_in_menu = by_provider
|
let show_in_menu = by_provider
|
||||||
&& EditorSettings::get_global(cx).show_edit_predictions_in_menu
|
|
||||||
&& self
|
&& self
|
||||||
.edit_prediction_provider
|
.edit_prediction_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -5055,9 +5054,8 @@ impl Editor {
|
||||||
provider.provider.show_completions_in_menu()
|
provider.provider.show_completions_in_menu()
|
||||||
});
|
});
|
||||||
|
|
||||||
let preview_requires_modifier = all_language_settings(file, cx)
|
let preview_requires_modifier =
|
||||||
.inline_completions_preview_mode()
|
all_language_settings(file, cx).edit_predictions_mode() == EditPredictionsMode::Auto;
|
||||||
== InlineCompletionPreviewMode::WhenHoldingModifier;
|
|
||||||
|
|
||||||
EditPredictionSettings::Enabled {
|
EditPredictionSettings::Enabled {
|
||||||
show_in_menu,
|
show_in_menu,
|
||||||
|
|
|
@ -35,7 +35,6 @@ pub struct EditorSettings {
|
||||||
pub auto_signature_help: bool,
|
pub auto_signature_help: bool,
|
||||||
pub show_signature_help_after_edits: bool,
|
pub show_signature_help_after_edits: bool,
|
||||||
pub jupyter: Jupyter,
|
pub jupyter: Jupyter,
|
||||||
pub show_edit_predictions_in_menu: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
|
@ -368,12 +367,6 @@ pub struct EditorSettingsContent {
|
||||||
/// Default: false
|
/// Default: false
|
||||||
pub show_signature_help_after_edits: Option<bool>,
|
pub show_signature_help_after_edits: Option<bool>,
|
||||||
|
|
||||||
/// Whether to show the edit predictions next to the completions provided by a language server.
|
|
||||||
/// Only has an effect if edit prediction provider supports it.
|
|
||||||
///
|
|
||||||
/// Default: true
|
|
||||||
pub show_edit_predictions_in_menu: Option<bool>,
|
|
||||||
|
|
||||||
/// Jupyter REPL settings.
|
/// Jupyter REPL settings.
|
||||||
pub jupyter: Option<JupyterContent>,
|
pub jupyter: Option<JupyterContent>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,9 +551,9 @@ impl InlineCompletionButton {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_eager_preview_enabled = match settings.inline_completions_preview_mode() {
|
let is_eager_preview_enabled = match settings.edit_predictions_mode() {
|
||||||
language::InlineCompletionPreviewMode::Auto => true,
|
language::EditPredictionsMode::Auto => false,
|
||||||
language::InlineCompletionPreviewMode::WhenHoldingModifier => false,
|
language::EditPredictionsMode::EagerPreview => true,
|
||||||
};
|
};
|
||||||
menu = menu.separator().toggleable_entry(
|
menu = menu.separator().toggleable_entry(
|
||||||
"Eager Preview",
|
"Eager Preview",
|
||||||
|
@ -567,17 +567,17 @@ impl InlineCompletionButton {
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
cx,
|
cx,
|
||||||
move |settings, _cx| {
|
move |settings, _cx| {
|
||||||
let inline_preview = match is_eager_preview_enabled {
|
let new_mode = match is_eager_preview_enabled {
|
||||||
true => language::InlineCompletionPreviewMode::WhenHoldingModifier,
|
true => language::EditPredictionsMode::Auto,
|
||||||
false => language::InlineCompletionPreviewMode::Auto,
|
false => language::EditPredictionsMode::EagerPreview,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(edit_predictions) = settings.edit_predictions.as_mut() {
|
if let Some(edit_predictions) = settings.edit_predictions.as_mut() {
|
||||||
edit_predictions.inline_preview = inline_preview;
|
edit_predictions.mode = new_mode;
|
||||||
} else {
|
} else {
|
||||||
settings.edit_predictions =
|
settings.edit_predictions =
|
||||||
Some(language_settings::EditPredictionSettingsContent {
|
Some(language_settings::EditPredictionSettingsContent {
|
||||||
inline_preview,
|
mode: new_mode,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ mod toolchain;
|
||||||
pub mod buffer_tests;
|
pub mod buffer_tests;
|
||||||
pub mod markdown;
|
pub mod markdown;
|
||||||
|
|
||||||
pub use crate::language_settings::InlineCompletionPreviewMode;
|
pub use crate::language_settings::EditPredictionsMode;
|
||||||
use crate::language_settings::SoftWrap;
|
use crate::language_settings::SoftWrap;
|
||||||
use anyhow::{anyhow, Context as _, Result};
|
use anyhow::{anyhow, Context as _, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
|
@ -227,19 +227,20 @@ pub struct EditPredictionSettings {
|
||||||
/// This list adds to a pre-existing, sensible default set of globs.
|
/// This list adds to a pre-existing, sensible default set of globs.
|
||||||
/// Any additional ones you add are combined with them.
|
/// Any additional ones you add are combined with them.
|
||||||
pub disabled_globs: Vec<GlobMatcher>,
|
pub disabled_globs: Vec<GlobMatcher>,
|
||||||
/// When to show edit predictions previews in buffer.
|
/// Configures how edit predictions are displayed in the buffer.
|
||||||
pub inline_preview: InlineCompletionPreviewMode,
|
pub mode: EditPredictionsMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The mode in which edit predictions should be displayed.
|
/// The mode in which edit predictions should be displayed.
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
|
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum InlineCompletionPreviewMode {
|
pub enum EditPredictionsMode {
|
||||||
/// Display inline when there are no language server completions available.
|
/// If provider supports it, display inline when holding modifier key (e.g., alt).
|
||||||
|
/// Otherwise, eager preview is used.
|
||||||
#[default]
|
#[default]
|
||||||
Auto,
|
Auto,
|
||||||
/// Display inline when holding modifier key (alt by default).
|
/// Display inline when there are no language server completions available.
|
||||||
WhenHoldingModifier,
|
EagerPreview,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The settings for all languages.
|
/// The settings for all languages.
|
||||||
|
@ -434,9 +435,10 @@ pub struct EditPredictionSettingsContent {
|
||||||
/// Any additional ones you add are combined with them.
|
/// Any additional ones you add are combined with them.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub disabled_globs: Option<Vec<String>>,
|
pub disabled_globs: Option<Vec<String>>,
|
||||||
/// When to show edit predictions previews in buffer.
|
/// The mode used to display edit predictions in the buffer.
|
||||||
|
/// Provider support required.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub inline_preview: InlineCompletionPreviewMode,
|
pub mode: EditPredictionsMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The settings for enabling/disabling features.
|
/// The settings for enabling/disabling features.
|
||||||
|
@ -923,8 +925,8 @@ impl AllLanguageSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the edit predictions preview mode for the given language and path.
|
/// Returns the edit predictions preview mode for the given language and path.
|
||||||
pub fn inline_completions_preview_mode(&self) -> InlineCompletionPreviewMode {
|
pub fn edit_predictions_mode(&self) -> EditPredictionsMode {
|
||||||
self.edit_predictions.inline_preview
|
self.edit_predictions.mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,10 +1025,10 @@ impl settings::Settings for AllLanguageSettings {
|
||||||
.features
|
.features
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|f| f.edit_prediction_provider);
|
.and_then(|f| f.edit_prediction_provider);
|
||||||
let mut inline_completions_preview = default_value
|
let mut edit_predictions_mode = default_value
|
||||||
.edit_predictions
|
.edit_predictions
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|inline_completions| inline_completions.inline_preview)
|
.map(|edit_predictions| edit_predictions.mode)
|
||||||
.ok_or_else(Self::missing_default)?;
|
.ok_or_else(Self::missing_default)?;
|
||||||
|
|
||||||
let mut completion_globs: HashSet<&String> = default_value
|
let mut completion_globs: HashSet<&String> = default_value
|
||||||
|
@ -1060,10 +1062,10 @@ impl settings::Settings for AllLanguageSettings {
|
||||||
edit_prediction_provider = Some(provider);
|
edit_prediction_provider = Some(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(inline_completions) = user_settings.edit_predictions.as_ref() {
|
if let Some(edit_predictions) = user_settings.edit_predictions.as_ref() {
|
||||||
inline_completions_preview = inline_completions.inline_preview;
|
edit_predictions_mode = edit_predictions.mode;
|
||||||
|
|
||||||
if let Some(disabled_globs) = inline_completions.disabled_globs.as_ref() {
|
if let Some(disabled_globs) = edit_predictions.disabled_globs.as_ref() {
|
||||||
completion_globs.extend(disabled_globs.iter());
|
completion_globs.extend(disabled_globs.iter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1118,7 +1120,7 @@ impl settings::Settings for AllLanguageSettings {
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|g| Some(globset::Glob::new(g).ok()?.compile_matcher()))
|
.filter_map(|g| Some(globset::Glob::new(g).ok()?.compile_matcher()))
|
||||||
.collect(),
|
.collect(),
|
||||||
inline_preview: inline_completions_preview,
|
mode: edit_predictions_mode,
|
||||||
},
|
},
|
||||||
defaults,
|
defaults,
|
||||||
languages,
|
languages,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue