Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/commands/lsp.rs')
-rw-r--r--helix-term/src/commands/lsp.rs62
1 files changed, 9 insertions, 53 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 0494db3e..9c55c830 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -46,7 +46,7 @@ macro_rules! language_server_with_feature {
match language_server {
Some(language_server) => language_server,
None => {
- $editor.set_error(format!(
+ $editor.set_status(format!(
"No configured language server supports {}",
$feature
));
@@ -100,7 +100,7 @@ struct PickerDiagnostic {
diag: lsp::Diagnostic,
}
-fn location_to_file_location(location: &Location) -> Option<FileLocation<'_>> {
+fn location_to_file_location(location: &Location) -> Option<FileLocation> {
let path = location.uri.as_path()?;
let line = Some((
location.range.start.line as usize,
@@ -231,13 +231,6 @@ fn diag_picker(
}
}
- flat_diag.sort_by(|a, b| {
- a.diag
- .severity
- .unwrap_or(lsp::DiagnosticSeverity::HINT)
- .cmp(&b.diag.severity.unwrap_or(lsp::DiagnosticSeverity::HINT))
- });
-
let styles = DiagnosticStyles {
hint: cx.editor.theme.get("hint"),
info: cx.editor.theme.get("info"),
@@ -259,9 +252,6 @@ fn diag_picker(
.into()
},
),
- ui::PickerColumn::new("source", |item: &PickerDiagnostic, _| {
- item.diag.source.as_deref().unwrap_or("").into()
- }),
ui::PickerColumn::new("code", |item: &PickerDiagnostic, _| {
match item.diag.code.as_ref() {
Some(NumberOrString::Number(n)) => n.to_string().into(),
@@ -273,12 +263,12 @@ fn diag_picker(
item.diag.message.as_str().into()
}),
];
- let mut primary_column = 3; // message
+ let mut primary_column = 2; // message
if format == DiagnosticsFormat::ShowSourcePath {
columns.insert(
// between message code and message
- 3,
+ 2,
ui::PickerColumn::new("path", |item: &PickerDiagnostic, _| {
if let Some(path) = item.location.uri.as_path() {
path::get_truncated_path(path)
@@ -589,7 +579,7 @@ struct CodeActionOrCommandItem {
impl ui::menu::Item for CodeActionOrCommandItem {
type Data = ();
- fn format(&self, _data: &Self::Data) -> Row<'_> {
+ fn format(&self, _data: &Self::Data) -> Row {
match &self.lsp_item {
lsp::CodeActionOrCommand::CodeAction(action) => action.title.as_str().into(),
lsp::CodeActionOrCommand::Command(command) => command.title.as_str().into(),
@@ -814,9 +804,7 @@ pub fn code_action(cx: &mut Context) {
});
picker.move_down(); // pre-select the first item
- let popup = Popup::new("code-action", picker)
- .with_scrollbar(false)
- .auto_close(true);
+ let popup = Popup::new("code-action", picker).with_scrollbar(false);
compositor.replace_or_push("code-action", popup);
};
@@ -935,13 +923,7 @@ where
}
let call = move |editor: &mut Editor, compositor: &mut Compositor| {
if locations.is_empty() {
- editor.set_error(match feature {
- LanguageServerFeature::GotoDeclaration => "No declaration found.",
- LanguageServerFeature::GotoDefinition => "No definition found.",
- LanguageServerFeature::GotoTypeDefinition => "No type definition found.",
- LanguageServerFeature::GotoImplementation => "No implementation found.",
- _ => "No location found.",
- });
+ editor.set_error("No definition found.");
} else {
goto_impl(editor, compositor, locations);
}
@@ -1146,7 +1128,7 @@ pub fn rename_symbol(cx: &mut Context) {
let Some(language_server) = doc
.language_servers_with_feature(LanguageServerFeature::RenameSymbol)
- .find(|ls| language_server_id.is_none_or(|id| id == ls.id()))
+ .find(|ls| language_server_id.map_or(true, |id| id == ls.id()))
else {
cx.editor
.set_error("No configured language server supports symbol renaming");
@@ -1375,7 +1357,6 @@ fn compute_inlay_hints_for_view(
let mut padding_after_inlay_hints = Vec::new();
let doc_text = doc.text();
- let inlay_hints_length_limit = doc.config.load().lsp.inlay_hints_length_limit;
for hint in hints {
let char_idx =
@@ -1386,7 +1367,7 @@ fn compute_inlay_hints_for_view(
None => continue,
};
- let mut label = match hint.label {
+ let label = match hint.label {
lsp::InlayHintLabel::String(s) => s,
lsp::InlayHintLabel::LabelParts(parts) => parts
.into_iter()
@@ -1394,31 +1375,6 @@ fn compute_inlay_hints_for_view(
.collect::<Vec<_>>()
.join(""),
};
- // Truncate the hint if too long
- if let Some(limit) = inlay_hints_length_limit {
- // Limit on displayed width
- use helix_core::unicode::{
- segmentation::UnicodeSegmentation, width::UnicodeWidthStr,
- };
-
- let width = label.width();
- let limit = limit.get().into();
- if width > limit {
- let mut floor_boundary = 0;
- let mut acc = 0;
- for (i, grapheme_cluster) in label.grapheme_indices(true) {
- acc += grapheme_cluster.width();
-
- if acc > limit {
- floor_boundary = i;
- break;
- }
- }
-
- label.truncate(floor_boundary);
- label.push('…');
- }
- }
let inlay_hints_vec = match hint.kind {
Some(lsp::InlayHintKind::TYPE) => &mut type_inlay_hints,