Skip to content

Configuration ZH

ssobol77 edited this page May 12, 2026 · 1 revision

配置

🌍 English · Polski · Français · Deutsch · 中文

ECLI 通过单个 TOML 文件配置。默认值合理 — 大多数用户只编辑 AI 提供商部分和主题。

配置文件位置

平台 路径
Linux / FreeBSD ~/.config/ecli/config.toml
macOS ~/Library/Application Support/ecli/config.toml
Windows %APPDATA%\ecli\config.toml

可在命令行使用 --config /path/to/config.toml 覆盖,或通过环境变量 ECLI_CONFIG:

ECLI_CONFIG=/tmp/test-config.toml ecli

优先级

当同一设置在多处定义时,ECLI 按以下顺序应用(优先级从高到低):

  1. 命令行标志(--theme dark)
  2. 环境变量(ECLI_THEME=dark)
  3. 用户配置(~/.config/ecli/config.toml)
  4. 内置默认值

首次启动生成

首次启动时,ECLI 创建带有内联注释解释每个键的默认配置。可随时重新生成:

ecli --print-default-config > ~/.config/ecli/config.toml

架构概览

配置分为命名章节:

[editor]      # 制表符大小、行尾、自动保存
[ui]          # 主题、面板宽度、状态栏
[keybindings] # 自定义快捷键
[ai]          # AI 提供商选择
[ai.openai]   # 每个提供商的设置
[ai.anthropic]
[ai.ollama]
[ai.huggingface]
[git]         # git 集成行为
[lsp]         # language server 偏好
[linters]     # 每种语言的代码检查器
[panels]      # 启用哪些面板

完整参考:docs/config/config-schema.md

最常见的编辑

更改主题

[ui]
theme = "dark"   # 或 "light", "solarized-dark", "monokai", "nord"

重启 ECLI 以应用。

设置 AI 提供商

[ai]
default_provider = "anthropic"

[ai.anthropic]
api_key = "sk-ant-..."
model = "claude-sonnet-4-5"
max_tokens = 4096

完整矩阵参见 AI 配置

制表符宽度

[editor]
tab_width = 4
use_spaces = true

行尾

[editor]
line_ending = "lf"   # 或 "crlf", "auto"

禁用自动保存

[editor]
autosave = false

为 Python 启用 Ruff

[linters]
python = "ruff"

最小可工作配置

[editor]
tab_width = 4
use_spaces = true

[ui]
theme = "dark"

[ai]
default_provider = "none"

[git]
auto_fetch = false

[lsp]
enabled = true

迁移

当 ECLI 升级配置架构时(很少),会自动迁移并将旧配置备份为 config.toml.bak。参见 config-migration-policy

每项目配置

ECLI 在当前工作目录中查找 .ecli.toml。其中的设置仅为该项目覆盖用户配置。

示例 .ecli.toml:

[editor]
tab_width = 2

[linters]
python = "pylint"

验证

ecli --check-config

成功时返回 0,否则打印错误。配置格式错误时,会回退到默认值并显示警告。

参见

Clone this wiki locally