pub struct HighlightConfiguration {
    pub language: Language,
    pub language_name: String,
    pub query: Query,
    /* private fields */
}
Expand description

Contains the data needed to highlight code written in a particular language.

This struct is immutable and can be shared between threads.

Fields§

§language: Language§language_name: String§query: Query

Implementations§

source§

impl HighlightConfiguration

source

pub fn new( language: Language, name: impl Into<String>, highlights_query: &str, injection_query: &str, locals_query: &str ) -> Result<Self, QueryError>

Creates a HighlightConfiguration for a given Language and set of highlighting queries.

§Parameters
  • language - The Tree-sitter Language that should be used for parsing.
  • highlights_query - A string containing tree patterns for syntax highlighting. This should be non-empty, otherwise no syntax highlights will be added.
  • injections_query - A string containing tree patterns for injecting other languages into the document. This can be empty if no injections are desired.
  • locals_query - A string containing tree patterns for tracking local variable definitions and references. This can be empty if local variable tracking is not needed.

Returns a HighlightConfiguration that can then be used with the highlight method.

source

pub const fn names(&self) -> &[&str]

Get a slice containing all of the highlight names used in the configuration.

source

pub fn configure(&mut self, recognized_names: &[impl AsRef<str>])

Set the list of recognized highlight names.

Tree-sitter syntax-highlighting queries specify highlights in the form of dot-separated highlight names like punctuation.bracket and function.method.builtin. Consumers of these queries can choose to recognize highlights with different levels of specificity. For example, the string function.builtin will match against function.method.builtin and function.builtin.constructor, but will not match function.method.

When highlighting, results are returned as Highlight values, which contain the index of the matched highlight this list of highlight names.

source

pub fn nonconformant_capture_names( &self, capture_names: &HashSet<&str> ) -> Vec<&str>

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>,

§

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>,

§

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.