# ============================================================
# .editorconfig (CUSTOM FROM ALL-REPOS)
# ============================================================
# Updated: 2026-10-22
#
# WHAT: A configuration file that defines shared text-formatting conventions.
#       EditorConfig helps different code editors and IDEs use consistent
#       indentation, character encoding, line endings, and whitespace rules.
#       The same conventions can be used on Windows, macOS, and Linux.
#
# WHEN: Use in professional projects where files may be edited by different
#       people, using different editors or operating systems.
#
# WHY: Consistent formatting makes project files easier to read, review,
#      compare, and maintain. Without shared conventions, editors may
#      introduce unnecessary formatting differences when files are saved.
#      These changes create distracting Git diffs, complicate code reviews,
#      and can occasionally cause problems with development tools.
#
# HOW: Editors that support EditorConfig read this file and apply its
#      settings when working with matching file types.
#      General defaults apply to all files unless more specific rules
#      are defined for a particular file or programming language.
#
# SKILLS: EditorConfig, code formatting, cross-platform development,
#         configuration management, Git, and team collaboration.
#
# TOOLS: EditorConfig-compatible editors use these formatting conventions.
#        Git tracks changes to the resulting files.
#        Linters and formatters can independently verify formatting rules.
#
# REQ: All professional GitHub project repositories SHOULD include .editorconfig.
# REQ: The file name MUST be exactly .editorconfig.
# ALT: Repositories may omit this file when equivalent formatting standards
#      are enforced through other established tools.
#
# OBS: EditorConfig does not execute code or install software.
#      Editors must support EditorConfig for these settings to take effect.
#
# OBS: .editorconfig and .gitattributes serve complementary purposes.
#      .editorconfig establishes editor formatting conventions.
#      .gitattributes establishes Git's rules for handling tracked files.
#      Neither replaces the other.
#
# CUSTOM: Adjust shared formatting conventions only when project or
#         organizational standards require different settings.
#
# SEE: https://editorconfig.org/
# ============================================================

# WHY: Keep this project's formatting rules independent of parent directories.
root = true


# === Core defaults ===

[*]
# WHY: Normalize line endings and encoding across Windows, macOS, and Linux.
charset = utf-8
end_of_line = lf

# WHY: Default to 2 spaces for configs and markup; language-specific overrides follow.
indent_size = 2
indent_style = space

# WHY: Newline at EOF avoids noisy diffs and tool warnings.
insert_final_newline = true

# WHY: Remove accidental whitespace noise in diffs.
trim_trailing_whitespace = true


# === Named root and metadata files ===

[CITATION.cff]
# WHY: Citation tooling expects stable YAML formatting.
indent_size = 2
indent_style = space

[CODEOWNERS]
# WHY: CODEOWNERS is a structured text file; keep formatting simple and stable.
indent_size = 2
indent_style = space

[LICENSE]
# WHY: License text should remain plain, stable, and editor-neutral.
indent_size = 2
indent_style = space


# === Build systems ===

[Makefile]
# WHY: Makefile recipe lines require real tab characters.
indent_style = tab
indent_size = tab

[*.mk]
# WHY: Makefile includes may contain recipes and should preserve real tabs.
indent_style = tab
indent_size = tab


# === Markup and documentation ===

[*.md]
# WHY: Keep Markdown clean; use explicit <br> for hard line breaks.
indent_size = 2
trim_trailing_whitespace = true

[*.qmd]
# WHY: Quarto Markdown follows Markdown-style formatting.
indent_size = 2
indent_style = space

[*.rst]
# WHY: reStructuredText documentation benefits from stable 2-space indentation.
indent_size = 2
indent_style = space

[*.{bib,cls,sty,tex,typ}]
# WHY: LaTeX, BibTeX, and Typst source use a stable 2-space convention.
indent_size = 2
indent_style = space

[*.{css,html,xml}]
# WHY: Web and XML markup convention is 2 spaces.
indent_size = 2
indent_style = space


# === Configuration and structured text ===

[*.env]
# WHY: Environment templates should remain simple line-oriented text.
indent_size = 2
indent_style = space

[*.{cfg,ini}]
# WHY: INI-style configuration convention is 2 spaces.
indent_size = 2
indent_style = space

[*.{json,jsonc,jsonl,ndjson}]
# WHY: JSON tooling typically expects 2 spaces.
indent_size = 2
indent_style = space

[*.toml]
# WHY: TOML often follows 4-space indentation in many projects.
indent_size = 4
indent_style = space

[*.{yaml,yml}]
# WHY: YAML convention is 2 spaces.
indent_size = 2
indent_style = space


# === Programming languages and scripts ===

[*.{bat,cmd}]
# WHY: Windows batch scripts use CRLF line endings.
end_of_line = crlf
indent_size = 2
indent_style = space

[*.{bash,sh}]
# WHY: Shell script convention is 2 spaces.
indent_size = 2
indent_style = space

[*.{c,cpp,cs,go,h,hpp,java,rs}]
# WHY: Many C-family and systems languages commonly use 4 spaces.
indent_size = 4
indent_style = space

[*.jl]
# WHY: Julia convention commonly uses 4 spaces.
indent_size = 4
indent_style = space

[*.{cjs,js,jsx,mjs,ts,tsx}]
# WHY: JavaScript and TypeScript ecosystems commonly use 2 spaces.
indent_size = 2
indent_style = space

[*.mojo]
# WHY: Mojo uses Python-like syntax and commonly follows 4-space indentation.
indent_size = 4
indent_style = space

[*.ps1]
# WHY: PowerShell convention is 4 spaces.
indent_size = 4
indent_style = space

[*.{py,pyi}]
# WHY: Python convention is 4 spaces.
indent_size = 4
indent_style = space

[*.{r,R}]
# WHY: R convention commonly uses 2 spaces.
indent_size = 2
indent_style = space

[*.sql]
# WHY: SQL formatting varies, but 2 spaces is a stable shared baseline.
indent_size = 2
indent_style = space


# === Formal, math, and proof languages ===

[*.lean]
# WHY: Lean 4 convention is 2 spaces; matches Mathlib and stdlib style.
indent_size = 2
indent_style = space


# === Notebooks ===

[*.ipynb]
# WHY: Jupyter notebooks are JSON documents; keep embedded formatting stable.
indent_size = 2
indent_style = space


# === Text and tabular data ===

[*.{csv,dat,psv,tsv,txt,ged}]
# WHY: Text and tabular data should remain simple line-oriented text.
indent_size = 2
indent_style = space

# === CUSTOM DATASETS ===

# Preserve original dataset formatting.
[data/raw/**]
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset

# Preserve published sample formatting.
[data/identity/**]
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
