Skip to content

Commit da6c2d2

Browse files
committed
Add file associations doc.
1 parent 95c16c5 commit da6c2d2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/fileassociations.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# File Associations in Ecode Projects
2+
3+
ecode supports project-specific file associations, allowing you to map file patterns or names to specific programming languages for syntax highlighting, autocompletion, and other language-specific features. This is configured via the `.ecode/settings.json` file in your project root, using the same format as VS Code for easy compatibility.
4+
5+
## Setup
6+
7+
1. **Create the configuration file**: In your project's root directory, create a folder named `.ecode` if it doesn't exist, and inside it, add a `settings.json` file.
8+
9+
2. **Add file associations**: In `settings.json`, include a `"files.associations"` object. Keys are glob patterns or file names, and values are the target [language ID](https://github.com/SpartanJ/ecode/?tab=readme-ov-file#language-support-table) (e.g., "cpp" for C++).
10+
11+
Example ` .ecode/settings.json`:
12+
```json
13+
{
14+
"files.associations": {
15+
"glob_pattern": "language_name",
16+
"functional": "cpp",
17+
"map": "cpp",
18+
"**/c++/**": "cpp"
19+
}
20+
}
21+
```
22+
23+
- **Simple file name**: `"functional": "cpp"` associates files named "functional" with C++.
24+
- **Glob pattern**: `"**/c++/**": "cpp"` matches any file in a subdirectory named "c++".
25+
- Language IDs follow standard conventions (e.g., "javascript", "python", "json"). Check ecode's [supported languages for exact IDs](https://github.com/SpartanJ/ecode/?tab=readme-ov-file#language-support-table).
26+
27+
3. **Reload the project**: Open or reload your project in ecode. The associations will apply automatically to matching files.
28+
29+
## VS Code Fallback
30+
31+
If `.ecode/settings.json` does not exist, ecode will automatically fall back to `.vscode/settings.json` (if present) and read the `"files.associations"` from there. This ensures compatibility with VS Code workspaces. You can migrate by copying the relevant section to `.ecode/settings.json` for ecode-specific overrides.

0 commit comments

Comments
 (0)