Crate topiary_core

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

CoverageData
Language
A Language contains all the information Topiary requires to format that specific languages.
ScopeInformation
SyntaxNode
TopiaryQuery
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 the Query 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
FormatterError
The various errors the formatter may return.
IoError
A subtype of FormatterError::Io
Operation
Operations that can be performed by the formatter.
ScopeCondition
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§

FormatterResult
A convenience wrapper around std::result::Result<T, FormatterError>.