Skip to content

Commit fd097d0

Browse files
committed
bootstrap: Add support for ./x setup vim
1 parent 87f3927 commit fd097d0

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

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

+15-14
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",
@@ -542,12 +543,12 @@ impl EditorKind {
542543
"828666b021d837a33e78d870b56d34c88a5e2c85de58b693607ec574f0c27000",
543544
"811fb3b063c739d261fd8590dd30242e117908f5a095d594fa04585daa18ec4d",
544545
],
545-
EditorKind::Emacs => vec![
546-
"51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0"
547-
],
548-
EditorKind::Helix => vec![
549-
"2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233"
550-
]
546+
EditorKind::Emacs => {
547+
vec!["51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0"]
548+
}
549+
EditorKind::Helix => {
550+
vec!["2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233"]
551+
}
551552
}
552553
}
553554

@@ -558,25 +559,24 @@ impl EditorKind {
558559
fn settings_short_path(&self) -> PathBuf {
559560
match self {
560561
EditorKind::Vscode => PathBuf::new().join(".vscode").join("settings.json"),
562+
EditorKind::Vim => PathBuf::new().join(".vim").join("coc-settings.json"),
561563
EditorKind::Emacs => PathBuf::new().join(".dir-locals.el"),
562564
EditorKind::Helix => PathBuf::new().join(".helix").join("languages.toml"),
563565
}
564566
}
565567

566568
fn settings(&self) -> &str {
567569
match self {
568-
EditorKind::Vscode => include_str!("../../../../etc/rust_analyzer_settings.json"),
570+
EditorKind::Vscode | EditorKind::Vim => {
571+
include_str!("../../../../etc/rust_analyzer_settings.json")
572+
}
569573
EditorKind::Emacs => include_str!("../../../../etc/rust_analyzer_eglot.el"),
570574
EditorKind::Helix => include_str!("../../../../etc/rust_analyzer_helix.toml"),
571575
}
572576
}
573577

574-
fn backup_extension(&self) -> &str {
575-
match self {
576-
EditorKind::Vscode => "json.bak",
577-
EditorKind::Emacs => "el.bak",
578-
EditorKind::Helix => "toml.bak",
579-
}
578+
fn backup_extension(&self) -> String {
579+
format!("{}.bak", self.settings_short_path().extension().unwrap().to_str().unwrap())
580580
}
581581
}
582582

@@ -618,6 +618,7 @@ macro_rules! impl_editor_support {
618618
}
619619

620620
impl_editor_support!(vscode, Vscode);
621+
impl_editor_support!(vim, Vim);
621622
impl_editor_support!(emacs, Emacs);
622623
impl_editor_support!(helix, Helix);
623624

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)