# =============================================================================
# EditorConfig 配置文件
# 官方文档: https://editorconfig.org
# Supported Properties: https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
# =============================================================================

# root = true 表示本文件为最顶层的 EditorConfig 配置；
# 编辑器在向上逐级查找 .editorconfig 时，发现此值为 true 即停止，不再继续向父目录搜索。
root = true

# -----------------------------------------------------------------------------
# 全局默认配置（适用于所有文件，可被下方各语言分组覆盖）
# -----------------------------------------------------------------------------
[*]
charset = utf-8              # 文件字符编码，可选: latin1、utf-8、utf-8-bom、utf-16be、utf-16le
end_of_line = lf             # 换行符类型，可选: lf、cr、crlf
insert_final_newline = true  # 文件末尾自动补充一个空行
# indent_style / indent_size 不在此统一指定，交由下方各语言分组单独定义

# -----------------------------------------------------------------------------
# Web 前端：HTML / CSS / Stylus / Nunjucks 模板
# -----------------------------------------------------------------------------
[*.{html,css,styl,njk}]
indent_style = space  # 使用空格缩进
indent_size = 2       # 缩进列数为 2

# -----------------------------------------------------------------------------
# Vue 单文件组件
# -----------------------------------------------------------------------------
[*.vue]
indent_style = space
indent_size = 2

# -----------------------------------------------------------------------------
# JavaScript / TypeScript / JSX / TSX (React) / JSON
# -----------------------------------------------------------------------------
[*.{js,jsx,ts,tsx,mts,mjs,json}]
indent_style = space
indent_size = 2

# -----------------------------------------------------------------------------
# VS Code 工作区文件
# -----------------------------------------------------------------------------
[*.code-workspace]
indent_style = space
indent_size = 2

# -----------------------------------------------------------------------------
# Python（遵循 PEP 8 规范，使用 4 空格缩进；pyi 为类型存根文件）
# -----------------------------------------------------------------------------
[*.{py,pyi}]
indent_style = space
indent_size = 4

# -----------------------------------------------------------------------------
# C / C++（源文件与头文件）
# -----------------------------------------------------------------------------
[*.{c,cpp,h,hpp}]
indent_style = space
indent_size = 4       # C/C++ 采用 4 空格缩进

# -----------------------------------------------------------------------------
# CMake 构建脚本（CMakeLists.txt 与 *.cmake，官方约定使用 2 空格缩进）
# -----------------------------------------------------------------------------
[{CMakeLists.txt,*.cmake}]
indent_style = space
indent_size = 2

# -----------------------------------------------------------------------------
# Makefile（make 语法要求必须使用 Tab 缩进，不可替换为空格，否则规则会失效）
# -----------------------------------------------------------------------------
[{Makefile,*.mk}]
indent_style = tab
indent_size = 4

# -----------------------------------------------------------------------------
# YAML 配置文件（GitHub Actions、Docker Compose、CI/CD 等场景常见，约定 2 空格缩进）
# -----------------------------------------------------------------------------
[*.{yml,yaml}]
indent_style = space
indent_size = 2

# -----------------------------------------------------------------------------
# Dockerfile（容器镜像构建脚本；后缀不固定，统一匹配 Dockerfile 与 Dockerfile.* ）
# -----------------------------------------------------------------------------
[{Dockerfile,Dockerfile.*}]
indent_style = space
indent_size = 2

# -----------------------------------------------------------------------------
# Rust（源文件 *.rs；rustfmt 默认约定 4 空格缩进）
# -----------------------------------------------------------------------------
[*.rs]
indent_style = space
indent_size = 4

# -----------------------------------------------------------------------------
# TOML 配置文件（Cargo.toml、pyproject.toml 等通用格式，约定 2 空格缩进）
# -----------------------------------------------------------------------------
[*.toml]
indent_style = space
indent_size = 2

# -----------------------------------------------------------------------------
# Go（源文件与模块/校验文件；gofmt 官方工具强制使用 Tab 缩进）
# -----------------------------------------------------------------------------
[{*.go,go.mod,go.sum,go.work,go.work.sum}]
indent_style = tab
indent_size = 4
