Skip to main content

WitLanguageSpec

Struct WitLanguageSpec 

Source
pub struct WitLanguageSpec {
    pub name: String,
    pub extensions: Vec<String>,
    pub grammar_name: Option<String>,
    pub grammar: Vec<u8>,
    pub highlights: Option<String>,
    pub folds: Option<String>,
    pub injections: Option<String>,
    pub indents: Option<String>,
    pub textobjects: Option<String>,
    pub conceal_rules: Vec<ConcealRule>,
}
Expand description

The wire record, as bindgen generates it. Taken whole by validate_language rather than splatted into nine positional arguments — the fields are all String/Option<String>, so a positional signature is exactly the shape a caller silently gets wrong. Everything the host needs to make a language real.

Fields§

§name: String

The grammar’s tree-sitter name — org for tree_sitter_org. Becomes the language id :set filetype and :describe-buffer report, and the key its queries are cached under. MUST match the grammar’s exported entry point or the module loads with nothing to call.

A name that collides with a bundled language is REFUSED, not shadowed: a plugin silently replacing rust would be a miserable thing to debug. Claiming a bundled extension is allowed but never wins, because the native table is consulted first.

§extensions: Vec<String>

["org"] — extensions that select this language, matched case-insensitively, with or without a leading dot. A language with none can never be selected and is refused as a manifest mistake.

§grammar_name: Option<String>

The grammar’s own entry-point name, when it differs from name.

load_language finds a grammar by its tree_sitter_<x> export, and that is not always what users call the language. lattice’s own bundled sql is the case in point: the grammar is tree-sitter-sequel and exports tree_sitter_sequel, while the language everyone types is sql. Absent means “same as name”, which is the common case.

§grammar: Vec<u8>

The grammar, compiled to wasm. tree-sitter build --wasm produces one; so does scripts/build-wasm-grammar.sh with nothing but clang and a rustup toolchain.

§highlights: Option<String>

Tree-sitter queries, as source. Absent means that feature is simply unavailable for this language — never an error.

All of these compile at REGISTRATION, not first use. A malformed query is the plugin author’s mistake and must surface at load with the offending query named; compiling lazily would turn a typo in folds.scm into “folding silently does nothing”, which is indistinguishable from the feature not existing and surfaces days later.

§folds: Option<String>§injections: Option<String>§indents: Option<String>§textobjects: Option<String>§conceal_rules: Vec<ConcealRule>

H.2: what to hide when rendering this language, empty for most languages.

A refused rule is dropped, not fatal — deliberately unlike a malformed query above, which rejects the whole language. The asymmetry is the proportionality: a broken folds.scm means the language cannot fold at all, and silence there is indistinguishable from the feature not existing; a broken conceal rule means one pattern does not hide, the others are unaffected, and the language is otherwise entirely usable. Losing a language over a typo in a cosmetic regex would cost far more than it protects.

Trait Implementations§

Source§

impl Clone for LanguageSpec

Source§

fn clone(&self) -> LanguageSpec

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 ComponentType for LanguageSpec

Source§

impl Debug for LanguageSpec

Source§

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

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

impl Lift for LanguageSpec

Source§

impl Lower for LanguageSpec

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
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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