pub struct TreeSitterProcessorConfig {
pub language: TreeSitterLanguage,
pub highlights_query: String,
pub folds_query: Option<String>,
pub capture_styles: BTreeMap<String, StyleId>,
pub style_layer: StyleLayerId,
pub preserve_collapsed_folds: bool,
}Expand description
Configuration for TreeSitterProcessor.
Fields§
§language: TreeSitterLanguageTree-sitter language.
highlights_query: StringSyntax highlighting query (.scm).
folds_query: Option<String>Optional folding query (.scm). Each capture becomes a fold candidate.
capture_styles: BTreeMap<String, StyleId>Mapping from capture name (e.g. "comment") to an editor-core StyleId.
style_layer: StyleLayerIdTarget style layer id to replace.
preserve_collapsed_folds: boolWhether to preserve the collapsed state for existing fold regions on replacement.
Implementations§
Source§impl TreeSitterProcessorConfig
impl TreeSitterProcessorConfig
Sourcepub fn new(
language: TreeSitterLanguage,
highlights_query: impl Into<String>,
) -> Self
pub fn new( language: TreeSitterLanguage, highlights_query: impl Into<String>, ) -> Self
Create a config with a language + highlights query.
By default:
style_layerisStyleLayerId::TREE_SITTERpreserve_collapsed_foldsistrue
Sourcepub fn with_folds_query(self, folds_query: impl Into<String>) -> Self
pub fn with_folds_query(self, folds_query: impl Into<String>) -> Self
Set a folding query.
Sourcepub fn with_simple_capture_styles<const N: usize>(
self,
styles: [(&'static str, StyleId); N],
) -> Self
pub fn with_simple_capture_styles<const N: usize>( self, styles: [(&'static str, StyleId); N], ) -> Self
Add a set of capture name → style id mappings.
Sourcepub fn set_preserve_collapsed_folds(&mut self, preserve: bool)
pub fn set_preserve_collapsed_folds(&mut self, preserve: bool)
Control whether fold replacement preserves collapsed state.
Sourcepub fn highlights_capture_names(&self) -> Result<Vec<String>, TreeSitterError>
pub fn highlights_capture_names(&self) -> Result<Vec<String>, TreeSitterError>
Compile highlights_query and return its capture names in the query’s declaration order.
Hosts can use this to pre-allocate a stable capture → StyleId mapping before running the
processor.
Trait Implementations§
Source§impl Clone for TreeSitterProcessorConfig
impl Clone for TreeSitterProcessorConfig
Source§fn clone(&self) -> TreeSitterProcessorConfig
fn clone(&self) -> TreeSitterProcessorConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TreeSitterProcessorConfig
impl RefUnwindSafe for TreeSitterProcessorConfig
impl Send for TreeSitterProcessorConfig
impl Sync for TreeSitterProcessorConfig
impl Unpin for TreeSitterProcessorConfig
impl UnsafeUnpin for TreeSitterProcessorConfig
impl UnwindSafe for TreeSitterProcessorConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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