]> git.lizzy.rs Git - rust.git/commitdiff
tweak installation process
authorAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 18 Sep 2019 11:24:20 +0000 (14:24 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 18 Sep 2019 11:24:20 +0000 (14:24 +0300)
README.md
crates/ra_tools/src/lib.rs
crates/ra_tools/src/main.rs

index 50918ee5ebadcc24d5b7b3aa56c534bbd1047ec2..e249c6486352c654b22b3eca2c351738c08b498c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -23,9 +23,10 @@ useful IDE experience and some people use it as a daily driver.
 To build rust-analyzer, you need:
 
 * latest stable rust for language server itself
-* latest stable npm and VS Code for VS Code extension (`code` should be in path)
+* latest stable npm and VS Code for VS Code extension
 
-For setup for other editors, see [./docs/user](./docs/user).
+To quickly install rust-analyzer with VS Code extension with standard setup
+(`code` and `cargo` in `$PATH`, etc), use this:
 
 ```
 # clone the repo
@@ -37,6 +38,9 @@ $ cargo install-ra
 # alternatively, install only the server. Binary name is `ra_lsp_server`.
 $ cargo install-ra --server
 ```
+
+For non-standard setup of VS Code and other editors, see [./docs/user](./docs/user).
+
 ## Documentation
 
 If you want to **contribute** to rust-analyzer or just curious about how things work
index d47660369e85081d3fe058d16e205100521b2c34..9ba23caaa99278e8dede6dfe629131bd066da85f 100644 (file)
@@ -79,13 +79,13 @@ pub fn project_root() -> PathBuf {
     Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(2).unwrap().to_path_buf()
 }
 
-pub struct Cmd {
-    pub unix: &'static str,
-    pub windows: &'static str,
-    pub work_dir: &'static str,
+pub struct Cmd<'a> {
+    pub unix: &'a str,
+    pub windows: &'a str,
+    pub work_dir: &'a str,
 }
 
-impl Cmd {
+impl Cmd<'_> {
     pub fn run(self) -> Result<()> {
         if cfg!(windows) {
             run(self.windows, self.work_dir)
index f96f1875fa7ffddbad9b93eed9f08aaa0322d92c..65d211b44f3360105bb4436ec0df572bee0b7587 100644 (file)
@@ -167,27 +167,34 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
     }
     .run()?;
 
-    let code_in_path = Cmd {
-        unix: r"code --version",
-        windows: r"cmd.exe /c code.cmd --version",
-        work_dir: "./editors/code",
-    }
-    .run()
-    .is_ok();
-    if !code_in_path {
-        Err("Can't execute `code --version`. Perhaps it is not in $PATH?")?;
-    }
+    let code_binary = ["code", "code-insiders"].iter().find(|bin| {
+        Cmd {
+            unix: &format!("{} --version", bin),
+            windows: &format!("cmd.exe /c {}.cmd --version", bin),
+            work_dir: "./editors/code",
+        }
+        .run()
+        .is_ok()
+    });
+
+    let code_binary = match code_binary {
+        Some(it) => it,
+        None => Err("Can't execute `code --version`. Perhaps it is not in $PATH?")?,
+    };
 
     Cmd {
-        unix: r"code --install-extension ./ra-lsp-0.0.1.vsix --force",
-        windows: r"cmd.exe /c code.cmd --install-extension ./ra-lsp-0.0.1.vsix --force",
+        unix: &format!(r"{} --install-extension ./ra-lsp-0.0.1.vsix --force", code_binary),
+        windows: &format!(
+            r"cmd.exe /c {}.cmd --install-extension ./ra-lsp-0.0.1.vsix --force",
+            code_binary
+        ),
         work_dir: "./editors/code",
     }
     .run()?;
 
     let output = Cmd {
-        unix: r"code --list-extensions",
-        windows: r"cmd.exe /c code.cmd --list-extensions",
+        unix: &format!(r"{} --list-extensions", code_binary),
+        windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary),
         work_dir: ".",
     }
     .run_with_output()?;