turbo-editors/turbo-rustpublic Fork 0
f69efbe
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-rust.git
git clone ssh://git@rickub.com/turbo-editors/turbo-rust.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

📦 Turbo Rust

k33g committed 2026-09-20T09:29:51+02:00 Browse files
f69efbe parent: 5adadd1
added .memory/handoffs/2026-09-20-load-config.md +17 -0
new file mode 100644
@@ -0,0 +1,17 @@
1+# Handoff — 2026-09-20 — `-load-config` (needs turbo-core v1.0.3)
2+
3+## State
4+
5+- `-load-config <url>` wired in `main.go`, three tests in `main_test.go`, docs EN+FR updated. Green under the umbrella `go.work` (`turbo-editors/`), which resolves turbo-core to the local checkout.
6+- **`go.mod` still says turbo-core v1.0.2** — `GOWORK=off make check` fails until turbo-core v1.0.3 is tagged and this is re-pinned. Even under the workspace, the two release-script tests (`TestTheTagScript…`) fail for the same reason: they build a copy of the module outside it. Everything else is green.
7+
8+## Next steps
9+
10+1. When turbo-core v1.0.3 is tagged: `go get rickub.com/turbo-editors/turbo-core@v1.0.3 && go mod tidy && GOWORK=off make check`.
11+2. Try it for real: in an empty directory, `turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init` (the sample repository holds `.turbo-go` only — for this editor a directory with a `.turbo-rust` is needed), then start `turbo-rust` and check the settings took.
12+3. Then `./01-release.tag.sh` as usual.
13+
14+## Traps
15+
16+- The sample configs repository is `rickub.com/turbo-editors/configs`; its git address is `git.rickub.com`, which `configrepo` tries second. A wrong first candidate costs one `ls-remote`, not the load.
17+- The editor refuses when `.turbo-rust` already exists (`configrepo.ErrExists`); there is deliberately no `--force`.
new file mode 100644
@@ -0,0 +1,17 @@
1+# Handoff — 2026-09-20 — `-load-config` (needs turbo-core v1.0.3)
2+
3+## State
4+
5+- `-load-config <url>` wired in `main.go`, three tests in `main_test.go`, docs EN+FR updated. Green under the umbrella `go.work` (`turbo-editors/`), which resolves turbo-core to the local checkout.
6+- **`go.mod` still says turbo-core v1.0.2** — `GOWORK=off make check` fails until turbo-core v1.0.3 is tagged and this is re-pinned. Even under the workspace, the two release-script tests (`TestTheTagScript…`) fail for the same reason: they build a copy of the module outside it. Everything else is green.
7+
8+## Next steps
9+
10+1. When turbo-core v1.0.3 is tagged: `go get rickub.com/turbo-editors/turbo-core@v1.0.3 && go mod tidy && GOWORK=off make check`.
11+2. Try it for real: in an empty directory, `turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init` (the sample repository holds `.turbo-go` only — for this editor a directory with a `.turbo-rust` is needed), then start `turbo-rust` and check the settings took.
12+3. Then `./01-release.tag.sh` as usual.
13+
14+## Traps
15+
16+- The sample configs repository is `rickub.com/turbo-editors/configs`; its git address is `git.rickub.com`, which `configrepo` tries second. A wrong first candidate costs one `ls-remote`, not the load.
17+- The editor refuses when `.turbo-rust` already exists (`configrepo.ErrExists`); there is deliberately no `--force`.
modified .memory/history.md +9 -0
@@ -154,3 +154,12 @@
154154 - **Changes, release tooling**: `.github/workflows/release.yml` (new), `01-release.tag.sh` (rewritten), `03-build-releases.sh` → `02-build-releases.sh` (tag from `$1`, validation, `replace` check, fresh `release/${TAG}/`, `go install` line in the README, no hand-off to 04), `02-release.publish.sh` and `04-release.upload-binaries.sh` deleted, `release.env` rewritten (`TAG="v1.0.0"`, `ABOUT="Turbo Rust"`). All generated from turbo-go's final files with the names substituted; the README paragraph naming this editor's language server and the example file (`src/main.rs`) kept from the old 03. Docs: the release section and the wrong-commit variant of `docs/{en,fr}/how-to/make-a-release.md` rewritten.
155155 - **Tests**: `release_test.go` regenerated from turbo-go's — see `summary.md`. The file-writing helper is `writeTestFile` because turbo-python's `main_test.go` owns `writeFile`, and the command helper `runOrFail` because `main.go` owns `run`.
156156 - **Not done**: nothing committed or pushed — no commit exists yet and `origin` is unreachable from the sandbox. The workflow has not run on Rickub for this editor; turbo-go's identical one has, and published.
157+
158+## 2026-09-20 — `-load-config <url>`: a shared `.turbo-rust` fetched from a repository
159+
160+- **Asked** (umbrella session, ticket #25 of `turbo-editors/.tickets`): `turbo-rust --load-config <forge URL>` fetches the `.turbo-rust` found at that directory of the repository and copies it into the working directory; the same for every Turbo editor with its own directory name.
161+- **Changes**: `main.go` — `loadConfig` option and flag, `case opts.loadConfig != ""` in `run`, `loadConfig` and `describeLoad`; the work itself is turbo-core's new `configrepo` package (git ls-remote + shallow clone; rickub, GitHub, GitLab, Codeberg URLs). `main_test.go` — three tests (`describeLoad` ×2, `loadConfig` refuses when `.turbo-rust` exists, no network needed). Docs: `docs/{en,fr}/reference/cli.md` (flag, example, files, errors), `docs/{en,fr}/how-to/configure-a-project.md` (new section).
162+- **Depends on turbo-core v1.0.3**, not yet tagged: `go.mod` still pins v1.0.2, so this builds only under the umbrella `go.work` (`turbo-editors/README.md` explains) until `go get rickub.com/turbo-editors/turbo-core@v1.0.3 && go mod tidy`. Verified with `make check` under that workspace.
163+- **Not done**: not committed; go.mod not re-pinned; not run against a real terminal.
164+- **Correction, same session**: under the workspace everything passes **except `TestTheTagScriptTagsAndPushesForReal` and `TestTheTagScriptRefusesATagItAlreadyPublished`** — they copy the module elsewhere and run `make check` there, outside the workspace, where turbo-core v1.0.2 from the proxy has no `configrepo`. They go green the moment `go.mod` is re-pinned to v1.0.3. The package diagram (`docs/diagrams/packages.drawio`, where the module has one) gained a `configrepo` box and a `main → configrepo` arrow, which its own test demanded.
165+
@@ -154,3 +154,12 @@
154 - **Changes, release tooling**: `.github/workflows/release.yml` (new), `01-release.tag.sh` (rewritten), `03-build-releases.sh` → `02-build-releases.sh` (tag from `$1`, validation, `replace` check, fresh `release/${TAG}/`, `go install` line in the README, no hand-off to 04), `02-release.publish.sh` and `04-release.upload-binaries.sh` deleted, `release.env` rewritten (`TAG="v1.0.0"`, `ABOUT="Turbo Rust"`). All generated from turbo-go's final files with the names substituted; the README paragraph naming this editor's language server and the example file (`src/main.rs`) kept from the old 03. Docs: the release section and the wrong-commit variant of `docs/{en,fr}/how-to/make-a-release.md` rewritten.154 - **Changes, release tooling**: `.github/workflows/release.yml` (new), `01-release.tag.sh` (rewritten), `03-build-releases.sh` → `02-build-releases.sh` (tag from `$1`, validation, `replace` check, fresh `release/${TAG}/`, `go install` line in the README, no hand-off to 04), `02-release.publish.sh` and `04-release.upload-binaries.sh` deleted, `release.env` rewritten (`TAG="v1.0.0"`, `ABOUT="Turbo Rust"`). All generated from turbo-go's final files with the names substituted; the README paragraph naming this editor's language server and the example file (`src/main.rs`) kept from the old 03. Docs: the release section and the wrong-commit variant of `docs/{en,fr}/how-to/make-a-release.md` rewritten.
155 - **Tests**: `release_test.go` regenerated from turbo-go's — see `summary.md`. The file-writing helper is `writeTestFile` because turbo-python's `main_test.go` owns `writeFile`, and the command helper `runOrFail` because `main.go` owns `run`.155 - **Tests**: `release_test.go` regenerated from turbo-go's — see `summary.md`. The file-writing helper is `writeTestFile` because turbo-python's `main_test.go` owns `writeFile`, and the command helper `runOrFail` because `main.go` owns `run`.
156 - **Not done**: nothing committed or pushed — no commit exists yet and `origin` is unreachable from the sandbox. The workflow has not run on Rickub for this editor; turbo-go's identical one has, and published.156 - **Not done**: nothing committed or pushed — no commit exists yet and `origin` is unreachable from the sandbox. The workflow has not run on Rickub for this editor; turbo-go's identical one has, and published.
157+
158+## 2026-09-20 — `-load-config <url>`: a shared `.turbo-rust` fetched from a repository
159+
160+- **Asked** (umbrella session, ticket #25 of `turbo-editors/.tickets`): `turbo-rust --load-config <forge URL>` fetches the `.turbo-rust` found at that directory of the repository and copies it into the working directory; the same for every Turbo editor with its own directory name.
161+- **Changes**: `main.go` — `loadConfig` option and flag, `case opts.loadConfig != ""` in `run`, `loadConfig` and `describeLoad`; the work itself is turbo-core's new `configrepo` package (git ls-remote + shallow clone; rickub, GitHub, GitLab, Codeberg URLs). `main_test.go` — three tests (`describeLoad` ×2, `loadConfig` refuses when `.turbo-rust` exists, no network needed). Docs: `docs/{en,fr}/reference/cli.md` (flag, example, files, errors), `docs/{en,fr}/how-to/configure-a-project.md` (new section).
162+- **Depends on turbo-core v1.0.3**, not yet tagged: `go.mod` still pins v1.0.2, so this builds only under the umbrella `go.work` (`turbo-editors/README.md` explains) until `go get rickub.com/turbo-editors/turbo-core@v1.0.3 && go mod tidy`. Verified with `make check` under that workspace.
163+- **Not done**: not committed; go.mod not re-pinned; not run against a real terminal.
164+- **Correction, same session**: under the workspace everything passes **except `TestTheTagScriptTagsAndPushesForReal` and `TestTheTagScriptRefusesATagItAlreadyPublished`** — they copy the module elsewhere and run `make check` there, outside the workspace, where turbo-core v1.0.2 from the proxy has no `configrepo`. They go green the moment `go.mod` is re-pinned to v1.0.3. The package diagram (`docs/diagrams/packages.drawio`, where the module has one) gained a `configrepo` box and a `main → configrepo` arrow, which its own test demanded.
165+
modified .memory/summary.md +5 -0
@@ -99,3 +99,8 @@ python3 ~/.claude/skills/quality/scripts/quality_report.py --workspace .
9999 - **Module path `rickub.com/turbo-editors/turbo-rust`**, depending on `rickub.com/turbo-editors/turbo-core v1.0.0` — the first turbo-core version published under that path (`v0.9.0` on the proxy still declares the Codeberg path and cannot be required as `rickub.com/…`). Every import, the Makefile's `VERSION_PKG`, `scripts/install.sh`, the README and the docs say `rickub.com`. `GOWORK=off make check` green. The repository on this side is a fresh `git init` with `origin` at `ssh://git@rickub.com/turbo-editors/turbo-rust.git` and **no commit yet**; `01-release.tag.sh` makes the first one.
100100 - **Releases are one script and one workflow**, modelled on turbo-core's and identical to turbo-go's. `01-release.tag.sh` runs `make check` under `TURBO_RUST_RELEASING=1`, refuses a tag taken locally or on origin (bump, never move), refuses a `replace` in `go.mod`, commits, pushes the current branch, then tags and pushes the tag. That push starts `.github/workflows/release.yml`: `go test` with `TURBO_RUST_RELEASING=1`, `./02-build-releases.sh "${GITHUB_REF_NAME}"`, release notes from the tag message, a run artifact, then `softprops/action-gh-release@v2` attaching `turbo-rust-*`, `SHA256SUMS` and `README.md` with the job's own `GITHUB_TOKEN` — the only credential Rickub's release API accepts. **`02-release.publish.sh` and `04-release.upload-binaries.sh` are gone**; the build script is now `02-build-releases.sh`, takes the tag as `$1` (CI has no `release.env`), validates it, refuses a `replace`, and starts from an empty `release/${TAG}/`. `release.env` holds only `TAG` and `ABOUT`; `turbo-rust.token.env` is read by nothing.
101101 - **`release_test.go`** runs `01` for real against a throwaway bare remote (publishes, then refuses the same tag), runs `02` alone to see it refuse `v0.o.0`, and asserts the workflow's trigger, `contents: write`, `./02-build-releases.sh`, `fail_on_unmatched_files`, docs linked at the tag, no `secrets.`, and `TURBO_RUST_RELEASING`. The copy of the module for the clone leaves out `.git`, `bin`, `release`, `kits`, `demo`, `demos`, `*.env` and `go.work*`; children run with `GOWORK=off`.
102+
103+## State as of 2026-09-20
104+
105+- **`-load-config <url>` is wired** (`main.go`: `loadConfig`, `describeLoad`), on top of turbo-core's `configrepo`. It needs **turbo-core v1.0.3**, which is not tagged yet; `go.mod` pins v1.0.2, so the editor builds only under the umbrella `go.work` until re-pinned. A project with a `.turbo-rust` already is refused, not overwritten.
106+
@@ -99,3 +99,8 @@ python3 ~/.claude/skills/quality/scripts/quality_report.py --workspace .
99 - **Module path `rickub.com/turbo-editors/turbo-rust`**, depending on `rickub.com/turbo-editors/turbo-core v1.0.0` — the first turbo-core version published under that path (`v0.9.0` on the proxy still declares the Codeberg path and cannot be required as `rickub.com/…`). Every import, the Makefile's `VERSION_PKG`, `scripts/install.sh`, the README and the docs say `rickub.com`. `GOWORK=off make check` green. The repository on this side is a fresh `git init` with `origin` at `ssh://git@rickub.com/turbo-editors/turbo-rust.git` and **no commit yet**; `01-release.tag.sh` makes the first one.99 - **Module path `rickub.com/turbo-editors/turbo-rust`**, depending on `rickub.com/turbo-editors/turbo-core v1.0.0` — the first turbo-core version published under that path (`v0.9.0` on the proxy still declares the Codeberg path and cannot be required as `rickub.com/…`). Every import, the Makefile's `VERSION_PKG`, `scripts/install.sh`, the README and the docs say `rickub.com`. `GOWORK=off make check` green. The repository on this side is a fresh `git init` with `origin` at `ssh://git@rickub.com/turbo-editors/turbo-rust.git` and **no commit yet**; `01-release.tag.sh` makes the first one.
100 - **Releases are one script and one workflow**, modelled on turbo-core's and identical to turbo-go's. `01-release.tag.sh` runs `make check` under `TURBO_RUST_RELEASING=1`, refuses a tag taken locally or on origin (bump, never move), refuses a `replace` in `go.mod`, commits, pushes the current branch, then tags and pushes the tag. That push starts `.github/workflows/release.yml`: `go test` with `TURBO_RUST_RELEASING=1`, `./02-build-releases.sh "${GITHUB_REF_NAME}"`, release notes from the tag message, a run artifact, then `softprops/action-gh-release@v2` attaching `turbo-rust-*`, `SHA256SUMS` and `README.md` with the job's own `GITHUB_TOKEN` — the only credential Rickub's release API accepts. **`02-release.publish.sh` and `04-release.upload-binaries.sh` are gone**; the build script is now `02-build-releases.sh`, takes the tag as `$1` (CI has no `release.env`), validates it, refuses a `replace`, and starts from an empty `release/${TAG}/`. `release.env` holds only `TAG` and `ABOUT`; `turbo-rust.token.env` is read by nothing.100 - **Releases are one script and one workflow**, modelled on turbo-core's and identical to turbo-go's. `01-release.tag.sh` runs `make check` under `TURBO_RUST_RELEASING=1`, refuses a tag taken locally or on origin (bump, never move), refuses a `replace` in `go.mod`, commits, pushes the current branch, then tags and pushes the tag. That push starts `.github/workflows/release.yml`: `go test` with `TURBO_RUST_RELEASING=1`, `./02-build-releases.sh "${GITHUB_REF_NAME}"`, release notes from the tag message, a run artifact, then `softprops/action-gh-release@v2` attaching `turbo-rust-*`, `SHA256SUMS` and `README.md` with the job's own `GITHUB_TOKEN` — the only credential Rickub's release API accepts. **`02-release.publish.sh` and `04-release.upload-binaries.sh` are gone**; the build script is now `02-build-releases.sh`, takes the tag as `$1` (CI has no `release.env`), validates it, refuses a `replace`, and starts from an empty `release/${TAG}/`. `release.env` holds only `TAG` and `ABOUT`; `turbo-rust.token.env` is read by nothing.
101 - **`release_test.go`** runs `01` for real against a throwaway bare remote (publishes, then refuses the same tag), runs `02` alone to see it refuse `v0.o.0`, and asserts the workflow's trigger, `contents: write`, `./02-build-releases.sh`, `fail_on_unmatched_files`, docs linked at the tag, no `secrets.`, and `TURBO_RUST_RELEASING`. The copy of the module for the clone leaves out `.git`, `bin`, `release`, `kits`, `demo`, `demos`, `*.env` and `go.work*`; children run with `GOWORK=off`.101 - **`release_test.go`** runs `01` for real against a throwaway bare remote (publishes, then refuses the same tag), runs `02` alone to see it refuse `v0.o.0`, and asserts the workflow's trigger, `contents: write`, `./02-build-releases.sh`, `fail_on_unmatched_files`, docs linked at the tag, no `secrets.`, and `TURBO_RUST_RELEASING`. The copy of the module for the clone leaves out `.git`, `bin`, `release`, `kits`, `demo`, `demos`, `*.env` and `go.work*`; children run with `GOWORK=off`.
102+
103+## State as of 2026-09-20
104+
105+- **`-load-config <url>` is wired** (`main.go`: `loadConfig`, `describeLoad`), on top of turbo-core's `configrepo`. It needs **turbo-core v1.0.3**, which is not tagged yet; `go.mod` pins v1.0.2, so the editor builds only under the umbrella `go.work` until re-pinned. A project with a `.turbo-rust` already is refused, not overwritten.
106+
added INSTALL.MACOS.md +11 -0
new file mode 100644
@@ -0,0 +1,11 @@
1+# Install `turbo-rust` on macOS
2+
3+```bash
4+# download the binary release in https://rickub.com/turbo-editors/turbo-rust/releases
5+VERSION=1.0.3
6+curl -fsSLO "https://rickub.com/turbo-editors/turbo-rust/releases/download/v${VERSION}/turbo-rust-${VERSION}-darwin-arm64"
7+chmod +x ./turbo-rust-${VERSION}-darwin-arm64
8+xattr -cr ./turbo-rust-${VERSION}-darwin-arm64
9+sudo rm /usr/local/bin/turbo-rust
10+sudo cp ./turbo-rust-${VERSION}-darwin-arm64 /usr/local/bin/turbo-rust
11+```
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,11 @@
1+# Install `turbo-rust` on macOS
2+
3+```bash
4+# download the binary release in https://rickub.com/turbo-editors/turbo-rust/releases
5+VERSION=1.0.3
6+curl -fsSLO "https://rickub.com/turbo-editors/turbo-rust/releases/download/v${VERSION}/turbo-rust-${VERSION}-darwin-arm64"
7+chmod +x ./turbo-rust-${VERSION}-darwin-arm64
8+xattr -cr ./turbo-rust-${VERSION}-darwin-arm64
9+sudo rm /usr/local/bin/turbo-rust
10+sudo cp ./turbo-rust-${VERSION}-darwin-arm64 /usr/local/bin/turbo-rust
11+```
\ No newline at end of file\ No newline at end of file
modified docs/en/how-to/configure-a-project.md +13 -0
@@ -70,6 +70,19 @@ turbo-rust -theme turbo-dark main.rs
7070
7171 **Options ▸ Project settings…** opens it again. It is greyed out in a project that has none.
7272
73+## Start from a shared configuration
74+
75+A team can keep ready-made configurations in a repository — one directory per kind of project, each with a `.turbo-rust` inside. Point the editor at the directory, with the URL the browser shows, and it copies that `.turbo-rust` into the current directory:
76+
77+```bash
78+cd my-project
79+turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init
80+```
81+
82+It prints what arrived and exits; the next `turbo-rust` opens the project with those settings, snippets and tools in force. The URL may be on rickub, GitHub, GitLab or Codeberg, and may point at the directory, at the `.turbo-rust` inside it, or at the repository itself for its root on the default branch. `git` must be installed: the fetch is a shallow clone.
83+
84+A project that already has a `.turbo-rust` is left alone — the editor refuses rather than overwrite what the project decided. Move the directory away first if you mean to replace it.
85+
7386 ## Variants
7487
7588 - **You start the editor from a subdirectory.** The settings are not found: only `./.turbo-rust` is looked at, with no walk up towards the project root. Start from the project's own directory, or pass `-theme` for that run.
@@ -70,6 +70,19 @@ turbo-rust -theme turbo-dark main.rs
70 70
71 **Options ▸ Project settings…** opens it again. It is greyed out in a project that has none.71 **Options ▸ Project settings…** opens it again. It is greyed out in a project that has none.
72 72
73+## Start from a shared configuration
74+
75+A team can keep ready-made configurations in a repository — one directory per kind of project, each with a `.turbo-rust` inside. Point the editor at the directory, with the URL the browser shows, and it copies that `.turbo-rust` into the current directory:
76+
77+```bash
78+cd my-project
79+turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init
80+```
81+
82+It prints what arrived and exits; the next `turbo-rust` opens the project with those settings, snippets and tools in force. The URL may be on rickub, GitHub, GitLab or Codeberg, and may point at the directory, at the `.turbo-rust` inside it, or at the repository itself for its root on the default branch. `git` must be installed: the fetch is a shallow clone.
83+
84+A project that already has a `.turbo-rust` is left alone — the editor refuses rather than overwrite what the project decided. Move the directory away first if you mean to replace it.
85+
73 ## Variants86 ## Variants
74 87
75 - **You start the editor from a subdirectory.** The settings are not found: only `./.turbo-rust` is looked at, with no walk up towards the project root. Start from the project's own directory, or pass `-theme` for that run.88 - **You start the editor from a subdirectory.** The settings are not found: only `./.turbo-rust` is looked at, with no walk up towards the project root. Start from the project's own directory, or pass `-theme` for that run.
modified docs/en/reference/cli.md +7 -0
@@ -18,6 +18,7 @@ Each `file` is opened in its own window. A file that does not exist yet is opene
1818 | `-list-themes` | bool | `false` | Print every loadable theme with its description, then the user theme directory, and exit. |
1919 | `-no-lsp` | bool | `false` | Do not start a language server. Colouring and editing are unaffected. |
2020 | `-version` | bool | `false` | Print `Turbo Rust <version>` on one line, with the commit and build date when the build recorded them, and exit. See [the version number](versioning.md). |
21+| `-load-config <url>` | string | none | Copy the `.turbo-rust` directory found at a repository URL — rickub, GitHub, GitLab or Codeberg, the URL of the directory as the browser shows it — into the working directory, print what arrived, and exit. Needs `git`. Refuses when `./.turbo-rust` already exists. The editor is not started. |
2122 | `-h`, `-help` | bool | `false` | Print the flag list and exit. |
2223
2324 ## Environment
@@ -34,6 +35,7 @@ Each `file` is opened in its own window. A file that does not exist yet is opene
3435 | --- | --- |
3536 | `$TURBO_RUST_THEME_DIR/*.toml` | User themes, when the variable is set. |
3637 | `./.turbo-rust/settings.toml` | This project's settings, read once at start-up. See [project settings](project-settings.md). |
38+| `./.turbo-rust/` (written) | Created by `-load-config` from a repository's copy, when the project has none yet. |
3739 | `~/.config/turbo-rust/themes/*.toml` | User themes on Linux (`os.UserConfigDir`). |
3840 | `~/Library/Application Support/turbo-rust/themes/*.toml` | User themes on macOS. |
3941 | `<module>/Cargo.toml` | Located by walking up from the first file; its directory becomes the language server's root. |
@@ -72,6 +74,7 @@ turbo-rust main.rs Cargo.toml # two windows
7274 turbo-rust -theme turbo-dark main.rs # a different theme
7375 turbo-rust -no-lsp main.rs # no language server
7476 turbo-rust -list-themes # what themes exist
77+turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init # start from a shared configuration
7578 ```
7679
7780 ## Installer
@@ -98,3 +101,7 @@ turbo-rust -list-themes # what themes exist
98101 | `turbo-rust: initialising the terminal: …` | The terminal was opened but could not be put into raw mode. |
99102 | `Cannot open` (in a dialog) | The path is a directory, or is not readable. |
100103 | `Cannot save` (in a dialog) | The directory does not exist, or is not writable. |
104+| `turbo-rust: configrepo: the project already has a configuration directory: …` | `-load-config` into a project that already has `.turbo-rust`. Move it away first. |
105+| `turbo-rust: configrepo: git is not installed` | `-load-config` needs the `git` command on `PATH`. |
106+| `turbo-rust: configrepo: no configuration directory at that path: …` | The repository was found but holds no `.turbo-rust` where the URL points. |
107+| `turbo-rust: configrepo: no repository answered: …` | No clone address for that URL answered; the URL, the network, or a private repository. |
@@ -18,6 +18,7 @@ Each `file` is opened in its own window. A file that does not exist yet is opene
18 | `-list-themes` | bool | `false` | Print every loadable theme with its description, then the user theme directory, and exit. |18 | `-list-themes` | bool | `false` | Print every loadable theme with its description, then the user theme directory, and exit. |
19 | `-no-lsp` | bool | `false` | Do not start a language server. Colouring and editing are unaffected. |19 | `-no-lsp` | bool | `false` | Do not start a language server. Colouring and editing are unaffected. |
20 | `-version` | bool | `false` | Print `Turbo Rust <version>` on one line, with the commit and build date when the build recorded them, and exit. See [the version number](versioning.md). |20 | `-version` | bool | `false` | Print `Turbo Rust <version>` on one line, with the commit and build date when the build recorded them, and exit. See [the version number](versioning.md). |
21+| `-load-config <url>` | string | none | Copy the `.turbo-rust` directory found at a repository URL — rickub, GitHub, GitLab or Codeberg, the URL of the directory as the browser shows it — into the working directory, print what arrived, and exit. Needs `git`. Refuses when `./.turbo-rust` already exists. The editor is not started. |
21 | `-h`, `-help` | bool | `false` | Print the flag list and exit. |22 | `-h`, `-help` | bool | `false` | Print the flag list and exit. |
22 23
23 ## Environment24 ## Environment
@@ -34,6 +35,7 @@ Each `file` is opened in its own window. A file that does not exist yet is opene
34 | --- | --- |35 | --- | --- |
35 | `$TURBO_RUST_THEME_DIR/*.toml` | User themes, when the variable is set. |36 | `$TURBO_RUST_THEME_DIR/*.toml` | User themes, when the variable is set. |
36 | `./.turbo-rust/settings.toml` | This project's settings, read once at start-up. See [project settings](project-settings.md). |37 | `./.turbo-rust/settings.toml` | This project's settings, read once at start-up. See [project settings](project-settings.md). |
38+| `./.turbo-rust/` (written) | Created by `-load-config` from a repository's copy, when the project has none yet. |
37 | `~/.config/turbo-rust/themes/*.toml` | User themes on Linux (`os.UserConfigDir`). |39 | `~/.config/turbo-rust/themes/*.toml` | User themes on Linux (`os.UserConfigDir`). |
38 | `~/Library/Application Support/turbo-rust/themes/*.toml` | User themes on macOS. |40 | `~/Library/Application Support/turbo-rust/themes/*.toml` | User themes on macOS. |
39 | `<module>/Cargo.toml` | Located by walking up from the first file; its directory becomes the language server's root. |41 | `<module>/Cargo.toml` | Located by walking up from the first file; its directory becomes the language server's root. |
@@ -72,6 +74,7 @@ turbo-rust main.rs Cargo.toml # two windows
72 turbo-rust -theme turbo-dark main.rs # a different theme74 turbo-rust -theme turbo-dark main.rs # a different theme
73 turbo-rust -no-lsp main.rs # no language server75 turbo-rust -no-lsp main.rs # no language server
74 turbo-rust -list-themes # what themes exist76 turbo-rust -list-themes # what themes exist
77+turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init # start from a shared configuration
75 ```78 ```
76 79
77 ## Installer80 ## Installer
@@ -98,3 +101,7 @@ turbo-rust -list-themes # what themes exist
98 | `turbo-rust: initialising the terminal: …` | The terminal was opened but could not be put into raw mode. |101 | `turbo-rust: initialising the terminal: …` | The terminal was opened but could not be put into raw mode. |
99 | `Cannot open` (in a dialog) | The path is a directory, or is not readable. |102 | `Cannot open` (in a dialog) | The path is a directory, or is not readable. |
100 | `Cannot save` (in a dialog) | The directory does not exist, or is not writable. |103 | `Cannot save` (in a dialog) | The directory does not exist, or is not writable. |
104+| `turbo-rust: configrepo: the project already has a configuration directory: …` | `-load-config` into a project that already has `.turbo-rust`. Move it away first. |
105+| `turbo-rust: configrepo: git is not installed` | `-load-config` needs the `git` command on `PATH`. |
106+| `turbo-rust: configrepo: no configuration directory at that path: …` | The repository was found but holds no `.turbo-rust` where the URL points. |
107+| `turbo-rust: configrepo: no repository answered: …` | No clone address for that URL answered; the URL, the network, or a private repository. |
modified docs/fr/how-to/configure-a-project.md +13 -0
@@ -70,6 +70,19 @@ turbo-rust -theme turbo-dark main.rs
7070
7171 **Options ▸ Project settings…** le rouvre. L'entrée est grisée dans un projet qui n'en a pas.
7272
73+## Partir d'une configuration partagée
74+
75+Une équipe peut garder des configurations toutes prêtes dans un dépôt — un dossier par sorte de projet, chacun avec un `.turbo-rust` dedans. Donnez à l'éditeur l'URL du dossier, telle que le navigateur l'affiche, et il copie ce `.turbo-rust` dans le répertoire courant :
76+
77+```bash
78+cd mon-projet
79+turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init
80+```
81+
82+Il affiche ce qui est arrivé et quitte ; le `turbo-rust` suivant ouvre le projet avec ces réglages, extraits et outils en vigueur. L'URL peut être sur rickub, GitHub, GitLab ou Codeberg, et pointer sur le dossier, sur le `.turbo-rust` qu'il contient, ou sur le dépôt lui-même pour sa racine sur la branche par défaut. `git` doit être installé : la récupération est un clone superficiel.
83+
84+Un projet qui a déjà un `.turbo-rust` est laissé tel quel — l'éditeur refuse plutôt que d'écraser ce que le projet a décidé. Déplacez d'abord le dossier si vous voulez le remplacer.
85+
7386 ## Variantes
7487
7588 - **Vous lancez l'éditeur depuis un sous-dossier.** Les réglages ne sont pas trouvés : seul `./.turbo-rust` est consulté, sans remontée vers la racine du projet. Lancez depuis le dossier du projet, ou passez `-theme` pour cette fois.
@@ -70,6 +70,19 @@ turbo-rust -theme turbo-dark main.rs
70 70
71 **Options ▸ Project settings…** le rouvre. L'entrée est grisée dans un projet qui n'en a pas.71 **Options ▸ Project settings…** le rouvre. L'entrée est grisée dans un projet qui n'en a pas.
72 72
73+## Partir d'une configuration partagée
74+
75+Une équipe peut garder des configurations toutes prêtes dans un dépôt — un dossier par sorte de projet, chacun avec un `.turbo-rust` dedans. Donnez à l'éditeur l'URL du dossier, telle que le navigateur l'affiche, et il copie ce `.turbo-rust` dans le répertoire courant :
76+
77+```bash
78+cd mon-projet
79+turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init
80+```
81+
82+Il affiche ce qui est arrivé et quitte ; le `turbo-rust` suivant ouvre le projet avec ces réglages, extraits et outils en vigueur. L'URL peut être sur rickub, GitHub, GitLab ou Codeberg, et pointer sur le dossier, sur le `.turbo-rust` qu'il contient, ou sur le dépôt lui-même pour sa racine sur la branche par défaut. `git` doit être installé : la récupération est un clone superficiel.
83+
84+Un projet qui a déjà un `.turbo-rust` est laissé tel quel — l'éditeur refuse plutôt que d'écraser ce que le projet a décidé. Déplacez d'abord le dossier si vous voulez le remplacer.
85+
73 ## Variantes86 ## Variantes
74 87
75 - **Vous lancez l'éditeur depuis un sous-dossier.** Les réglages ne sont pas trouvés : seul `./.turbo-rust` est consulté, sans remontée vers la racine du projet. Lancez depuis le dossier du projet, ou passez `-theme` pour cette fois.88 - **Vous lancez l'éditeur depuis un sous-dossier.** Les réglages ne sont pas trouvés : seul `./.turbo-rust` est consulté, sans remontée vers la racine du projet. Lancez depuis le dossier du projet, ou passez `-theme` pour cette fois.
modified docs/fr/reference/cli.md +7 -0
@@ -18,6 +18,7 @@ Chaque `fichier` est ouvert dans sa propre fenêtre. Un fichier qui n'existe pas
1818 | `-list-themes` | booléen | `false` | Affiche chaque thème chargeable avec sa description, puis le répertoire de thèmes utilisateur, et quitte. |
1919 | `-no-lsp` | booléen | `false` | Ne démarre pas de serveur de langage. La coloration et l'édition sont inchangées. |
2020 | `-version` | booléen | `false` | Affiche `Turbo Rust <version>` sur une ligne, avec le commit et la date de build quand le build les a enregistrés, puis quitte. Voir [le numéro de version](versioning.md). |
21+| `-load-config <url>` | chaîne | aucune | Copie le répertoire `.turbo-rust` trouvé à l'URL d'un dépôt — rickub, GitHub, GitLab ou Codeberg, l'URL du dossier telle que le navigateur l'affiche — dans le répertoire courant, affiche ce qui est arrivé, et quitte. Nécessite `git`. Refuse si `./.turbo-rust` existe déjà. L'éditeur n'est pas lancé. |
2122 | `-h`, `-help` | booléen | `false` | Affiche la liste des options et quitte. |
2223
2324 ## Environnement
@@ -34,6 +35,7 @@ Chaque `fichier` est ouvert dans sa propre fenêtre. Un fichier qui n'existe pas
3435 | --- | --- |
3536 | `$TURBO_RUST_THEME_DIR/*.toml` | Thèmes utilisateur, quand la variable est définie. |
3637 | `./.turbo-rust/settings.toml` | Les réglages de ce projet, lus une fois au démarrage. Voir [réglages de projet](project-settings.md). |
38+| `./.turbo-rust/` (écrit) | Créé par `-load-config` à partir de la copie d'un dépôt, quand le projet n'en a pas encore. |
3739 | `~/.config/turbo-rust/themes/*.toml` | Thèmes utilisateur sous Linux (`os.UserConfigDir`). |
3840 | `~/Library/Application Support/turbo-rust/themes/*.toml` | Thèmes utilisateur sous macOS. |
3941 | `<module>/Cargo.toml` | Trouvé en remontant depuis le premier fichier ; son répertoire devient la racine du serveur de langage. |
@@ -72,6 +74,7 @@ turbo-rust main.rs Cargo.toml # deux fenêtres
7274 turbo-rust -theme turbo-dark main.rs # un autre thème
7375 turbo-rust -no-lsp main.rs # sans serveur de langage
7476 turbo-rust -list-themes # quels thèmes existent
77+turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init # partir d'une configuration partagée
7578 ```
7679
7780 ## Installateur
@@ -98,3 +101,7 @@ turbo-rust -list-themes # quels thèmes existent
98101 | `turbo-rust: initialising the terminal: …` | Le terminal a été ouvert mais n'a pas pu être mis en mode brut. |
99102 | `Cannot open` (dans une boîte) | Le chemin est un répertoire, ou n'est pas lisible. |
100103 | `Cannot save` (dans une boîte) | Le répertoire n'existe pas, ou n'est pas accessible en écriture. |
104+| `turbo-rust: configrepo: the project already has a configuration directory: …` | `-load-config` dans un projet qui a déjà `.turbo-rust`. Déplacez-le d'abord. |
105+| `turbo-rust: configrepo: git is not installed` | `-load-config` a besoin de la commande `git` dans le `PATH`. |
106+| `turbo-rust: configrepo: no configuration directory at that path: …` | Le dépôt existe mais ne contient pas de `.turbo-rust` là où l'URL pointe. |
107+| `turbo-rust: configrepo: no repository answered: …` | Aucune adresse de clone pour cette URL n'a répondu : l'URL, le réseau, ou un dépôt privé. |
@@ -18,6 +18,7 @@ Chaque `fichier` est ouvert dans sa propre fenêtre. Un fichier qui n'existe pas
18 | `-list-themes` | booléen | `false` | Affiche chaque thème chargeable avec sa description, puis le répertoire de thèmes utilisateur, et quitte. |18 | `-list-themes` | booléen | `false` | Affiche chaque thème chargeable avec sa description, puis le répertoire de thèmes utilisateur, et quitte. |
19 | `-no-lsp` | booléen | `false` | Ne démarre pas de serveur de langage. La coloration et l'édition sont inchangées. |19 | `-no-lsp` | booléen | `false` | Ne démarre pas de serveur de langage. La coloration et l'édition sont inchangées. |
20 | `-version` | booléen | `false` | Affiche `Turbo Rust <version>` sur une ligne, avec le commit et la date de build quand le build les a enregistrés, puis quitte. Voir [le numéro de version](versioning.md). |20 | `-version` | booléen | `false` | Affiche `Turbo Rust <version>` sur une ligne, avec le commit et la date de build quand le build les a enregistrés, puis quitte. Voir [le numéro de version](versioning.md). |
21+| `-load-config <url>` | chaîne | aucune | Copie le répertoire `.turbo-rust` trouvé à l'URL d'un dépôt — rickub, GitHub, GitLab ou Codeberg, l'URL du dossier telle que le navigateur l'affiche — dans le répertoire courant, affiche ce qui est arrivé, et quitte. Nécessite `git`. Refuse si `./.turbo-rust` existe déjà. L'éditeur n'est pas lancé. |
21 | `-h`, `-help` | booléen | `false` | Affiche la liste des options et quitte. |22 | `-h`, `-help` | booléen | `false` | Affiche la liste des options et quitte. |
22 23
23 ## Environnement24 ## Environnement
@@ -34,6 +35,7 @@ Chaque `fichier` est ouvert dans sa propre fenêtre. Un fichier qui n'existe pas
34 | --- | --- |35 | --- | --- |
35 | `$TURBO_RUST_THEME_DIR/*.toml` | Thèmes utilisateur, quand la variable est définie. |36 | `$TURBO_RUST_THEME_DIR/*.toml` | Thèmes utilisateur, quand la variable est définie. |
36 | `./.turbo-rust/settings.toml` | Les réglages de ce projet, lus une fois au démarrage. Voir [réglages de projet](project-settings.md). |37 | `./.turbo-rust/settings.toml` | Les réglages de ce projet, lus une fois au démarrage. Voir [réglages de projet](project-settings.md). |
38+| `./.turbo-rust/` (écrit) | Créé par `-load-config` à partir de la copie d'un dépôt, quand le projet n'en a pas encore. |
37 | `~/.config/turbo-rust/themes/*.toml` | Thèmes utilisateur sous Linux (`os.UserConfigDir`). |39 | `~/.config/turbo-rust/themes/*.toml` | Thèmes utilisateur sous Linux (`os.UserConfigDir`). |
38 | `~/Library/Application Support/turbo-rust/themes/*.toml` | Thèmes utilisateur sous macOS. |40 | `~/Library/Application Support/turbo-rust/themes/*.toml` | Thèmes utilisateur sous macOS. |
39 | `<module>/Cargo.toml` | Trouvé en remontant depuis le premier fichier ; son répertoire devient la racine du serveur de langage. |41 | `<module>/Cargo.toml` | Trouvé en remontant depuis le premier fichier ; son répertoire devient la racine du serveur de langage. |
@@ -72,6 +74,7 @@ turbo-rust main.rs Cargo.toml # deux fenêtres
72 turbo-rust -theme turbo-dark main.rs # un autre thème74 turbo-rust -theme turbo-dark main.rs # un autre thème
73 turbo-rust -no-lsp main.rs # sans serveur de langage75 turbo-rust -no-lsp main.rs # sans serveur de langage
74 turbo-rust -list-themes # quels thèmes existent76 turbo-rust -list-themes # quels thèmes existent
77+turbo-rust -load-config https://rickub.com/turbo-editors/configs/tree/main/golang-init # partir d'une configuration partagée
75 ```78 ```
76 79
77 ## Installateur80 ## Installateur
@@ -98,3 +101,7 @@ turbo-rust -list-themes # quels thèmes existent
98 | `turbo-rust: initialising the terminal: …` | Le terminal a été ouvert mais n'a pas pu être mis en mode brut. |101 | `turbo-rust: initialising the terminal: …` | Le terminal a été ouvert mais n'a pas pu être mis en mode brut. |
99 | `Cannot open` (dans une boîte) | Le chemin est un répertoire, ou n'est pas lisible. |102 | `Cannot open` (dans une boîte) | Le chemin est un répertoire, ou n'est pas lisible. |
100 | `Cannot save` (dans une boîte) | Le répertoire n'existe pas, ou n'est pas accessible en écriture. |103 | `Cannot save` (dans une boîte) | Le répertoire n'existe pas, ou n'est pas accessible en écriture. |
104+| `turbo-rust: configrepo: the project already has a configuration directory: …` | `-load-config` dans un projet qui a déjà `.turbo-rust`. Déplacez-le d'abord. |
105+| `turbo-rust: configrepo: git is not installed` | `-load-config` a besoin de la commande `git` dans le `PATH`. |
106+| `turbo-rust: configrepo: no configuration directory at that path: …` | Le dépôt existe mais ne contient pas de `.turbo-rust` là où l'URL pointe. |
107+| `turbo-rust: configrepo: no repository answered: …` | Aucune adresse de clone pour cette URL n'a répondu : l'URL, le réseau, ou un dépôt privé. |
modified go.mod +1 -1
@@ -4,7 +4,7 @@ go 1.26.1
44
55 require (
66 github.com/gdamore/tcell/v2 v2.13.10
7- rickub.com/turbo-editors/turbo-core v1.0.2
7+ rickub.com/turbo-editors/turbo-core v1.0.3
88 )
99
1010 require (
@@ -4,7 +4,7 @@ go 1.26.1
4 4
5 require (5 require (
6 github.com/gdamore/tcell/v2 v2.13.106 github.com/gdamore/tcell/v2 v2.13.10
7- rickub.com/turbo-editors/turbo-core v1.0.27+ rickub.com/turbo-editors/turbo-core v1.0.3
8 )8 )
9 9
10 require (10 require (
modified go.sum +2 -2
@@ -45,5 +45,5 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
4545 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
4646 golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
4747 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
48-rickub.com/turbo-editors/turbo-core v1.0.2 h1:OA/LhR6JkvtUlp6lTgYa0wwaWou3HKXd1Glnoscyffw=
49-rickub.com/turbo-editors/turbo-core v1.0.2/go.mod h1:rmfIY5gsFEo3sC5IIJFapwsGvdKG6NjrD7ACmnNTKq8=
48+rickub.com/turbo-editors/turbo-core v1.0.3 h1:j+bqzIIBsese8iLgre9PQdbpi9YkoOMIHP6pOli5UjE=
49+rickub.com/turbo-editors/turbo-core v1.0.3/go.mod h1:rmfIY5gsFEo3sC5IIJFapwsGvdKG6NjrD7ACmnNTKq8=
@@ -45,5 +45,5 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
45 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=45 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
46 golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=46 golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
47 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=47 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
48-rickub.com/turbo-editors/turbo-core v1.0.2 h1:OA/LhR6JkvtUlp6lTgYa0wwaWou3HKXd1Glnoscyffw=48+rickub.com/turbo-editors/turbo-core v1.0.3 h1:j+bqzIIBsese8iLgre9PQdbpi9YkoOMIHP6pOli5UjE=
49-rickub.com/turbo-editors/turbo-core v1.0.2/go.mod h1:rmfIY5gsFEo3sC5IIJFapwsGvdKG6NjrD7ACmnNTKq8=49+rickub.com/turbo-editors/turbo-core v1.0.3/go.mod h1:rmfIY5gsFEo3sC5IIJFapwsGvdKG6NjrD7ACmnNTKq8=
modified main.go +38 -0
@@ -15,6 +15,7 @@
1515 // -list-themes print the available themes and exit
1616 // -no-lsp do not start a language server
1717 // -version print the version and exit
18+// -load-config url copy the .turbo-rust directory found at a repository URL into the working directory and exit
1819 package main
1920
2021 import (
@@ -23,10 +24,12 @@ import (
2324 "flag"
2425 "fmt"
2526 "os"
27+ "strings"
2628
2729 "github.com/gdamore/tcell/v2"
2830
2931 "rickub.com/turbo-editors/turbo-core/app"
32+ "rickub.com/turbo-editors/turbo-core/configrepo"
3033 "rickub.com/turbo-editors/turbo-core/profile"
3134 "rickub.com/turbo-editors/turbo-core/settings"
3235 "rickub.com/turbo-editors/turbo-core/theme"
@@ -46,6 +49,7 @@ func main() {
4649 type options struct {
4750 theme string
4851 listThemes bool
52+ loadConfig string
4953 noLSP bool
5054 version bool
5155 files []string
@@ -62,6 +66,7 @@ func parseFlags() options {
6266 flag.BoolVar(&opts.listThemes, "list-themes", false, "print the available themes and exit")
6367 flag.BoolVar(&opts.noLSP, "no-lsp", false, "do not start a language server")
6468 flag.BoolVar(&opts.version, "version", false, "print the version and exit")
69+ flag.StringVar(&opts.loadConfig, "load-config", "", "copy the .turbo-rust directory found at this repository URL into the working directory, then exit")
6570 flag.Parse()
6671
6772 opts.files = flag.Args()
@@ -82,6 +87,8 @@ func run() error {
8287 return nil
8388 case opts.listThemes:
8489 return listThemes(p)
90+ case opts.loadConfig != "":
91+ return loadConfig(p, opts.loadConfig)
8592 }
8693
8794 return edit(opts, p)
@@ -106,6 +113,37 @@ func listThemes(p profile.Profile) error {
106113 return nil
107114 }
108115
116+// loadConfig copies a shared configuration — the .turbo-rust directory at a
117+// repository URL, on rickub, GitHub, GitLab or Codeberg — into the working
118+// directory, and says what arrived. The editor is not started: this is a
119+// set-up step, and the next command is the one that opens the project.
120+//
121+// A project that already has a .turbo-rust is left alone; turbo-core refuses
122+// rather than overwrite what the project decided.
123+func loadConfig(p profile.Profile, url string) error {
124+ result, err := configrepo.Load(context.Background(), p, url, ".")
125+ if err != nil {
126+ return err
127+ }
128+ fmt.Print(describeLoad(result))
129+ return nil
130+}
131+
132+// describeLoad is what a successful -load-config prints: where the files
133+// came from, and each of them, so the reader knows what is now in force.
134+func describeLoad(result configrepo.Result) string {
135+ var out strings.Builder
136+ fmt.Fprintf(&out, "Copied %s from %s", result.Dir, result.Remote)
137+ if result.Ref != "" {
138+ fmt.Fprintf(&out, " (%s)", result.Ref)
139+ }
140+ out.WriteString(":\n")
141+ for _, file := range result.Files {
142+ fmt.Fprintf(&out, " %s\n", file)
143+ }
144+ return out.String()
145+}
146+
109147 // edit opens the terminal and runs the editor until the user leaves.
110148 func edit(opts options, p profile.Profile) error {
111149 project, projectSettings := loadProjectSettings(p)
@@ -15,6 +15,7 @@
15 // -list-themes print the available themes and exit15 // -list-themes print the available themes and exit
16 // -no-lsp do not start a language server16 // -no-lsp do not start a language server
17 // -version print the version and exit17 // -version print the version and exit
18+// -load-config url copy the .turbo-rust directory found at a repository URL into the working directory and exit
18 package main19 package main
19 20
20 import (21 import (
@@ -23,10 +24,12 @@ import (
23 "flag"24 "flag"
24 "fmt"25 "fmt"
25 "os"26 "os"
27+ "strings"
26 28
27 "github.com/gdamore/tcell/v2"29 "github.com/gdamore/tcell/v2"
28 30
29 "rickub.com/turbo-editors/turbo-core/app"31 "rickub.com/turbo-editors/turbo-core/app"
32+ "rickub.com/turbo-editors/turbo-core/configrepo"
30 "rickub.com/turbo-editors/turbo-core/profile"33 "rickub.com/turbo-editors/turbo-core/profile"
31 "rickub.com/turbo-editors/turbo-core/settings"34 "rickub.com/turbo-editors/turbo-core/settings"
32 "rickub.com/turbo-editors/turbo-core/theme"35 "rickub.com/turbo-editors/turbo-core/theme"
@@ -46,6 +49,7 @@ func main() {
46 type options struct {49 type options struct {
47 theme string50 theme string
48 listThemes bool51 listThemes bool
52+ loadConfig string
49 noLSP bool53 noLSP bool
50 version bool54 version bool
51 files []string55 files []string
@@ -62,6 +66,7 @@ func parseFlags() options {
62 flag.BoolVar(&opts.listThemes, "list-themes", false, "print the available themes and exit")66 flag.BoolVar(&opts.listThemes, "list-themes", false, "print the available themes and exit")
63 flag.BoolVar(&opts.noLSP, "no-lsp", false, "do not start a language server")67 flag.BoolVar(&opts.noLSP, "no-lsp", false, "do not start a language server")
64 flag.BoolVar(&opts.version, "version", false, "print the version and exit")68 flag.BoolVar(&opts.version, "version", false, "print the version and exit")
69+ flag.StringVar(&opts.loadConfig, "load-config", "", "copy the .turbo-rust directory found at this repository URL into the working directory, then exit")
65 flag.Parse()70 flag.Parse()
66 71
67 opts.files = flag.Args()72 opts.files = flag.Args()
@@ -82,6 +87,8 @@ func run() error {
82 return nil87 return nil
83 case opts.listThemes:88 case opts.listThemes:
84 return listThemes(p)89 return listThemes(p)
90+ case opts.loadConfig != "":
91+ return loadConfig(p, opts.loadConfig)
85 }92 }
86 93
87 return edit(opts, p)94 return edit(opts, p)
@@ -106,6 +113,37 @@ func listThemes(p profile.Profile) error {
106 return nil113 return nil
107 }114 }
108 115
116+// loadConfig copies a shared configuration — the .turbo-rust directory at a
117+// repository URL, on rickub, GitHub, GitLab or Codeberg — into the working
118+// directory, and says what arrived. The editor is not started: this is a
119+// set-up step, and the next command is the one that opens the project.
120+//
121+// A project that already has a .turbo-rust is left alone; turbo-core refuses
122+// rather than overwrite what the project decided.
123+func loadConfig(p profile.Profile, url string) error {
124+ result, err := configrepo.Load(context.Background(), p, url, ".")
125+ if err != nil {
126+ return err
127+ }
128+ fmt.Print(describeLoad(result))
129+ return nil
130+}
131+
132+// describeLoad is what a successful -load-config prints: where the files
133+// came from, and each of them, so the reader knows what is now in force.
134+func describeLoad(result configrepo.Result) string {
135+ var out strings.Builder
136+ fmt.Fprintf(&out, "Copied %s from %s", result.Dir, result.Remote)
137+ if result.Ref != "" {
138+ fmt.Fprintf(&out, " (%s)", result.Ref)
139+ }
140+ out.WriteString(":\n")
141+ for _, file := range result.Files {
142+ fmt.Fprintf(&out, " %s\n", file)
143+ }
144+ return out.String()
145+}
146+
109 // edit opens the terminal and runs the editor until the user leaves.147 // edit opens the terminal and runs the editor until the user leaves.
110 func edit(opts options, p profile.Profile) error {148 func edit(opts options, p profile.Profile) error {
111 project, projectSettings := loadProjectSettings(p)149 project, projectSettings := loadProjectSettings(p)
modified main_test.go +41 -0
@@ -1,11 +1,14 @@
11 package main
22
33 import (
4+ "errors"
45 "os"
56 "path/filepath"
7+ "strings"
68 "testing"
79
810 "rickub.com/turbo-editors/turbo-core/app"
11+ "rickub.com/turbo-editors/turbo-core/configrepo"
912 "rickub.com/turbo-editors/turbo-core/settings"
1013 "rickub.com/turbo-editors/turbo-core/theme"
1114
@@ -129,3 +132,41 @@ func TestABrokenSettingsFileDoesNotStopTheEditor(t *testing.T) {
129132 t.Errorf("loadProjectSettings(rustlang.Profile()) = %+v, want the defaults", loaded)
130133 }
131134 }
135+
136+func TestDescribeLoadNamesTheSourceAndEveryFile(t *testing.T) {
137+ got := describeLoad(configrepo.Result{
138+ Remote: "https://git.rickub.com/turbo-editors/configs.git",
139+ Ref: "main",
140+ Dir: "/work/.turbo-rust",
141+ Files: []string{"settings.toml", "tools.toml"},
142+ })
143+
144+ want := "Copied /work/.turbo-rust from https://git.rickub.com/turbo-editors/configs.git (main):\n settings.toml\n tools.toml\n"
145+ if got != want {
146+ t.Errorf("describeLoad() =\n%q\nwant\n%q", got, want)
147+ }
148+}
149+
150+func TestDescribeLoadOmitsTheRefWhenTheDefaultBranchWasUsed(t *testing.T) {
151+ got := describeLoad(configrepo.Result{Remote: "r", Dir: "d"})
152+
153+ if strings.Contains(got, "(") {
154+ t.Errorf("describeLoad() = %q, want no parenthesised ref", got)
155+ }
156+}
157+
158+func TestLoadConfigLeavesAProjectThatHasAConfigurationAlone(t *testing.T) {
159+ // Checked before anything is fetched, so this needs neither git nor a
160+ // network: the project's own .turbo-rust is a decision, not a default.
161+ project := t.TempDir()
162+ if err := os.MkdirAll(filepath.Join(project, ".turbo-rust"), 0o755); err != nil {
163+ t.Fatal(err)
164+ }
165+ t.Chdir(project)
166+
167+ err := loadConfig(rustlang.Profile(), "https://rickub.com/turbo-editors/configs/tree/main/golang-init")
168+
169+ if !errors.Is(err, configrepo.ErrExists) {
170+ t.Errorf("loadConfig() error = %v, want ErrExists", err)
171+ }
172+}
@@ -1,11 +1,14 @@
1 package main1 package main
2 2
3 import (3 import (
4+ "errors"
4 "os"5 "os"
5 "path/filepath"6 "path/filepath"
7+ "strings"
6 "testing"8 "testing"
7 9
8 "rickub.com/turbo-editors/turbo-core/app"10 "rickub.com/turbo-editors/turbo-core/app"
11+ "rickub.com/turbo-editors/turbo-core/configrepo"
9 "rickub.com/turbo-editors/turbo-core/settings"12 "rickub.com/turbo-editors/turbo-core/settings"
10 "rickub.com/turbo-editors/turbo-core/theme"13 "rickub.com/turbo-editors/turbo-core/theme"
11 14
@@ -129,3 +132,41 @@ func TestABrokenSettingsFileDoesNotStopTheEditor(t *testing.T) {
129 t.Errorf("loadProjectSettings(rustlang.Profile()) = %+v, want the defaults", loaded)132 t.Errorf("loadProjectSettings(rustlang.Profile()) = %+v, want the defaults", loaded)
130 }133 }
131 }134 }
135+
136+func TestDescribeLoadNamesTheSourceAndEveryFile(t *testing.T) {
137+ got := describeLoad(configrepo.Result{
138+ Remote: "https://git.rickub.com/turbo-editors/configs.git",
139+ Ref: "main",
140+ Dir: "/work/.turbo-rust",
141+ Files: []string{"settings.toml", "tools.toml"},
142+ })
143+
144+ want := "Copied /work/.turbo-rust from https://git.rickub.com/turbo-editors/configs.git (main):\n settings.toml\n tools.toml\n"
145+ if got != want {
146+ t.Errorf("describeLoad() =\n%q\nwant\n%q", got, want)
147+ }
148+}
149+
150+func TestDescribeLoadOmitsTheRefWhenTheDefaultBranchWasUsed(t *testing.T) {
151+ got := describeLoad(configrepo.Result{Remote: "r", Dir: "d"})
152+
153+ if strings.Contains(got, "(") {
154+ t.Errorf("describeLoad() = %q, want no parenthesised ref", got)
155+ }
156+}
157+
158+func TestLoadConfigLeavesAProjectThatHasAConfigurationAlone(t *testing.T) {
159+ // Checked before anything is fetched, so this needs neither git nor a
160+ // network: the project's own .turbo-rust is a decision, not a default.
161+ project := t.TempDir()
162+ if err := os.MkdirAll(filepath.Join(project, ".turbo-rust"), 0o755); err != nil {
163+ t.Fatal(err)
164+ }
165+ t.Chdir(project)
166+
167+ err := loadConfig(rustlang.Profile(), "https://rickub.com/turbo-editors/configs/tree/main/golang-init")
168+
169+ if !errors.Is(err, configrepo.ErrExists) {
170+ t.Errorf("loadConfig() error = %v, want ErrExists", err)
171+ }
172+}