Expand description
A general code formatter that relies on Tree-sitter for language parsing.
In order for a language to be supported, there must be a Tree-sitter grammar available, and there must be a query file that dictates how that language is to be formatted. We include query files for some languages.
More details can be found on GitHub.
Structs§
- Coverage
Data - Language
- A Language contains all the information Topiary requires to format that specific languages.
- Scope
Information - Syntax
Node - Topiary
Query - Topiary often needs both the tree-sitter
Query
and the original content belonging to the file from which the query was parsed. This struct is a simple convenience wrapper that combines theQuery
with its original string.
Enums§
- Atom
- An atom represents a small piece of the output. We turn Tree-sitter nodes into atoms, and we add white-space atoms where appropriate. The final list of atoms is rendered to the output.
- Capitalisation
- Formatter
Error - The various errors the formatter may return.
- IoError
- A subtype of
FormatterError::Io
- Operation
- Operations that can be performed by the formatter.
- Scope
Condition - Used in
Atom::ScopedConditional
to apply the containing Atoms only if the matched node spans a single line or multiple lines - Visualisation
- Supported visualisation formats
Functions§
- apply_
query - Applies a query to an input content and returns a collection of atoms.
- coverage
- formatter
- The function that takes an input and formats, or visualises an output.
Type Aliases§
- Formatter
Result - A convenience wrapper around
std::result::Result<T, FormatterError>
.