aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/rust_analyzer
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-09-01 10:29:23 +0200
committerGitHub <noreply@github.com>2021-09-01 10:29:23 +0200
commitbfbf5fbd39fa75847bf23da2c46d12fe2728fb78 (patch)
treef05d2f041f895ff639684c10f57d19f1d4a433e0 /lua/nvim-lsp-installer/servers/rust_analyzer
parentREADME: simplify example a bit, add clarifying comment (diff)
downloadmason-bfbf5fbd39fa75847bf23da2c46d12fe2728fb78.tar
mason-bfbf5fbd39fa75847bf23da2c46d12fe2728fb78.tar.gz
mason-bfbf5fbd39fa75847bf23da2c46d12fe2728fb78.tar.bz2
mason-bfbf5fbd39fa75847bf23da2c46d12fe2728fb78.tar.lz
mason-bfbf5fbd39fa75847bf23da2c46d12fe2728fb78.tar.xz
mason-bfbf5fbd39fa75847bf23da2c46d12fe2728fb78.tar.zst
mason-bfbf5fbd39fa75847bf23da2c46d12fe2728fb78.zip
add Windows support (#70)
Diffstat (limited to 'lua/nvim-lsp-installer/servers/rust_analyzer')
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs41
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/init.lua6
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/install.mjs42
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/install.win.mjs9
4 files changed, 58 insertions, 40 deletions
diff --git a/lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs b/lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs
new file mode 100644
index 00000000..0f54a71e
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs
@@ -0,0 +1,41 @@
+export const VERSION = "2021-06-28";
+
+const exitNotSupported = () => {
+ console.error(chalk.red(`${os.platform()} ${os.arch()} is currently not supported.`));
+ process.exit(1);
+};
+
+export const getDownloadUrl = () => {
+ const target = (() => {
+ switch (os.platform()) {
+ case "win32": {
+ switch (os.arch()) {
+ case "arm64":
+ return "rust-analyzer-aarch64-pc-windows-msvc.gz";
+ case "x64":
+ return "rust-analyzer-x86_64-pc-windows-msvc.gz";
+ default:
+ return exitNotSupported();
+ }
+ }
+ case "darwin":
+ switch (os.arch()) {
+ case "arm64":
+ return "rust-analyzer-aarch64-apple-darwin.gz";
+ case "x64":
+ return "rust-analyzer-x86_64-apple-darwin.gz";
+ default:
+ return exitNotSupported();
+ }
+ default:
+ switch (os.arch()) {
+ case "arm64":
+ return "rust-analyzer-aarch64-unknown-linux-gnu.gz";
+ default:
+ return "rust-analyzer-x86_64-unknown-linux-gnu.gz";
+ }
+ }
+ })();
+
+ return `https://github.com/rust-analyzer/rust-analyzer/releases/download/${VERSION}/${target}`;
+};
diff --git a/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua b/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua
index 6502ee07..58cb53e2 100644
--- a/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua
+++ b/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua
@@ -1,4 +1,5 @@
local server = require "nvim-lsp-installer.server"
+local installers = require "nvim-lsp-installer.installers"
local path = require "nvim-lsp-installer.path"
local zx = require "nvim-lsp-installer.installers.zx"
@@ -7,7 +8,10 @@ local root_dir = server.get_server_root_path "rust"
return server.Server:new {
name = "rust_analyzer",
root_dir = root_dir,
- installer = zx.file "./install.mjs",
+ installer = installers.when {
+ unix = zx.file "./install.mjs",
+ win = zx.file "./install.win.mjs",
+ },
default_options = {
cmd = { path.concat { root_dir, "rust-analyzer" } },
},
diff --git a/lua/nvim-lsp-installer/servers/rust_analyzer/install.mjs b/lua/nvim-lsp-installer/servers/rust_analyzer/install.mjs
index 7e976850..4d3fec85 100644
--- a/lua/nvim-lsp-installer/servers/rust_analyzer/install.mjs
+++ b/lua/nvim-lsp-installer/servers/rust_analyzer/install.mjs
@@ -1,41 +1,5 @@
-const VERSION = "2021-06-28";
+import { getDownloadUrl } from "./common.mjs";
-const exitNotSupported = () => {
- console.error(
- chalk.red(`${os.platform()} ${os.arch()} is currently not supported.`)
- );
- process.exit(1);
-};
-
-const target = (() => {
- switch (os.platform()) {
- case "win32": {
- exitNotSupported();
- break;
- }
- case "darwin":
- switch (os.arch()) {
- case "arm64":
- return "rust-analyzer-aarch64-apple-darwin.gz";
- case "x64":
- return "rust-analyzer-x86_64-apple-darwin.gz";
- default: {
- exitNotSupported();
- break;
- }
- }
- default:
- switch (os.arch()) {
- case "arm64":
- return "rust-analyzer-aarch64-unknown-linux-gnu.gz";
- default:
- return "rust-analyzer-x86_64-unknown-linux-gnu.gz";
- }
- }
-})();
-
-const downloadUrl = `https://github.com/rust-analyzer/rust-analyzer/releases/download/${VERSION}/${target}`;
-
-await $`wget -O rust-analyzer.gz ${downloadUrl}`;
-await $`gunzip rust-analyzer.gz`;
+await $`wget -O rust-analyzer.gz ${getDownloadUrl()}`;
+await $`gzip -fd rust-analyzer.gz`;
await $`chmod +x rust-analyzer`;
diff --git a/lua/nvim-lsp-installer/servers/rust_analyzer/install.win.mjs b/lua/nvim-lsp-installer/servers/rust_analyzer/install.win.mjs
new file mode 100644
index 00000000..22ad75f7
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/rust_analyzer/install.win.mjs
@@ -0,0 +1,9 @@
+import { getDownloadUrl } from "./common.mjs";
+
+// TODO: can this be... less hacky?
+$.shell = "powershell.exe";
+$.prefix = "";
+$.quote = (a) => a;
+
+await $`wget -O rust-analyzer.exe.gz ${getDownloadUrl()}`;
+await $`gzip -fd rust-analyzer.exe.gz`;