pub struct Config {
pub file_associations: Option<HashMap<String, String>>,
pub formatting: RenderConfig,
pub grammar: GrammarConfig,
pub input_processing: TreeSitterProcessor,
pub fallback_cmd: Option<String>,
}Expand description
The config struct for the application
Fields§
§file_associations: Option<HashMap<String, String>>Custom file extension mappings between a file extension and a language
These will be merged with the existing defaults, with the user-defined mappings taking
precedence. The existing mappings are available at: parse::FILE_EXTS and the user can
list all available langauges with diffsitter --cmd list
formatting: RenderConfigFormatting options for display
grammar: GrammarConfigOptions for loading
input_processing: TreeSitterProcessorOptions for processing tree-sitter input.
fallback_cmd: Option<String>The program to invoke if the given files can not be parsed by the available tree-sitter parsers.
This will invoke the program with with the old and new file as arguments, like so:
${FALLBACK_PROGRAM} ${OLD} ${NEW}Implementations§
Source§impl Config
impl Config
Sourcepub fn try_from_file<P: AsRef<Path>>(
path: Option<&P>,
) -> Result<Self, ReadError>
pub fn try_from_file<P: AsRef<Path>>( path: Option<&P>, ) -> Result<Self, ReadError>
Read a config from a given filepath, or fall back to the default file paths
If a path is supplied, this method will attempt to read the contents of that path and parse
it to a string. If a path isn’t supplied, the function will attempt to figure out what the
default config file path is supposed to be (based on OS conventions, see
[default_config_file_path]).
§Errors
This method will return an error if the config cannot be parsed or if no default config exists.