Repository: helix-editor/helix
File: helix-term/src/commands/lsp.rs (Rust)

Code before:
                }
            }

            doc.set_inlay_hints(
                view_id,
                DocumentInlayHints {
                    id: new_doc_inlay_hints_id,
                    type_inlay_hints,
                    parameter_inlay_hints,
                    other_inlay_hints,
                    padding_before_inlay_hints,
                    padding_after_inlay_hints,
                },
            );
            doc.inlay_hints_oudated = false;
        },
    );

    Some(callback)
}

pub fn pull_diagnostic_for_current_doc(editor: &Editor, jobs: &mut crate::job::Jobs) {
    let doc = doc!(editor);
    let Some(language_server) = doc
        .language_servers_with_feature(LanguageServerFeature::PullDiagnostics)
        .next()
    else {
        return;
    };

    let future = language_server
        .text_document_diagnostic(doc.identifier(), doc.previous_diagnostic_id.clone());

    let server_id = language_server.id();
    let original_path = doc
        .path()
        .expect("safety: the file has a path if there is a running language server")
        .to_owned();

    let callback = super::make_job_callback(
        future.expect("safety: language server supports pull diagnostics"),
        move |editor, _compositor, response: Option<lsp::DocumentDiagnosticReport>| {
            let parse_diagnostic = |editor: &mut Editor,
                                    path: PathBuf,
                                    report: Vec<lsp::Diagnostic>,
                                    result_id: Option<String>| {
                let uri = helix_core::Uri::try_from(path);
                let diagnostics: Vec<(Diagnostic, LanguageServerId)> =
                    report.into_iter().map(|d| (d, server_id)).collect();

                if let Ok(uri) = uri {

Review comment (suggestion):
It looks like this is only requesting diagnostics from the first language server to support it. We should request pull diagnostics for all language servers in this iterator - there might be multiple language servers configured that support the feature.

Code after:
                        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,
                    Some(lsp::InlayHintKind::PARAMETER) => &mut parameter_inlay_hints,
                    // We can't warn on unknown kind here since LSPs are free to set it or not, for
                    // example Rust Analyzer does not: every kind will be `None`.
                    _ => &mut other_inlay_hints,
                };

                if let Some(true) = hint.padding_left {
                    padding_before_inlay_hints.push(InlineAnnotation::new(char_idx, " "));
                }

                inlay_hints_vec.push(InlineAnnotation::new(char_idx, label));

                if let Some(true) = hint.padding_right {
                    padding_after_inlay_hints.push(InlineAnnotation::new(char_idx, " "));
                }
            }

            doc.set_inlay_hints(
                view_id,
                DocumentInlayHints {
                    id: new_doc_inlay_hints_id,
                    type_inlay_hints,
                    parameter_inlay_hints,
                    other_inlay_hints,
                    padding_before_inlay_hints,
                    padding_after_inlay_hints,
                },
            );
            doc.inlay_hints_oudated = false;
        },
    );

    Some(callback)