@@ -523,48 +523,73 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
523
523
/// Handles editor-specific setup differences
524
524
#[ derive( Clone , Debug , Eq , PartialEq ) ]
525
525
enum EditorKind {
526
- Vscode ,
527
- Vim ,
528
526
Emacs ,
529
527
Helix ,
528
+ Vim ,
529
+ VsCode ,
530
+ Zed ,
530
531
}
531
532
532
533
impl EditorKind {
534
+ // Used in `./tests.rs`.
535
+ #[ allow( dead_code) ]
536
+ pub const ALL : & [ EditorKind ] = & [
537
+ EditorKind :: Emacs ,
538
+ EditorKind :: Helix ,
539
+ EditorKind :: Vim ,
540
+ EditorKind :: VsCode ,
541
+ EditorKind :: Zed ,
542
+ ] ;
543
+
533
544
fn prompt_user ( ) -> io:: Result < Option < EditorKind > > {
534
545
let prompt_str = "Available editors:
535
- 1. vscode
536
- 2. vim
537
- 3. emacs
538
- 4. helix
546
+ 1. Emacs
547
+ 2. Helix
548
+ 3. Vim
549
+ 4. VS Code
550
+ 5. Zed
539
551
540
552
Select which editor you would like to set up [default: None]: " ;
541
553
542
554
let mut input = String :: new ( ) ;
543
555
loop {
544
556
print ! ( "{}" , prompt_str) ;
545
557
io:: stdout ( ) . flush ( ) ?;
546
- input. clear ( ) ;
547
558
io:: stdin ( ) . read_line ( & mut input) ?;
548
- match input. trim ( ) . to_lowercase ( ) . as_str ( ) {
549
- "1" | "vscode" => return Ok ( Some ( EditorKind :: Vscode ) ) ,
550
- "2" | "vim" => return Ok ( Some ( EditorKind :: Vim ) ) ,
551
- "3" | "emacs" => return Ok ( Some ( EditorKind :: Emacs ) ) ,
552
- "4" | "helix" => return Ok ( Some ( EditorKind :: Helix ) ) ,
553
- "" => return Ok ( None ) ,
559
+
560
+ let mut modified_input = input. to_lowercase ( ) ;
561
+ modified_input. retain ( |ch| !ch. is_whitespace ( ) ) ;
562
+ match modified_input. as_str ( ) {
563
+ "1" | "emacs" => return Ok ( Some ( EditorKind :: Emacs ) ) ,
564
+ "2" | "helix" => return Ok ( Some ( EditorKind :: Helix ) ) ,
565
+ "3" | "vim" => return Ok ( Some ( EditorKind :: Vim ) ) ,
566
+ "4" | "vscode" => return Ok ( Some ( EditorKind :: VsCode ) ) ,
567
+ "5" | "zed" => return Ok ( Some ( EditorKind :: Zed ) ) ,
568
+ "" | "none" => return Ok ( None ) ,
554
569
_ => {
555
570
eprintln ! ( "ERROR: unrecognized option '{}'" , input. trim( ) ) ;
556
571
eprintln ! ( "NOTE: press Ctrl+C to exit" ) ;
557
572
}
558
- } ;
573
+ }
574
+
575
+ input. clear ( ) ;
559
576
}
560
577
}
561
578
562
579
/// A list of historical hashes of each LSP settings file
563
580
/// New entries should be appended whenever this is updated so we can detect
564
581
/// outdated vs. user-modified settings files.
565
- fn hashes ( & self ) -> Vec < & str > {
582
+ fn hashes ( & self ) -> & ' static [ & ' static str ] {
566
583
match self {
567
- EditorKind :: Vscode | EditorKind :: Vim => vec ! [
584
+ EditorKind :: Emacs => & [
585
+ "51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0" ,
586
+ "d29af4d949bbe2371eac928a3c31cf9496b1701aa1c45f11cd6c759865ad5c45" ,
587
+ ] ,
588
+ EditorKind :: Helix => & [
589
+ "2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233" ,
590
+ "6736d61409fbebba0933afd2e4c44ff2f97c1cb36cf0299a7f4a7819b8775040" ,
591
+ ] ,
592
+ EditorKind :: Vim | EditorKind :: VsCode => & [
568
593
"ea67e259dedf60d4429b6c349a564ffcd1563cf41c920a856d1f5b16b4701ac8" ,
569
594
"56e7bf011c71c5d81e0bf42e84938111847a810eee69d906bba494ea90b51922" ,
570
595
"af1b5efe196aed007577899db9dae15d6dbc923d6fa42fa0934e68617ba9bbe0" ,
@@ -576,12 +601,8 @@ Select which editor you would like to set up [default: None]: ";
576
601
"4eecb58a2168b252077369da446c30ed0e658301efe69691979d1ef0443928f4" ,
577
602
"c394386e6133bbf29ffd32c8af0bb3d4aac354cba9ee051f29612aa9350f8f8d" ,
578
603
] ,
579
- EditorKind :: Emacs => vec ! [
580
- "51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0" ,
581
- "d29af4d949bbe2371eac928a3c31cf9496b1701aa1c45f11cd6c759865ad5c45" ,
582
- ] ,
583
- EditorKind :: Helix => {
584
- vec ! [ "2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233" ]
604
+ EditorKind :: Zed => {
605
+ & [ "bbce727c269d1bd0c98afef4d612eb4ce27aea3c3a8968c5f10b31affbc40b6c" ]
585
606
}
586
607
}
587
608
}
@@ -592,29 +613,31 @@ Select which editor you would like to set up [default: None]: ";
592
613
593
614
fn settings_short_path ( & self ) -> PathBuf {
594
615
self . settings_folder ( ) . join ( match self {
595
- EditorKind :: Vscode => "settings.json" ,
596
- EditorKind :: Vim => "coc-settings.json" ,
597
616
EditorKind :: Emacs => ".dir-locals.el" ,
598
617
EditorKind :: Helix => "languages.toml" ,
618
+ EditorKind :: Vim => "coc-settings.json" ,
619
+ EditorKind :: VsCode | EditorKind :: Zed => "settings.json" ,
599
620
} )
600
621
}
601
622
602
623
fn settings_folder ( & self ) -> PathBuf {
603
624
match self {
604
- EditorKind :: Vscode => PathBuf :: from ( ".vscode" ) ,
605
- EditorKind :: Vim => PathBuf :: from ( ".vim" ) ,
606
625
EditorKind :: Emacs => PathBuf :: new ( ) ,
607
626
EditorKind :: Helix => PathBuf :: from ( ".helix" ) ,
627
+ EditorKind :: Vim => PathBuf :: from ( ".vim" ) ,
628
+ EditorKind :: VsCode => PathBuf :: from ( ".vscode" ) ,
629
+ EditorKind :: Zed => PathBuf :: from ( ".zed" ) ,
608
630
}
609
631
}
610
632
611
- fn settings_template ( & self ) -> & str {
633
+ fn settings_template ( & self ) -> & ' static str {
612
634
match self {
613
- EditorKind :: Vscode | EditorKind :: Vim => {
614
- include_str ! ( "../../../../etc/rust_analyzer_settings.json" )
615
- }
616
635
EditorKind :: Emacs => include_str ! ( "../../../../etc/rust_analyzer_eglot.el" ) ,
617
636
EditorKind :: Helix => include_str ! ( "../../../../etc/rust_analyzer_helix.toml" ) ,
637
+ EditorKind :: Vim | EditorKind :: VsCode => {
638
+ include_str ! ( "../../../../etc/rust_analyzer_settings.json" )
639
+ }
640
+ EditorKind :: Zed => include_str ! ( "../../../../etc/rust_analyzer_zed.json" ) ,
618
641
}
619
642
}
620
643
0 commit comments