pub enum Lang {
Show 22 variants
Plain,
Rust,
Python,
JavaScript,
Bash,
C,
Cpp,
Css,
Go,
Html,
Java,
Json,
Lua,
Ruby,
Sql,
Toml,
TypeScript,
Wit,
Tsx,
Yaml,
Markdown,
Plugin(LanguageName),
}Variants§
Plain
Rust
Python
JavaScript
Bash
C
Cpp
Css
Go
Html
Java
Json
Lua
Ruby
Sql
SQL via tree-sitter-sequel — general/permissive SQL grammar
supporting multiple dialects (MySQL, PostgreSQL, SQLite).
Toml
TypeScript
Wit
WebAssembly Interface Types — the language wit/ is written in, and
therefore the language this editor’s own plugin API is written in.
Highlighted with a repo-held query rather than the grammar crate’s own:
tree_sitter_wit::HIGHLIGHTS_QUERY uses TextMate capture names
(entity.name.type.interface), and [crate::style::name_to_style]
keys on the first dot-segment — so every interface / record /
world NAME would have rendered unstyled.
Tsx
TypeScript + JSX (React) via tree-sitter-typescript’s TSX
grammar. Separate from TypeScript because the two are
different dialects — TSX adds JSX element syntax on top of
the TypeScript parser.
Yaml
Markdown
CommonMark + GitHub-flavor markdown via tree-sitter-md.
The grammar is intentionally split into block + inline parsers;
the registry holds both as separate HighlightConfigurations
(markdown and markdown_inline) and the block grammar’s
injection queries thread between them. Help buffers also
render through this language.
Plugin(LanguageName)
A language contributed at runtime by a plugin (LG.2; design
plugin-languages.md §2.3).
The existing variants deliberately stay. Native languages keep
compiler-checked coverage in Self::comment_syntax,
crate::major_mode_id_for_lang and FormatSpec::for_lang —
so adding a bundled language still cannot silently miss its
formatter — and a plugin language is one fallthrough arm at each.
The payload is the language’s name, interned, rather than an
index: Self::name is the key every query lookup already uses,
and it stays a field read. See crate::plugin_lang.
Implementations§
Source§impl Lang
impl Lang
Sourcepub fn builtin_by_name(name: &str) -> Option<Lang>
pub fn builtin_by_name(name: &str) -> Option<Lang>
The compiled-in language with this canonical name, if any.
Exists so crate::plugin_lang::register can refuse a name that
would shadow a builtin, and it is written as a match over the
same table Self::name uses so the two cannot drift.
Sourcepub fn detect_from_path(path: Option<&Path>) -> Lang
pub fn detect_from_path(path: Option<&Path>) -> Lang
Detect language from a file path’s extension.
pub fn label(self) -> &'static str
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Canonical name used as a registry key. The block markdown
parser is registered under "markdown"; the inline variant
(registered under "markdown_inline") is reached only via
the block grammar’s injection queries.
Sourcepub fn comment_syntax(self) -> CommentSyntax
pub fn comment_syntax(self) -> CommentSyntax
N.1.6: per-language comment-leader descriptor for the comment
text objects (aC / iC). Commentstring-driven — the line
leader is all v1 uses; block delimiters are carried for a
follow-up. Languages with no line comment (markdown, plain)
return line: None, so the comment objects no-op there.
Trait Implementations§
impl Copy for Lang
impl Eq for Lang
impl StructuralPartialEq for Lang
Auto Trait Implementations§
impl Freeze for Lang
impl RefUnwindSafe for Lang
impl Send for Lang
impl Sync for Lang
impl Unpin for Lang
impl UnsafeUnpin for Lang
impl UnwindSafe for Lang
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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