Remove config option and read config file from ${workspace}/clice.toml (#258)

This commit is contained in:
ykiko
2025-09-14 22:42:02 +08:00
committed by GitHub
parent 50ef22f197
commit bba3ee3174
15 changed files with 197 additions and 346 deletions

View File

@@ -2,16 +2,30 @@
这是 `clice.toml` 的文档。
## Server
## Project
| 名称 | 类型 | 默认值 |
| ------------------- | -------- | ----------------------------- |
| `project.cache_dir` | `string` | `"${workspace}/.clice/cache"` |
用于储存 PCH 和 PCM 缓存的文件夹。
<br>
| 名称 | 类型 | 默认值 |
| ------------------- | -------- | ----------------------------- |
| `project.index_dir` | `string` | `"${workspace}/.clice/index"` |
用于储存索引文件的文件夹。
<br>
## Rule
`[[rules]]` 表示一个对象数组,其中每个对象都拥有下面这些属性
<br>
| 名称              | 类型                |
| ----------------- | ------------------- |
| `[rules].pattern` | `array` of `string` |
| 名称 | 类型 |
| ------------------ | ------------------- |
| `[rules].patterns` | `array` of `string` |
用于匹配文件路径的 glob patterns遵循 LSP 的 [标准](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentFilter)。
@@ -23,70 +37,16 @@
- `[!...]`: 排除要匹配的路径段中的字符范围 (例如,`example.[!0-9]` 匹配 `example.a`, `example.b`,但不匹配 `example.0`)。
<br>
| 名称             | 类型                | 默认值 |
| ---------------- | ------------------- | ------- |
| `[rules].append` | `array` of `string` | `[]`    |
| 名称 | 类型 | 默认值 |
| ---------------- | ------------------- | ------ |
| `[rules].append` | `array` of `string` | `[]` |
追加到原始命令列表中的命令。例如,`append = ["-std=c++17"]`
<br>
| 名称             | 类型                | 默认值 |
| ---------------- | ------------------- | ------- |
| `[rules].remove` | `array` of `string` | `[]`    |
| 名称 | 类型 | 默认值 |
| ---------------- | ------------------- | ------ |
| `[rules].remove` | `array` of `string` | `[]` |
从原始命令列表中移除的命令。例如,`remove = ["-std=c++11"]`
<br>
| 名称               | 类型     | 默认值  |
| ------------------ | -------- | -------- |
| `[rules].readonly` | `string` | `"auto"` |
控制文件是否被视为只读。值可以是 `"auto"``"always"``"never"` 中的一个。
- `"auto"`: 在你编辑文件之前,文件被视为只读。
- `"always"`: 始终将文件视为只读。
- `"never"`: 始终将文件视为非只读。
只读意味着文件不可编辑,并且像代码操作 (code actions) 或补全 (completions) 这样的 LSP 请求不会在其上触发。这避免了动态计算,并允许直接加载预先索引的结果,从而提高性能。
<br>
| 名称             | 类型     | 默认值  |
| ---------------- | -------- | -------- |
| `[rules].header` | `string` | `"auto"` |
控制如何处理头文件。值可以是 `"auto"``"always"``"never"` 中的一个。
- `"auto"`: 首先尝试推断头文件上下文。如果未找到头文件上下文,文件将被视为普通的源文件。
- `"always"`: 始终将文件视为头文件。如果未找到头文件上下文,将会报告错误。
- `"never"`: 始终将文件视为源文件。
头文件上下文指的是与该头文件相关联的源文件或其他元数据。
<br>
| 名称               | 类型                | 默认值 |
| ------------------ | ------------------- | ------- |
| `[rules].contexts` | `array` of `string` | `[]`    |
为文件指定额外的头文件上下文 (文件路径)。
通常,一旦文件被索引,头文件上下文会自动推断。但是,如果你需要在索引完成前获得即时上下文,可以使用此字段手动提供。
## Cache
| 名称        | 类型     | 默认值                       |
| ----------- | -------- | ----------------------------- |
| `cache.dir` | `string` | `"${workspace}/.clice/cache"` |
用于储存 PCH 和 PCM 缓存的文件夹。
<br>
## Index
| 名称        | 类型     | 默认值                       |
| ----------- | -------- | ----------------------------- |
| `index.dir` | `string` | `"${workspace}/.clice/index"` |
用于储存索引文件的文件夹。
<br>
## Feature