Skip to main content

postgres_lsp_analysis/
hover.rs

1use std::sync::Arc;
2
3use crate::symbols::Symbol;
4
5/// Build hover content for a symbol definition.
6pub fn hover_for_symbol(symbol: &Arc<Symbol>) -> String {
7    let kind_label = symbol.kind.label();
8    let name = symbol.name.display();
9
10    // Show the kind and name as a header, then the full definition.
11    // Use a fenced code block with enough backticks to avoid conflicts
12    // if the definition text itself contains triple backticks.
13    let mut content = format!("**{kind_label}** `{name}`\n\n");
14    let fence = if symbol.definition_text.contains("```") {
15        "````"
16    } else {
17        "```"
18    };
19    content.push_str(fence);
20    content.push_str("sql\n");
21    content.push_str(&symbol.definition_text);
22    content.push('\n');
23    content.push_str(fence);
24
25    content
26}