Struct syntect_assets::assets::HighlightingAssets
source · pub struct HighlightingAssets { /* private fields */ }Implementations§
source§impl HighlightingAssets
impl HighlightingAssets
sourcepub fn default_theme() -> &'static str
pub fn default_theme() -> &'static str
The default theme.
Windows and Linux
Windows and most Linux distributions has a dark terminal theme by default. On these platforms, this function always returns a theme that looks good on a dark background.
macOS
On macOS the default terminal background is light, but it is common that Dark Mode is active, which makes the terminal background dark. On this platform, the default theme depends on
defaults read -globalDomain AppleInterfaceStyle
To avoid the overhead of the check on macOS, simply specify a theme
explicitly via --theme, BAT_THEME, or ~/.config/syntect-assets.
See https://github.com/sharkdp/bat/issues/1746 and https://github.com/sharkdp/bat/issues/1928 for more context.
pub fn from_cache(cache_path: &Path) -> Result<Self, Error>
pub fn from_binary() -> Self
pub fn set_fallback_theme(&mut self, theme: &'static str)
sourcepub fn get_syntax_set(&self) -> Result<&SyntaxSet, Error>
pub fn get_syntax_set(&self) -> Result<&SyntaxSet, Error>
Return the collection of syntect syntax definitions.
pub fn get_syntaxes(&self) -> Result<&[SyntaxReference], Error>
pub fn themes(&self) -> impl Iterator<Item = &str>
sourcepub fn get_syntax_for_path(
&self,
path: impl AsRef<Path>,
mapping: &SyntaxMapping<'_>
) -> Result<SyntaxReferenceInSet<'_>, Error>
pub fn get_syntax_for_path( &self, path: impl AsRef<Path>, mapping: &SyntaxMapping<'_> ) -> Result<SyntaxReferenceInSet<'_>, Error>
Detect the syntax based on, in order:
- Syntax mappings with [MappingTarget::MapTo] and [MappingTarget::MapToUnknown]
(e.g.
/etc/profile->Bourne Again Shell (bash)) - The file name (e.g.
Dockerfile) - Syntax mappings with [MappingTarget::MapExtensionToUnknown]
(e.g.
*.conf) - The file name extension (e.g.
.rs)
When detecting syntax based on syntax mappings, the full path is taken into account. When detecting syntax based on file name, no regard is taken to the path of the file. Only the file name itself matters. When detecting syntax based on file name extension, only the file name extension itself matters.
Returns [Error::UndetectedSyntax] if it was not possible detect syntax based on path/file name/extension (or if the path was mapped to [MappingTarget::MapToUnknown] or [MappingTarget::MapExtensionToUnknown]). In this case it is appropriate to fall back to other methods to detect syntax. Such as using the contents of the first line of the file.
Returns [Error::UnknownSyntax] if a syntax mapping exist, but the mapped syntax does not exist.