Skip to content

Commit

Permalink
bootstrap: Add support for ./x setup vim
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkajetanp committed Sep 30, 2024
1 parent 8639008 commit 52049f8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
29 changes: 15 additions & 14 deletions src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
#[derive(Clone, Debug, Eq, PartialEq)]
enum EditorKind {
Vscode,
Vim,
Emacs,
Helix,
}
Expand All @@ -532,7 +533,7 @@ impl EditorKind {
/// outdated vs. user-modified settings files.
fn hashes(&self) -> Vec<&str> {
match self {
EditorKind::Vscode => vec![
EditorKind::Vscode | EditorKind::Vim => vec![
"ea67e259dedf60d4429b6c349a564ffcd1563cf41c920a856d1f5b16b4701ac8",
"56e7bf011c71c5d81e0bf42e84938111847a810eee69d906bba494ea90b51922",
"af1b5efe196aed007577899db9dae15d6dbc923d6fa42fa0934e68617ba9bbe0",
Expand All @@ -542,12 +543,12 @@ impl EditorKind {
"828666b021d837a33e78d870b56d34c88a5e2c85de58b693607ec574f0c27000",
"811fb3b063c739d261fd8590dd30242e117908f5a095d594fa04585daa18ec4d",
],
EditorKind::Emacs => vec![
"51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0"
],
EditorKind::Helix => vec![
"2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233"
]
EditorKind::Emacs => {
vec!["51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0"]
}
EditorKind::Helix => {
vec!["2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233"]
}
}
}

Expand All @@ -558,25 +559,24 @@ impl EditorKind {
fn settings_short_path(&self) -> PathBuf {
match self {
EditorKind::Vscode => PathBuf::new().join(".vscode").join("settings.json"),
EditorKind::Vim => PathBuf::new().join(".vim").join("coc-settings.json"),
EditorKind::Emacs => PathBuf::new().join(".dir-locals.el"),
EditorKind::Helix => PathBuf::new().join(".helix").join("languages.toml"),
}
}

fn settings(&self) -> &str {
match self {
EditorKind::Vscode => include_str!("../../../../etc/rust_analyzer_settings.json"),
EditorKind::Vscode | EditorKind::Vim => {
include_str!("../../../../etc/rust_analyzer_settings.json")
}
EditorKind::Emacs => include_str!("../../../../etc/rust_analyzer_eglot.el"),
EditorKind::Helix => include_str!("../../../../etc/rust_analyzer_helix.toml"),
}
}

fn backup_extension(&self) -> &str {
match self {
EditorKind::Vscode => "json.bak",
EditorKind::Emacs => "el.bak",
EditorKind::Helix => "toml.bak",
}
fn backup_extension(&self) -> String {
format!("{}.bak", self.settings_short_path().extension().unwrap().to_str().unwrap())
}
}

Expand Down Expand Up @@ -618,6 +618,7 @@ macro_rules! impl_editor_support {
}

impl_editor_support!(vscode, Vscode);
impl_editor_support!(vim, Vim);
impl_editor_support!(emacs, Emacs);
impl_editor_support!(helix, Helix);

Expand Down
10 changes: 9 additions & 1 deletion src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,15 @@ impl<'a> Builder<'a> {
run::GenerateCompletions,
),
Kind::Setup => {
describe!(setup::Profile, setup::Hook, setup::Link, setup::Vscode, setup::Emacs, setup::Helix)
describe!(
setup::Profile,
setup::Hook,
setup::Link,
setup::Vscode,
setup::Emacs,
setup::Helix,
setup::Vim
)
}
Kind::Clean => describe!(clean::CleanAll, clean::Rustc, clean::Std),
Kind::Vendor => describe!(vendor::Vendor),
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/src/core/config/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,14 @@ Arguments:
To only set up the git hook, VS Code config or toolchain link, you may use
./x.py setup hook
./x.py setup vscode
./x.py setup vim
./x.py setup emacs
./x.py setup helix
./x.py setup link", Profile::all_for_help(" ").trim_end()))]
Setup {
/// Either the profile for `config.toml` or another setup action.
/// May be omitted to set up interactively
#[arg(value_name = "<PROFILE>|hook|vscode|emacs|helix|link")]
#[arg(value_name = "<PROFILE>|hook|vscode|vim|emacs|helix|link")]
profile: Option<PathBuf>,
},
/// Suggest a subset of tests to run, based on modified files
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Info,
summary: "If `llvm.download-ci-llvm` is not defined, it defaults to `true`.",
},
ChangeInfo {
change_id: 131075,
severity: ChangeSeverity::Info,
summary: "New options for ./x setup added - ./x setup [vim|emacs|helix]",
},
];
2 changes: 1 addition & 1 deletion src/etc/completions/x.py.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,7 @@ _x.py() {
return 0
;;
x.py__setup)
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]..."
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]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down

0 comments on commit 52049f8

Please sign in to comment.