@@ -523,48 +523,73 @@ undesirable, simply delete the `pre-push` file from .git/hooks."
523523/// Handles editor-specific setup differences
524524#[ derive( Clone , Debug , Eq , PartialEq ) ]
525525enum EditorKind {
526- Vscode ,
527- Vim ,
528526 Emacs ,
529527 Helix ,
528+ Vim ,
529+ VsCode ,
530+ Zed ,
530531}
531532
532533impl 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+
533544 fn prompt_user ( ) -> io:: Result < Option < EditorKind > > {
534545 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
539551
540552Select which editor you would like to set up [default: None]: " ;
541553
542554 let mut input = String :: new ( ) ;
543555 loop {
544556 print ! ( "{}" , prompt_str) ;
545557 io:: stdout ( ) . flush ( ) ?;
546- input. clear ( ) ;
547558 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 ) ,
554569 _ => {
555570 eprintln ! ( "ERROR: unrecognized option '{}'" , input. trim( ) ) ;
556571 eprintln ! ( "NOTE: press Ctrl+C to exit" ) ;
557572 }
558- } ;
573+ }
574+
575+ input. clear ( ) ;
559576 }
560577 }
561578
562579 /// A list of historical hashes of each LSP settings file
563580 /// New entries should be appended whenever this is updated so we can detect
564581 /// outdated vs. user-modified settings files.
565- fn hashes ( & self ) -> Vec < & str > {
582+ fn hashes ( & self ) -> & ' static [ & ' static str ] {
566583 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 => & [
568593 "ea67e259dedf60d4429b6c349a564ffcd1563cf41c920a856d1f5b16b4701ac8" ,
569594 "56e7bf011c71c5d81e0bf42e84938111847a810eee69d906bba494ea90b51922" ,
570595 "af1b5efe196aed007577899db9dae15d6dbc923d6fa42fa0934e68617ba9bbe0" ,
@@ -576,12 +601,8 @@ Select which editor you would like to set up [default: None]: ";
576601 "4eecb58a2168b252077369da446c30ed0e658301efe69691979d1ef0443928f4" ,
577602 "c394386e6133bbf29ffd32c8af0bb3d4aac354cba9ee051f29612aa9350f8f8d" ,
578603 ] ,
579- EditorKind :: Emacs => vec ! [
580- "51068d4747a13732440d1a8b8f432603badb1864fa431d83d0fd4f8fa57039e0" ,
581- "d29af4d949bbe2371eac928a3c31cf9496b1701aa1c45f11cd6c759865ad5c45" ,
582- ] ,
583- EditorKind :: Helix => {
584- vec ! [ "2d3069b8cf1b977e5d4023965eb6199597755e6c96c185ed5f2854f98b83d233" ]
604+ EditorKind :: Zed => {
605+ & [ "bbce727c269d1bd0c98afef4d612eb4ce27aea3c3a8968c5f10b31affbc40b6c" ]
585606 }
586607 }
587608 }
@@ -592,29 +613,31 @@ Select which editor you would like to set up [default: None]: ";
592613
593614 fn settings_short_path ( & self ) -> PathBuf {
594615 self . settings_folder ( ) . join ( match self {
595- EditorKind :: Vscode => "settings.json" ,
596- EditorKind :: Vim => "coc-settings.json" ,
597616 EditorKind :: Emacs => ".dir-locals.el" ,
598617 EditorKind :: Helix => "languages.toml" ,
618+ EditorKind :: Vim => "coc-settings.json" ,
619+ EditorKind :: VsCode | EditorKind :: Zed => "settings.json" ,
599620 } )
600621 }
601622
602623 fn settings_folder ( & self ) -> PathBuf {
603624 match self {
604- EditorKind :: Vscode => PathBuf :: from ( ".vscode" ) ,
605- EditorKind :: Vim => PathBuf :: from ( ".vim" ) ,
606625 EditorKind :: Emacs => PathBuf :: new ( ) ,
607626 EditorKind :: Helix => PathBuf :: from ( ".helix" ) ,
627+ EditorKind :: Vim => PathBuf :: from ( ".vim" ) ,
628+ EditorKind :: VsCode => PathBuf :: from ( ".vscode" ) ,
629+ EditorKind :: Zed => PathBuf :: from ( ".zed" ) ,
608630 }
609631 }
610632
611- fn settings_template ( & self ) -> & str {
633+ fn settings_template ( & self ) -> & ' static str {
612634 match self {
613- EditorKind :: Vscode | EditorKind :: Vim => {
614- include_str ! ( "../../../../etc/rust_analyzer_settings.json" )
615- }
616635 EditorKind :: Emacs => include_str ! ( "../../../../etc/rust_analyzer_eglot.el" ) ,
617636 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" ) ,
618641 }
619642 }
620643
0 commit comments