Skip to main content

view_lsp_overlay

Function view_lsp_overlay 

Source
pub fn view_lsp_overlay<'a, M: Clone + 'a>(
    state: &'a LspOverlayState,
    editor: &'a CodeEditor,
    theme: &'a Theme,
    font_size: f32,
    line_height: f32,
    f: impl Fn(LspOverlayMessage) -> M + 'a,
) -> Element<'a, M>
Expand description

Renders LSP overlay elements (hover tooltip and completion menu) on top of a CodeEditor.

Returns an Element containing the overlays positioned relative to the editor viewport. The function maps LspOverlayMessage values to the application message type M via f.

§Arguments

  • state — current overlay display state
  • editor — the editor this overlay is associated with (used for viewport measurements)
  • theme — the active Iced theme for styling
  • font_size — font size in points, used for markdown rendering
  • line_height — line height in pixels, used for vertical positioning
  • f — mapping function from LspOverlayMessage to the app’s message type

§Example

use iced_code_editor::{
    CodeEditor, LspOverlayMessage, LspOverlayState, view_lsp_overlay,
};

struct App {
    editor: CodeEditor,
    overlay: LspOverlayState,
}

#[derive(Clone)]
enum Message {
    Overlay(LspOverlayMessage),
}

fn view(app: &App) -> iced::Element<'_, Message> {
    view_lsp_overlay(
        &app.overlay,
        &app.editor,
        &iced::Theme::Dark,
        14.0,
        20.0,
        Message::Overlay,
    )
}