Skip to main content

LanguageRegistry

Struct LanguageRegistry 

Source
pub struct LanguageRegistry { /* private fields */ }

Implementations§

Source§

impl LanguageRegistry

Source

pub fn syntactic_emphasis( &self, file: &mut FileDiff, mark_reformat_only: bool, ) -> bool

Set char-precise emphasis on file’s diff lines from the AST diff. mark_reformat_only additionally flags a paired deleted/added line the AST diff found no structural difference on at all (a pure reformat) for the structural algorithm’s dimmed rendering. Returns false when the syntactic engine is unavailable, so the caller can fall back to the textual engine (and structural mode silently reads as a plain histogram diff for that file).

Source§

impl LanguageRegistry

Source

pub fn build() -> Self

Build the registry with every bundled grammar, reused for the session.

Source

pub fn for_path(&self, path: &str) -> Option<&LangEntry>

The entry whose grammar handles path, by extension or, for the files a build tool names outright (Makefile, Dockerfile), by basename.

Source

pub fn for_token(&self, token: &str) -> Option<&LangEntry>

The entry for a markdown fence token (rust, py, c++, …), matched by grammar name then extension.

Source

pub fn config_for_injection( &self, lang: &str, ) -> Option<&HighlightConfiguration>

Highlight config for a tree-sitter injection language name (the inline markdown grammar, or a fenced code block’s language). None leaves the injected region plain.

Source

pub fn markdown_inline_spans( &self, content: &str, ) -> Vec<(Range<usize>, &'static str)>

Inline markdown captures (emphasis, code spans, links) as byte range plus the recognized highlight name, narrowest span first so a first-match renderer picks the most specific. The inline grammar parses only the block grammar’s (inline) node ranges, so block markers stay untouched.

Source§

impl LanguageRegistry

Source

pub fn scope_index(&self, path: &str, content: &str) -> ScopeIndex

Parse content and index its definition spans for scope lookup. Returns an empty index when the language is unsupported, has no tags query, the file is too large, or parsing fails, so callers show no breadcrumb.

Source§

impl LanguageRegistry

Source

pub fn symbols(&self, path: &str, content: &str) -> (Vec<Ident>, ScopeIndex)

Every identifier in content, top to bottom, and its definition spans, from one parse. A file with no grammar, or too large to parse, falls back to plain words and no definitions; those words include the ones inside strings and comments.

Trait Implementations§

Source§

impl Default for LanguageRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.