Add --user-data-dir CLI flag and propose renaming support_dir to data_dir (#26886)

This PR introduces support for a `--user-data-dir` CLI flag to override
Zed's data directory and proposes renaming `support_dir` to `data_dir`
for better cross-platform clarity. It builds on the discussion in #25349
about custom data directories, aiming to provide a flexible
cross-platform solution.

### Changes

The PR is split into two commits:
1. **[feat(cli): add --user-data-dir to override data
directory](https://github.com/zed-industries/zed/pull/26886/commits/28e8889105847401e783d1739722d0998459fe5a)**
2. **[refactor(paths): rename support_dir to data_dir for cross-platform
clarity](https://github.com/zed-industries/zed/pull/26886/commits/affd2fc606b39af1b25432a688a9006229a8fc3a)**


### Context
Inspired by the need for custom data directories discussed in #25349,
this PR provides an immediate implementation in the first commit, while
the second commit suggests a naming improvement for broader appeal.
@mikayla-maki, I’d appreciate your feedback, especially on the rename
proposal, given your involvement in the original discussion!

### Testing
- `cargo build `
- `./target/debug/zed --user-data-dir ~/custom-data-dir`

Release Notes:
- Added --user-data-dir CLI flag

---------

Signed-off-by: Marko Kungla <marko.kungla@gmail.com>
This commit is contained in:
Marko Kungla 2025-04-11 00:16:43 +03:00 committed by GitHub
parent d88694f8da
commit 384868e597
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 172 additions and 71 deletions

View file

@ -312,7 +312,7 @@ impl ManagedNodeRuntime {
let version = Self::VERSION;
let folder_name = format!("node-{version}-{os}-{arch}");
let node_containing_dir = paths::support_dir().join("node");
let node_containing_dir = paths::data_dir().join("node");
let node_dir = node_containing_dir.join(folder_name);
let node_binary = node_dir.join(Self::NODE_PATH);
let npm_file = node_dir.join(Self::NPM_PATH);
@ -498,7 +498,7 @@ impl SystemNodeRuntime {
)
}
let scratch_dir = paths::support_dir().join("node");
let scratch_dir = paths::data_dir().join("node");
fs::create_dir(&scratch_dir).await.ok();
fs::create_dir(scratch_dir.join("cache")).await.ok();