EditorConfig

CIHex.pmHexDocsLicense: MIT

EditorConfig is a pure Elixir EditorConfig parser and resolver targeting specification 0.17.2. It reads .editorconfig files, matches EditorConfig globs, walks parent directories, and returns the effective properties for any file. The package also provides typed property helpers and an editorconfig escript CLI.

Why EditorConfig?

Tools that format, analyze, or generate source code often need the same settings that a developer's editor uses. Implementing that behavior requires more than parsing an INI file: .editorconfig discovery, glob matching, section precedence, root = true, unset, and version-specific defaults all affect the final result.

EditorConfig provides that behavior through an Elixir API, without requiring an external EditorConfig executable. It offers:

When to use EditorConfig

Use EditorConfig when an Elixir application needs to interpret .editorconfig files itself, especially when building:

You probably do not need this package when your editor already supports EditorConfig and your Elixir application never reads the resolved properties.

Installation

Add EditorConfig to your dependencies in mix.exs:

def deps do
[
{:editorconfig_core, "~> 0.1"}
]
end

During local development, use a path: dependency.

Quick start

EditorConfig.spec_version()
# => "0.17.2"
{:ok, props} = EditorConfig.properties("/project/lib/file.ex")
props["indent_style"]
# => "space"

Use an in-memory filesystem for editor integrations or tests:

fs =
EditorConfig.FileSystem.Memory.new(%{
"/project/.editorconfig" => "root = true\n[*]\nindent_style = space\n"
})
EditorConfig.properties("/project/lib/file.ex", fs: fs)

Build and run the CLI:

mix escript.build
./editorconfig lib/file.ex
./editorconfig --files lib/file.ex

Documentation is generated with mix docs.

What It Does

EditorConfig walks up from a target file, reads each applicable .editorconfig, respects root = true, applies EditorConfig glob sections in order, and returns the final property map for that file. It is meant for formatters, linters, generators, language servers, editor plugins, and CI tools that need EditorConfig behavior from Elixir without shelling out to an external binary.

Compliance

EditorConfig is gated by the official editorconfig-core-test suite pinned in vendor/editorconfig-core-test.

License

MIT. See LICENSE.