aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md8
-rw-r--r--crates/ra_tools/src/lib.rs10
-rw-r--r--crates/ra_tools/src/main.rs35
3 files changed, 32 insertions, 21 deletions
diff --git a/README.md b/README.md
index 50918ee5e..e249c6486 100644
--- a/README.md
+++ b/README.md
@@ -23,9 +23,10 @@ useful IDE experience and some people use it as a daily driver.
23To build rust-analyzer, you need: 23To build rust-analyzer, you need:
24 24
25* latest stable rust for language server itself 25* latest stable rust for language server itself
26* latest stable npm and VS Code for VS Code extension (`code` should be in path) 26* latest stable npm and VS Code for VS Code extension
27 27
28For setup for other editors, see [./docs/user](./docs/user). 28To quickly install rust-analyzer with VS Code extension with standard setup
29(`code` and `cargo` in `$PATH`, etc), use this:
29 30
30``` 31```
31# clone the repo 32# clone the repo
@@ -37,6 +38,9 @@ $ cargo install-ra
37# alternatively, install only the server. Binary name is `ra_lsp_server`. 38# alternatively, install only the server. Binary name is `ra_lsp_server`.
38$ cargo install-ra --server 39$ cargo install-ra --server
39``` 40```
41
42For non-standard setup of VS Code and other editors, see [./docs/user](./docs/user).
43
40## Documentation 44## Documentation
41 45
42If you want to **contribute** to rust-analyzer or just curious about how things work 46If you want to **contribute** to rust-analyzer or just curious about how things work
diff --git a/crates/ra_tools/src/lib.rs b/crates/ra_tools/src/lib.rs
index d47660369..9ba23caaa 100644
--- a/crates/ra_tools/src/lib.rs
+++ b/crates/ra_tools/src/lib.rs
@@ -79,13 +79,13 @@ pub fn project_root() -> PathBuf {
79 Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(2).unwrap().to_path_buf() 79 Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(2).unwrap().to_path_buf()
80} 80}
81 81
82pub struct Cmd { 82pub struct Cmd<'a> {
83 pub unix: &'static str, 83 pub unix: &'a str,
84 pub windows: &'static str, 84 pub windows: &'a str,
85 pub work_dir: &'static str, 85 pub work_dir: &'a str,
86} 86}
87 87
88impl Cmd { 88impl Cmd<'_> {
89 pub fn run(self) -> Result<()> { 89 pub fn run(self) -> Result<()> {
90 if cfg!(windows) { 90 if cfg!(windows) {
91 run(self.windows, self.work_dir) 91 run(self.windows, self.work_dir)
diff --git a/crates/ra_tools/src/main.rs b/crates/ra_tools/src/main.rs
index f96f1875f..65d211b44 100644
--- a/crates/ra_tools/src/main.rs
+++ b/crates/ra_tools/src/main.rs
@@ -167,27 +167,34 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
167 } 167 }
168 .run()?; 168 .run()?;
169 169
170 let code_in_path = Cmd { 170 let code_binary = ["code", "code-insiders"].iter().find(|bin| {
171 unix: r"code --version", 171 Cmd {
172 windows: r"cmd.exe /c code.cmd --version", 172 unix: &format!("{} --version", bin),
173 work_dir: "./editors/code", 173 windows: &format!("cmd.exe /c {}.cmd --version", bin),
174 } 174 work_dir: "./editors/code",
175 .run() 175 }
176 .is_ok(); 176 .run()
177 if !code_in_path { 177 .is_ok()
178 Err("Can't execute `code --version`. Perhaps it is not in $PATH?")?; 178 });
179 } 179
180 let code_binary = match code_binary {
181 Some(it) => it,
182 None => Err("Can't execute `code --version`. Perhaps it is not in $PATH?")?,
183 };
180 184
181 Cmd { 185 Cmd {
182 unix: r"code --install-extension ./ra-lsp-0.0.1.vsix --force", 186 unix: &format!(r"{} --install-extension ./ra-lsp-0.0.1.vsix --force", code_binary),
183 windows: r"cmd.exe /c code.cmd --install-extension ./ra-lsp-0.0.1.vsix --force", 187 windows: &format!(
188 r"cmd.exe /c {}.cmd --install-extension ./ra-lsp-0.0.1.vsix --force",
189 code_binary
190 ),
184 work_dir: "./editors/code", 191 work_dir: "./editors/code",
185 } 192 }
186 .run()?; 193 .run()?;
187 194
188 let output = Cmd { 195 let output = Cmd {
189 unix: r"code --list-extensions", 196 unix: &format!(r"{} --list-extensions", code_binary),
190 windows: r"cmd.exe /c code.cmd --list-extensions", 197 windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary),
191 work_dir: ".", 198 work_dir: ".",
192 } 199 }
193 .run_with_output()?; 200 .run_with_output()?;