Enum Lang

Source
#[non_exhaustive]
pub enum Lang {
Show 64 variants Asm, Bash, Bibtex, C, CSharp, Clojure, Cmake, Comment, Cpp, Css, Dart, Diff, Dockerfile, Ebnf, Ejs, Elixir, Erb, Fish, Gleam, Go, Haskell, Hexdump, Html, Java, Javascript, Jsdoc, Json, Json5, Jsonc, Julia, Kotlin, Lalrpop, Latex, Llvm, Lua, Luap, Make, Markdown, MarkdownInline, Nix, Ocaml, OcamlInterface, Php, PhpOnly, Printf, Python, Ql, Regex, Ruby, Rush, Rust, Scala, Scss, Sql, Swift, Toml, Tsx, Typescript, Typst, Ursa, Verilog, Wat, Yaml, Zig,
}
Expand description

An enum of every supported language in the current feature set.

An instance of the respective tree-stter Language can be obtained with the get method.

You can also get a Lang from its name using for_name, or for a FileType using for_file_type. See the docs for each variant to see its “name” and the supported file types. Both of these require the SupportedLanguage trait to be in scope.

See LANGUAGES for a list containing all variants and LANGUAGE_NAMES for a list of all valid names.

The enum is marked as non-exhaustive for two reasons:

  1. New languages may be added in the future
  2. The variants are enabled/disabled by features

§Example

use syntastica_parsers_git::{Lang, LANGUAGES, LANGUAGE_NAMES};
use syntastica_core::language_set::{SupportedLanguage, FileType};

// you can get a `Lang` from its name
assert_eq!(Lang::Rust, Lang::for_name("rust", &()).unwrap());
// and for a file type
assert_eq!(Some(Lang::Rust), Lang::for_file_type(FileType::Rust, &()));

// `LANGUAGES` is a list of all variants,
// `LANGUAGE_NAMES` is a list of all variant names
for (&lang, &name) in LANGUAGES.iter().zip(LANGUAGE_NAMES) {
    assert_eq!(lang, Lang::for_name(name, &()).unwrap());

    // `Lang` instances can be turned into strings
    assert_eq!(lang, Lang::for_name(<Lang as SupportedLanguage<'_, ()>>::name(&lang), &()).unwrap());
    assert_eq!(lang, Lang::for_name(lang.to_string(), &()).unwrap());
    assert_eq!(lang, Lang::for_name(lang.as_ref(), &()).unwrap());
    let lang_name: &'static str = lang.into();
    assert_eq!(lang, Lang::for_name(lang_name, &()).unwrap());
}

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Asm

Available on crate features most or asm only.

Provides the asm language, supports these file types: asm, vmasm.

§

Bash

Available on crate features some or bash only.

Provides the bash language, supports these file types: sh, bash, ksh.

§

Bibtex

Available on crate features all or bibtex only.

Provides the bibtex language, supports these file types: bib.

§

C

Available on crate features some or c only.

Provides the c language, supports these file types: c.

§

CSharp

Available on crate features most or c_sharp only.

Provides the c_sharp language, supports these file types: csharp.

§

Clojure

Available on crate features most or clojure only.

Provides the clojure language, supports these file types: clojure.

§

Cmake

Available on crate features most or cmake only.

Provides the cmake language, supports these file types: cmake.

§

Comment

Available on crate features most or comment only.

Provides the comment language, supports no file types.

§

Cpp

Available on crate features some or cpp only.

Provides the cpp language, supports these file types: cpp.

§

Css

Available on crate features some or css only.

Provides the css language, supports these file types: css.

§

Dart

Available on crate features most or dart only.

Provides the dart language, supports these file types: dart.

§

Diff

Available on crate features most or diff only.

Provides the diff language, supports these file types: diff.

§

Dockerfile

Available on crate features all or dockerfile only.

Provides the dockerfile language, supports these file types: dockerfile.

§

Ebnf

Available on crate features all or ebnf only.

Provides the ebnf language, supports these file types: ebnf.

§

Ejs

Available on crate features all or ejs only.

Provides the ejs language, supports these file types: ejavascript.

§

Elixir

Available on crate features most or elixir only.

Provides the elixir language, supports these file types: elixir.

§

Erb

Available on crate features all or erb only.

Provides the erb language, supports these file types: eruby.

§

Fish

Available on crate features all or fish only.

Provides the fish language, supports these file types: fish.

§

Gleam

Available on crate features all or gleam only.

Provides the gleam language, supports these file types: gleam.

§

Go

Available on crate features some or go only.

Provides the go language, supports these file types: go.

§

Haskell

Available on crate features most or haskell only.

Provides the haskell language, supports these file types: haskell.

§

Hexdump

Available on crate features all or hexdump only.

Provides the hexdump language, supports these file types: hexdump.

§

Html

Available on crate features some or html only.

Provides the html language, supports these file types: html.

§

Java

Available on crate features some or java only.

Provides the java language, supports these file types: java.

§

Javascript

Available on crate features some or javascript only.

Provides the javascript language, supports these file types: javascript, jsx.

§

Jsdoc

Available on crate features most or jsdoc only.

Provides the jsdoc language, supports no file types.

§

Json

Available on crate features some or json only.

Provides the json language, supports these file types: json.

§

Json5

Available on crate features most or json5 only.

Provides the json5 language, supports these file types: json5.

§

Jsonc

Available on crate features most or jsonc only.

Provides the jsonc language, supports these file types: jsonc.

§

Julia

Available on crate features all or julia only.

Provides the julia language, supports these file types: julia.

§

Kotlin

Available on crate features some or kotlin only.

Provides the kotlin language, supports these file types: kotlin.

§

Lalrpop

Available on crate features all or lalrpop only.

Provides the lalrpop language, supports no file types.

§

Latex

Available on crate features all or latex only.

Provides the latex language, supports these file types: tex.

§

Llvm

Available on (crate features all or llvm) and non-target_family="wasm" only.

Provides the llvm language, supports these file types: llvm.

§

Lua

Available on crate features some or lua only.

Provides the lua language, supports these file types: lua.

§

Luap

Available on crate features most or luap only.

Provides the luap language, supports no file types.

§

Make

Available on crate features most or make only.

Provides the make language, supports these file types: make, automake.

§

Markdown

Available on crate features most or markdown only.

Provides the markdown language, supports these file types: markdown.

§

MarkdownInline

Available on crate features most or markdown_inline only.

Provides the markdown_inline language, supports no file types.

§

Nix

Available on crate features most or nix only.

Provides the nix language, supports these file types: nix.

§

Ocaml

Available on crate features all or ocaml only.

Provides the ocaml language, supports these file types: ocaml.

§

OcamlInterface

Available on crate features all or ocaml_interface only.

Provides the ocaml_interface language, supports these file types: ocamlinterface.

§

Php

Available on crate features most or php only.

Provides the php language, supports these file types: php.

§

PhpOnly

Available on crate features most or php_only only.

Provides the php_only language, supports no file types.

§

Printf

Available on crate features most or printf only.

Provides the printf language, supports no file types.

§

Python

Available on crate features some or python only.

Provides the python language, supports these file types: python.

§

Ql

Available on crate features all or ql only.

Provides the ql language, supports these file types: ql.

§

Regex

Available on crate features most or regex only.

Provides the regex language, supports no file types.

§

Ruby

Available on crate features most or ruby only.

Provides the ruby language, supports these file types: ruby.

§

Rush

Available on crate features all or rush only.

Provides the rush language, supports these file types: rush.

§

Rust

Available on crate features some or rust only.

Provides the rust language, supports these file types: rust.

§

Scala

Available on crate features most or scala only.

Provides the scala language, supports these file types: scala, sbt.

§

Scss

Available on crate features most or scss only.

Provides the scss language, supports these file types: scss.

§

Sql

Available on crate features most or sql only.

Provides the sql language, supports these file types: sql, mysql.

§

Swift

Available on crate features most or swift only.

Provides the swift language, supports these file types: swift.

§

Toml

Available on crate features some or toml only.

Provides the toml language, supports these file types: toml.

§

Tsx

Available on crate features some or tsx only.

Provides the tsx language, supports these file types: tsx.

§

Typescript

Available on crate features some or typescript only.

Provides the typescript language, supports these file types: typescript.

§

Typst

Available on crate features most or typst only.

Provides the typst language, supports these file types: typst.

§

Ursa

Available on crate features all or ursa only.

Provides the ursa language, supports these file types: ursa.

§

Verilog

Available on crate features all or verilog only.

Provides the verilog language, supports these file types: verilog.

§

Wat

Available on crate features all or wat only.

Provides the wat language, supports these file types: wat.

§

Yaml

Available on crate features some or yaml only.

Provides the yaml language, supports these file types: yaml.

§

Zig

Available on crate features most or zig only.

Provides the zig language, supports these file types: zig.

Implementations§

Source§

impl Lang

Source

pub fn get(&self) -> Language

Get an instance of the respective Language.

Source

pub fn get_config(&self) -> Result<HighlightConfiguration>

Create an instance of the corresponding HighlightConfiguration.

Source

pub fn highlights_query(&self) -> &'static str

Get the highlights query for this language.

Source

pub fn injections_query(&self) -> &'static str

Get the injections query for this language.

Source

pub fn locals_query(&self) -> &'static str

Get the locals query for this language.

Trait Implementations§

Source§

impl AsRef<str> for Lang

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Lang

Source§

fn clone(&self) -> Lang

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Lang

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Lang

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'_derivative_strum> From<&'_derivative_strum Lang> for &'static str

Source§

fn from(x: &'_derivative_strum Lang) -> &'static str

Converts to this type from the input type.
Source§

impl From<Lang> for &'static str

Source§

fn from(x: Lang) -> &'static str

Converts to this type from the input type.
Source§

impl FromStr for Lang

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Lang, <Self as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Lang

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Lang

Source§

fn eq(&self, other: &Lang) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> SupportedLanguage<'_, S> for Lang

Source§

fn name(&self) -> Cow<'_, str>

Get the name for this language. Read more
Source§

fn for_name(name: impl AsRef<str>, _set: &S) -> Result<Self>

Get the language with the given name. Read more
Source§

fn for_file_type(file_type: FileType, _set: &S) -> Option<Self>

Find a language based on the given [FileType]. Read more
§

fn for_injection(name: impl AsRef<str>, set: &'set S) -> Option<Self>

Find a language for an injection. Read more
Source§

impl TryFrom<&str> for Lang

Source§

type Error = ParseError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &str) -> Result<Lang, <Self as TryFrom<&str>>::Error>

Performs the conversion.
Source§

impl Copy for Lang

Source§

impl Eq for Lang

Source§

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 UnwindSafe for Lang

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
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> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.