pub enum Language {
Show 29 variants
TypeScript,
Tsx,
JavaScript,
Jsx,
Python,
Go,
Rust,
Java,
C,
Cpp,
CSharp,
Ruby,
Kotlin,
Php,
Scala,
Bash,
Swift,
Zig,
Elixir,
Lua,
Haskell,
R,
Json,
Yaml,
Toml,
Css,
Html,
Sql,
Markdown,
}Expand description
Languages with tree-sitter grammar support.
The string returned by Language::name is the canonical wire name;
callers (and the JSON schemas) refer to languages by that string. The
trailing group (Json..Markdown) are data/markup/config grammars:
they support the query-driven edit primitives but have no symbol-graph
projection (see Language::edit_capabilities).
Variants§
TypeScript
Tsx
JavaScript
Jsx
Python
Go
Rust
Java
C
Cpp
CSharp
Ruby
Kotlin
Php
Scala
Bash
Swift
Zig
Elixir
Lua
Haskell
R
Json
Yaml
Toml
Css
Html
Sql
Markdown
Implementations§
Source§impl Language
impl Language
Sourcepub fn ts_language(self) -> Option<TsLanguage>
pub fn ts_language(self) -> Option<TsLanguage>
Tree-sitter grammar handle, or None when this build was not
compiled with the grammar family that backs self.
Each arm is gated on its grammar-* family feature, so a trimmed
build only links the grammars it asked for. The name/extension/
detection metadata above stays complete regardless of features — a
lean build still recognizes a .py file, it just returns None
here and the edit primitives degrade to the text fallback. The full
(default) build enables every family, so None never occurs there.
Cheap when present; the underlying LANGUAGE constants are static.
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Resolve a language from its canonical wire name. Accepts a few
historical aliases (ts, js, c++, …) so users don’t have to
memorize the exact spelling.
Sourcepub fn from_extension(ext: &str) -> Option<Self>
pub fn from_extension(ext: &str) -> Option<Self>
Resolve a language from a file extension.
Sourcepub fn detect(path: &Path, language_hint: Option<&str>) -> Option<Self>
pub fn detect(path: &Path, language_hint: Option<&str>) -> Option<Self>
Resolve from a file path: prefer explicit language_hint if
supplied, otherwise fall back to extension-based detection.
Sourcepub fn primary_extension(self) -> &'static str
pub fn primary_extension(self) -> &'static str
A representative file extension for the language (no leading dot).
Used by docs and the onboarding probe; not necessarily the only
extension Language::from_extension accepts.
Sourcepub fn rename_identifier_kinds(self) -> Option<&'static [&'static str]>
pub fn rename_identifier_kinds(self) -> Option<&'static [&'static str]>
Per-language allow-list of tree-sitter node kinds that represent an
identifier token bound to a name (variables, functions, types,
fields). This is the symbol-graph projection that drives
rename_symbol: anything not in this table is treated as a literal
or punctuation node and left alone, which keeps a rename out of
comments and string bodies even though those contain identifier
substrings. None means the language has no rename projection yet.
Sourcepub fn supports_rename(self) -> bool
pub fn supports_rename(self) -> bool
Whether rename_symbol can operate on this language (i.e. it has a
Language::rename_identifier_kinds projection).
Sourcepub fn supports_symbol_extraction(self) -> bool
pub fn supports_symbol_extraction(self) -> bool
Whether symbols/outline produce meaningful results. Data/markup
grammars parse and edit fine but expose no symbol projection.
Sourcepub fn edit_capabilities(self) -> EditCapabilities
pub fn edit_capabilities(self) -> EditCapabilities
The AST-precise edit capability matrix for this language. See
EditCapabilities.
Trait Implementations§
impl Copy for Language
impl Eq for Language
impl StructuralPartialEq for Language
Auto Trait Implementations§
impl Freeze for Language
impl RefUnwindSafe for Language
impl Send for Language
impl Sync for Language
impl Unpin for Language
impl UnsafeUnpin for Language
impl UnwindSafe for Language
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);