diff options
author | Poliorcetics | 2023-03-11 02:32:14 +0000 |
---|---|---|
committer | GitHub | 2023-03-11 02:32:14 +0000 |
commit | bdcd4d9411655ab69245d803e88f88cc278127da (patch) | |
tree | 3131cca198bec2520a2fccc7d4c47cd3d4eddedf /helix-core/src/text_annotations.rs | |
parent | 3d230e701d4771377a6b3f3b8c68527af29ee066 (diff) |
Feat: LSP Type Hints (#5934)
* misc: missing inline, outdated link
* doc: Add new theme keys and config option to book
* fix: don't panic in Tree::try_get(view_id)
Necessary for later, where we could be receiving an LSP response
for a closed window, in which case we don't want to crash while
checking for its existence
* fix: reset idle timer on all mouse events
* refacto: Introduce Overlay::new and InlineAnnotation::new
* refacto: extract make_job_callback from Context::callback
* feat: add LSP display_inlay_hint option to config
* feat: communicate inlay hints support capabilities of helix to LSP server
* feat: Add function to request range of inlay hint from LSP
* feat: Save inlay hints in document, per view
* feat: Update inlay hints on document changes
* feat: Compute inlay hints on idle timeout
* nit: Add todo's about inlay hints for later
* fix: compute text annotations for current view in view.rs, not document.rs
* doc: Improve Document::text_annotations() description
* nit: getters don't use 'get_' in front
* fix: Drop inlay hints annotations on config refresh if necessary
* fix: padding theming for LSP inlay hints
* fix: tracking of outdated inlay hints should not be dependant on document revision (because of undos and such)
* fix: follow LSP spec and don't highlight padding as virtual text
* config: add some LSP inlay hint configs
Diffstat (limited to 'helix-core/src/text_annotations.rs')
-rw-r--r-- | helix-core/src/text_annotations.rs | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/helix-core/src/text_annotations.rs b/helix-core/src/text_annotations.rs index 1956f6b5..3e48de4d 100644 --- a/helix-core/src/text_annotations.rs +++ b/helix-core/src/text_annotations.rs @@ -15,6 +15,15 @@ pub struct InlineAnnotation { pub char_idx: usize, } +impl InlineAnnotation { + pub fn new(char_idx: usize, text: impl Into<Tendril>) -> Self { + Self { + char_idx, + text: text.into(), + } + } +} + /// Represents a **single Grapheme** that is part of the document /// that start at `char_idx` that will be replaced with /// a different `grapheme`. @@ -33,22 +42,13 @@ pub struct InlineAnnotation { /// use helix_core::text_annotations::Overlay; /// /// // replaces a -/// Overlay { -/// char_idx: 0, -/// grapheme: "X".into(), -/// }; +/// Overlay::new(0, "X"); /// /// // replaces X͎̊͢͜͝͡ -/// Overlay{ -/// char_idx: 1, -/// grapheme: "\t".into(), -/// }; +/// Overlay::new(1, "\t"); /// /// // replaces b -/// Overlay{ -/// char_idx: 6, -/// grapheme: "X̢̢̟͖̲͌̋̇͑͝".into(), -/// }; +/// Overlay::new(6, "X̢̢̟͖̲͌̋̇͑͝"); /// ``` /// /// The following examples are invalid uses @@ -57,16 +57,10 @@ pub struct InlineAnnotation { /// use helix_core::text_annotations::Overlay; /// /// // overlay is not aligned at grapheme boundary -/// Overlay{ -/// char_idx: 3, -/// grapheme: "x".into(), -/// }; +/// Overlay::new(3, "x"); /// /// // overlay contains multiple graphemes -/// Overlay{ -/// char_idx: 0, -/// grapheme: "xy".into(), -/// }; +/// Overlay::new(0, "xy"); /// ``` #[derive(Debug, Clone)] pub struct Overlay { @@ -74,6 +68,15 @@ pub struct Overlay { pub grapheme: Tendril, } +impl Overlay { + pub fn new(char_idx: usize, grapheme: impl Into<Tendril>) -> Self { + Self { + char_idx, + grapheme: grapheme.into(), + } + } +} + /// Line annotations allow for virtual text between normal /// text lines. They cause `height` empty lines to be inserted /// below the document line that contains `anchor_char_idx`. |