Skip to content

Commit 9b24fae

Browse files
committed
bootstrap: Add support for ./x setup vim
1 parent dfc7e39 commit 9b24fae

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

src/bootstrap/src/core/build_steps/setup.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
522522
#[derive(Clone, Debug, Eq, PartialEq)]
523523
enum EditorKind {
524524
Vscode,
525+
Vim,
525526
Emacs,
526527
Helix,
527528
}
@@ -532,7 +533,7 @@ impl EditorKind {
532533
/// outdated vs. user-modified settings files.
533534
fn hashes(&self) -> Vec<&str> {
534535
match self {
535-
EditorKind::Vscode => vec![
536+
EditorKind::Vscode | EditorKind::Vim => vec![
536537
"ea67e259dedf60d4429b6c349a564ffcd1563cf41c920a856d1f5b16b4701ac8",
537538
"56e7bf011c71c5d81e0bf42e84938111847a810eee69d906bba494ea90b51922",
538539
"af1b5efe196aed007577899db9dae15d6dbc923d6fa42fa0934e68617ba9bbe0",
@@ -546,9 +547,9 @@ impl EditorKind {
546547
"51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0",
547548
"d29af4d949bbe2371eac928a3c31cf9496b1701aa1c45f11cd6c759865ad5c45",
548549
],
549-
EditorKind::Helix => vec![
550-
"2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233"
551-
]
550+
EditorKind::Helix => {
551+
vec!["2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233"]
552+
}
552553
}
553554
}
554555

@@ -559,6 +560,7 @@ impl EditorKind {
559560
fn settings_short_path(&self) -> PathBuf {
560561
self.settings_folder().join(match self {
561562
EditorKind::Vscode => "settings.json",
563+
EditorKind::Vim => "coc-settings.json",
562564
EditorKind::Emacs => ".dir-locals.el",
563565
EditorKind::Helix => "languages.toml",
564566
})
@@ -567,25 +569,24 @@ impl EditorKind {
567569
fn settings_folder(&self) -> PathBuf {
568570
match self {
569571
EditorKind::Vscode => PathBuf::new().join(".vscode"),
572+
EditorKind::Vim => PathBuf::new().join(".vim"),
570573
EditorKind::Emacs => PathBuf::new(),
571574
EditorKind::Helix => PathBuf::new().join(".helix"),
572575
}
573576
}
574577

575578
fn settings_template(&self) -> &str {
576579
match self {
577-
EditorKind::Vscode => include_str!("../../../../etc/rust_analyzer_settings.json"),
580+
EditorKind::Vscode | EditorKind::Vim => {
581+
include_str!("../../../../etc/rust_analyzer_settings.json")
582+
}
578583
EditorKind::Emacs => include_str!("../../../../etc/rust_analyzer_eglot.el"),
579584
EditorKind::Helix => include_str!("../../../../etc/rust_analyzer_helix.toml"),
580585
}
581586
}
582587

583-
fn backup_extension(&self) -> &str {
584-
match self {
585-
EditorKind::Vscode => "json.bak",
586-
EditorKind::Emacs => "el.bak",
587-
EditorKind::Helix => "toml.bak",
588-
}
588+
fn backup_extension(&self) -> String {
589+
format!("{}.bak", self.settings_short_path().extension().unwrap().to_str().unwrap())
589590
}
590591
}
591592

@@ -627,6 +628,7 @@ macro_rules! impl_editor_support {
627628
}
628629

629630
impl_editor_support!(vscode, Vscode);
631+
impl_editor_support!(vim, Vim);
630632
impl_editor_support!(emacs, Emacs);
631633
impl_editor_support!(helix, Helix);
632634

src/bootstrap/src/core/builder.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,15 @@ impl<'a> Builder<'a> {
10011001
run::GenerateCompletions,
10021002
),
10031003
Kind::Setup => {
1004-
describe!(setup::Profile, setup::Hook, setup::Link, setup::Vscode, setup::Emacs, setup::Helix)
1004+
describe!(
1005+
setup::Profile,
1006+
setup::Hook,
1007+
setup::Link,
1008+
setup::Vscode,
1009+
setup::Emacs,
1010+
setup::Helix,
1011+
setup::Vim
1012+
)
10051013
}
10061014
Kind::Clean => describe!(clean::CleanAll, clean::Rustc, clean::Std),
10071015
Kind::Vendor => describe!(vendor::Vendor),

src/bootstrap/src/core/config/flags.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,14 @@ Arguments:
450450
To only set up the git hook, VS Code config or toolchain link, you may use
451451
./x.py setup hook
452452
./x.py setup vscode
453+
./x.py setup vim
453454
./x.py setup emacs
454455
./x.py setup helix
455456
./x.py setup link", Profile::all_for_help(" ").trim_end()))]
456457
Setup {
457458
/// Either the profile for `config.toml` or another setup action.
458459
/// May be omitted to set up interactively
459-
#[arg(value_name = "<PROFILE>|hook|vscode|emacs|helix|link")]
460+
#[arg(value_name = "<PROFILE>|hook|vscode|vim|emacs|helix|link")]
460461
profile: Option<PathBuf>,
461462
},
462463
/// Suggest a subset of tests to run, based on modified files

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
270270
severity: ChangeSeverity::Info,
271271
summary: "If `llvm.download-ci-llvm` is not defined, it defaults to `true`.",
272272
},
273+
ChangeInfo {
274+
change_id: 131075,
275+
severity: ChangeSeverity::Info,
276+
summary: "New options for ./x setup added - ./x setup [vim|emacs|helix]",
277+
},
273278
];

src/etc/completions/x.py.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ _x.py() {
27412741
return 0
27422742
;;
27432743
x.py__setup)
2744-
opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [<PROFILE>|hook|vscode|emacs|helix|link] [PATHS]... [ARGS]..."
2744+
opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --error-format --json-output --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --help [<PROFILE>|hook|vscode|vim|emacs|helix|link] [PATHS]... [ARGS]..."
27452745
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
27462746
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
27472747
return 0

0 commit comments

Comments
 (0)