Skip to main content

SignDefinition

Struct SignDefinition 

Source
pub struct SignDefinition {
    pub name: String,
    pub text: String,
    pub fallback: String,
    pub theme_element: String,
    pub priority: i32,
    pub column: String,
}
Expand description

A sign definition: what it looks like, how it is styled, how it competes for its cell (SG.1).

vim’s :sign define / :sign place split, and the split is load-bearing rather than historical. A definition is registered once and carries the expensive, reusable parts — the glyph and its theme element. A placement is (line, name) and happens per keystroke, per visible line, on every refresh. Folding the two together would re-carry a glyph and a theme key across the boundary for every marked line of every refresh, to say something that was already true at load.

The host knows what a sign IS and nothing about what any particular sign MEANS — which is what makes this a mechanism rather than a feature. A provider’s marks, a plugin’s breakpoints and a future built-in all place signs through the same registry and are styled through the same theme.

Fields§

§name: String

The name placements refer to. A provider’s own namespace by convention (org-agenda-mark), unenforced — last definition wins, as with every other registry here.

§text: String

The glyph when ui.nerd_fonts is on. One cell — SG.2b put signs in the gutter’s single shared mark cell, so anything wider would push every line of content right. Self::glyph_char is what the renderers paint and it takes the first character.

§fallback: String

The BMP fallback, used when it is off — the same cell width, per the icon-degradation rule, so toggling the option cannot shift the gutter’s geometry.

§theme_element: String

The theme element the glyph is painted in (gutter.sign.* by convention). Resolved by the renderer through the ordinary theme registry, so a user or a theme retunes a plugin’s signs without either knowing about the other.

§priority: i32

Which sign wins when two land on one line of the same column. Higher wins; ties break on name so the answer is stable rather than incidental to hash order.

One cell, one sign: a cell that stacked them would either grow unpredictably or silently drop one, and vim’s answer — priority — is the one users already know.

§column: String

Which gutter column this sign paints in (SG.4a).

Columns exist because contention is only meaningful between marks that mean comparable things. A diagnostic and a git-diff mark are both “something is true of this line”, but they answer different questions, and a single contended cell would drop the git gutter on exactly the lines a diagnostic touches — the lines a user is most likely to be looking at. Vim’s single signcolumn accepts that trade; Helix and Zed do not, and neither does this.

A name the host does not paint falls back to the FIRST column rather than vanishing, on the same principle as the gutter.sign theme fallback: a sign was placed to say something, and the failure mode that loses the information entirely is the worst one available.

Use SIGN_COLUMN_MARK / SIGN_COLUMN_DIFF for the built-ins.

Implementations§

Source§

impl SignDefinition

Source

pub fn glyph(&self, nerd_fonts: bool) -> &str

The glyph for the current palette. Not a theme question — the theme decides the COLOUR, the font capability decides the GLYPH, and conflating them is how a themed editor renders tofu.

Source

pub fn glyph_char(&self, nerd_fonts: bool) -> char

The single character the renderers paint into the gutter’s mark cell (SG.2b).

The cell is one column, so this TRUNCATES rather than trusting a producer to have obeyed the one-cell rule. A definition that ignores it loses its tail; the alternative is a gutter that silently widens and pushes every line of content sideways, which is a pixel change to content the user did not edit and costs far more than the glyph. An empty definition paints a blank, so a producer can place a sign that reserves the cell without drawing in it.

Trait Implementations§

Source§

impl Clone for SignDefinition

Source§

fn clone(&self) -> SignDefinition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SignDefinition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SignDefinition

Source§

impl PartialEq for SignDefinition

Source§

fn eq(&self, other: &SignDefinition) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SignDefinition

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more