| Crates.io | editorconfig-parser |
| lib.rs | editorconfig-parser |
| version | 0.0.3 |
| created_at | 2025-12-09 09:57:01.867701+00 |
| updated_at | 2025-12-18 09:14:53.296249+00 |
| description | .editorconfig parser |
| homepage | |
| repository | https://github.com/oxc-project/editorconfig-parser |
| max_upload_size | |
| id | 1975195 |
| size | 24,158 |
A fast, spec-compliant Rust implementation of an EditorConfig parser.
Add this to your Cargo.toml:
[dependencies]
editorconfig-parser = "0.0.1"
use editorconfig_parser::EditorConfig;
let config_text = r#"
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
max_line_length = off
[Makefile]
indent_style = tab
"#;
let config = EditorConfig::parse(config_text);
// Check if this is a root config
assert!(config.root());
// Access sections
for section in config.sections() {
println!("Section: {}", section.name);
if let Some(indent_style) = section.properties.indent_style {
println!(" indent_style: {:?}", indent_style);
}
}
use editorconfig_parser::EditorConfig;
use std::path::Path;
let config = EditorConfig::parse(config_text);
let properties = config.resolve(Path::new("src/main.rs"));
The parser supports all standard EditorConfig properties:
| Property | Type | Values |
|---|---|---|
indent_style |
IdentStyle |
tab, space |
indent_size |
usize |
Positive integer |
tab_width |
usize |
Positive integer |
end_of_line |
EndOfLine |
lf, cr, crlf |
charset |
Charset |
latin1, utf-8, utf-8-bom, utf-16be, utf-16le |
trim_trailing_whitespace |
bool |
true, false |
insert_final_newline |
bool |
true, false |
max_line_length |
MaxLineLength |
Positive integer or off |
Note: max_line_length is not part of the official EditorConfig spec but is commonly used by tools like Prettier.
The parser follows the EditorConfig specification:
# or ;)root = true in the preamble (before any sections)[pattern] as glob patternskey = value within sectionscargo build --release
cargo test
MIT