topiary_core/
language.rs

1use std::fmt;
2
3use crate::TopiaryQuery;
4
5/// A Language contains all the information Topiary requires to format that
6/// specific languages.
7#[derive(Debug)]
8pub struct Language {
9    /// The name of the language, used as a key when looking up information in
10    /// the Configuration, and to convert from a language to the respective tree-sitter
11    /// grammar.
12    pub name: String,
13    /// The Query Topiary will use to get the formatting captures, must be
14    /// present. The topiary engine does not include any formatting queries.
15    pub query: TopiaryQuery,
16    /// The tree-sitter Language. Topiary will use this Language for parsing.
17    pub grammar: topiary_tree_sitter_facade::Language,
18    /// The indentation string used for that particular language. Defaults to "  "
19    /// if not provided. Any string can be provided, but in most instances will be
20    /// some whitespace: "  ", "    ", or "\t".
21    pub indent: Option<String>,
22}
23
24impl fmt::Display for Language {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        write!(f, "{}", self.name)
27    }
28}