aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer/data.lua18
-rw-r--r--lua/nvim-lsp-installer/installers/gem.lua34
-rw-r--r--lua/nvim-lsp-installer/installers/init.lua58
-rw-r--r--lua/nvim-lsp-installer/installers/npm.lua24
-rw-r--r--lua/nvim-lsp-installer/installers/shell.lua15
-rw-r--r--lua/nvim-lsp-installer/installers/std.lua142
-rw-r--r--lua/nvim-lsp-installer/installers/zx.lua6
-rw-r--r--lua/nvim-lsp-installer/platform.lua12
-rw-r--r--lua/nvim-lsp-installer/process.lua4
-rw-r--r--lua/nvim-lsp-installer/server.lua43
-rw-r--r--lua/nvim-lsp-installer/servers/ansiblels/init.lua16
-rw-r--r--lua/nvim-lsp-installer/servers/clangd/init.lua21
-rw-r--r--lua/nvim-lsp-installer/servers/clangd/install.mjs18
-rw-r--r--lua/nvim-lsp-installer/servers/clojure_lsp/init.lua18
-rw-r--r--lua/nvim-lsp-installer/servers/clojure_lsp/install.mjs17
-rw-r--r--lua/nvim-lsp-installer/servers/elixirls/init.lua13
-rw-r--r--lua/nvim-lsp-installer/servers/groovyls/init.lua17
-rw-r--r--lua/nvim-lsp-installer/servers/hls/init.lua28
-rw-r--r--lua/nvim-lsp-installer/servers/hls/install.mjs26
-rw-r--r--lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua12
-rw-r--r--lua/nvim-lsp-installer/servers/omnisharp/common.mjs35
-rw-r--r--lua/nvim-lsp-installer/servers/omnisharp/init.lua27
-rw-r--r--lua/nvim-lsp-installer/servers/omnisharp/install.mjs6
-rw-r--r--lua/nvim-lsp-installer/servers/omnisharp/install.win.mjs10
-rw-r--r--lua/nvim-lsp-installer/servers/rescriptls/init.lua15
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs41
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/init.lua40
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/install.mjs5
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/install.win.mjs9
-rw-r--r--lua/nvim-lsp-installer/servers/solargraph/init.lua18
-rw-r--r--lua/nvim-lsp-installer/servers/solargraph/install.mjs14
-rw-r--r--lua/nvim-lsp-installer/servers/sumneko_lua/init.lua35
-rw-r--r--lua/nvim-lsp-installer/servers/sumneko_lua/install.mjs17
-rw-r--r--lua/nvim-lsp-installer/servers/tailwindcss/init.lua16
-rw-r--r--lua/nvim-lsp-installer/servers/tailwindcss/install.mjs7
-rw-r--r--lua/nvim-lsp-installer/servers/terraformls/init.lua33
-rw-r--r--lua/nvim-lsp-installer/servers/terraformls/install.mjs35
-rw-r--r--lua/nvim-lsp-installer/servers/texlab/init.lua25
-rw-r--r--lua/nvim-lsp-installer/servers/texlab/install.mjs16
39 files changed, 504 insertions, 442 deletions
diff --git a/lua/nvim-lsp-installer/data.lua b/lua/nvim-lsp-installer/data.lua
index 3d6bf196..53bca81e 100644
--- a/lua/nvim-lsp-installer/data.lua
+++ b/lua/nvim-lsp-installer/data.lua
@@ -33,4 +33,22 @@ function Data.list_map(fn, list)
return result
end
+function Data.tbl_pack(...)
+ return { n = select("#", ...), ... }
+end
+
+function Data.when(condition, value)
+ return condition and value or nil
+end
+
+function Data.coalesce(...)
+ local args = Data.tbl_pack(...)
+ for i = 1, args.n do
+ local variable = args[i]
+ if variable ~= nil then
+ return variable
+ end
+ end
+end
+
return Data
diff --git a/lua/nvim-lsp-installer/installers/gem.lua b/lua/nvim-lsp-installer/installers/gem.lua
new file mode 100644
index 00000000..6f66c7eb
--- /dev/null
+++ b/lua/nvim-lsp-installer/installers/gem.lua
@@ -0,0 +1,34 @@
+local path = require "nvim-lsp-installer.path"
+local process = require "nvim-lsp-installer.process"
+
+local M = {}
+
+function M.packages(packages)
+ return function(server, callback, context)
+ process.spawn("gem", {
+ args = {
+ "install",
+ "--no-user-install",
+ "--install-dir=.",
+ "--bindir=bin",
+ "--no-document",
+ table.concat(packages, " "),
+ },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end
+end
+
+function M.executable(root_dir, executable)
+ return path.concat { root_dir, "bin", executable }
+end
+
+function M.env(root_dir)
+ return {
+ GEM_HOME = root_dir,
+ GEM_PATH = root_dir,
+ }
+end
+
+return M
diff --git a/lua/nvim-lsp-installer/installers/init.lua b/lua/nvim-lsp-installer/installers/init.lua
index 98bb78bc..7698e900 100644
--- a/lua/nvim-lsp-installer/installers/init.lua
+++ b/lua/nvim-lsp-installer/installers/init.lua
@@ -3,9 +3,9 @@ local Data = require "nvim-lsp-installer.data"
local M = {}
-function M.join(installers)
+function M.pipe(installers)
if #installers == 0 then
- error "No installers to join."
+ error "No installers to pipe."
end
return function(server, callback, context)
@@ -30,27 +30,49 @@ end
-- much fp, very wow
function M.compose(installers)
- return M.join(Data.list_reverse(installers))
+ return M.pipe(Data.list_reverse(installers))
end
+function M.always_succeed(installer)
+ return function(server, callback, context)
+ installer(server, function()
+ callback(true)
+ end, context)
+ end
+end
+
+local function get_by_platform(platform_table)
+ if platform.is_unix then
+ return platform_table.unix
+ elseif platform.is_win then
+ return platform_table.win
+ else
+ return nil
+ end
+end
+
+-- non-exhaustive
+function M.on(platform_table)
+ return function(server, callback, context)
+ local installer = get_by_platform(platform_table)
+ if installer then
+ installer(server, callback, context)
+ else
+ callback(true)
+ end
+ end
+end
+
+-- exhaustive
function M.when(platform_table)
return function(server, callback, context)
- if platform.is_unix then
- if platform_table.unix then
- platform_table.unix(server, callback, context)
- else
- context.stdio_sink.stderr(("Unix is not yet supported for server %q."):format(server.name))
- callback(false)
- end
- elseif platform.is_win then
- if platform_table.win then
- platform_table.win(server, callback, context)
- else
- context.stdio_sink.stderr(("Windows is not yet supported for server %q."):format(server.name))
- callback(false)
- end
+ local installer = get_by_platform(platform_table)
+ if installer then
+ installer(server, callback, context)
else
- context.sdtio_sink.stderr "installers.when: Could not find installer for current platform."
+ context.stdio_sink.stderr(
+ ("Current operating system is not yet supported for server %q."):format(server.name)
+ )
callback(false)
end
end
diff --git a/lua/nvim-lsp-installer/installers/npm.lua b/lua/nvim-lsp-installer/installers/npm.lua
index 93bbb5ae..4900fba1 100644
--- a/lua/nvim-lsp-installer/installers/npm.lua
+++ b/lua/nvim-lsp-installer/installers/npm.lua
@@ -4,9 +4,11 @@ local process = require "nvim-lsp-installer.process"
local M = {}
+local npm = platform.is_win and "npm.cmd" or "npm"
+
function M.packages(packages)
return function(server, callback, context)
- process.spawn(platform.is_win and "npm.cmd" or "npm", {
+ process.spawn(npm, {
args = vim.list_extend({ "install" }, packages),
cwd = server.root_dir,
stdio_sink = context.stdio_sink,
@@ -14,6 +16,26 @@ function M.packages(packages)
end
end
+function M.install(production)
+ return function(server, callback, context)
+ process.spawn(npm, {
+ args = production and { "install", "--production" } or { "install" },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end
+end
+
+function M.run(script)
+ return function(server, callback, context)
+ process.spawn(npm, {
+ args = { "run", script },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end
+end
+
function M.executable(root_dir, executable)
return path.concat {
root_dir,
diff --git a/lua/nvim-lsp-installer/installers/shell.lua b/lua/nvim-lsp-installer/installers/shell.lua
index dbf0c17a..ace1f814 100644
--- a/lua/nvim-lsp-installer/installers/shell.lua
+++ b/lua/nvim-lsp-installer/installers/shell.lua
@@ -52,6 +52,21 @@ function M.cmd(raw_script, opts)
}
end
+function M.powershell(raw_script, opts)
+ local default_opts = {
+ env = {},
+ -- YIKES https://stackoverflow.com/a/63301751
+ prefix = "$ProgressPreference = 'SilentlyContinue';",
+ }
+ opts = vim.tbl_deep_extend("force", default_opts, opts or {})
+
+ return shell {
+ shell = "powershell.exe",
+ cmd = (opts.prefix or "") .. raw_script,
+ env = opts.env,
+ }
+end
+
function M.polyshell(raw_script, opts)
local default_opts = {
env = {},
diff --git a/lua/nvim-lsp-installer/installers/std.lua b/lua/nvim-lsp-installer/installers/std.lua
new file mode 100644
index 00000000..0a4aa40a
--- /dev/null
+++ b/lua/nvim-lsp-installer/installers/std.lua
@@ -0,0 +1,142 @@
+local path = require "nvim-lsp-installer.path"
+local process = require "nvim-lsp-installer.process"
+local installers = require "nvim-lsp-installer.installers"
+local shell = require "nvim-lsp-installer.installers.shell"
+
+local M = {}
+
+function M.download_file(url, out_file)
+ return installers.when {
+ unix = function(server, callback, context)
+ process.spawn("wget", {
+ args = { "-nv", "-O", out_file, url },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end,
+ win = shell.powershell(("iwr -Uri %q -OutFile %q"):format(url, out_file)),
+ }
+end
+
+function M.unzip(file, dest)
+ return installers.when {
+ unix = function(server, callback, context)
+ process.spawn("unzip", {
+ args = { "-d", dest, file },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end,
+ win = shell.powershell(("Expand-Archive -Path %q -DestinationPath %q"):format(file, dest)),
+ }
+end
+
+function M.unzip_remote(url, dest)
+ return installers.pipe {
+ M.download_file(url, "archive.zip"),
+ M.unzip("archive.zip", dest or "."),
+ installers.always_succeed(M.delete_file "archive.zip"),
+ }
+end
+
+function M.untar(file)
+ return installers.pipe {
+ function(server, callback, context)
+ process.spawn("tar", {
+ args = { "-xvf", file },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end,
+ installers.always_succeed(M.delete_file(file)),
+ }
+end
+
+function M.untargz_remote(url)
+ return installers.pipe {
+ M.download_file(url, "archive.tar.gz"),
+ M.gunzip "archive.tar.gz",
+ M.untar "archive.tar",
+ installers.always_succeed(M.delete_file "archive.tar"),
+ }
+end
+
+function M.gunzip(file)
+ return function(server, callback, context)
+ process.spawn("gzip", {
+ args = { "-d", file },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end
+end
+
+function M.gunzip_remote(url, out_file)
+ local archive = ("%s.gz"):format(out_file or "archive")
+ return installers.pipe {
+ M.download_file(url, archive),
+ M.gunzip(archive),
+ installers.always_succeed(M.delete_file(archive)),
+ }
+end
+
+function M.delete_file(file)
+ return installers.when {
+ unix = function(server, callback, context)
+ process.spawn("rm", {
+ args = { "-f", file },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end,
+ win = shell.powershell(("rm %q"):format(file)),
+ }
+end
+
+function M.git_clone(repo_url)
+ return function(server, callback, context)
+ process.spawn("git", {
+ args = { "clone", "--depth", "1", repo_url, "." },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end
+end
+
+function M.gradlew(opts)
+ return function(server, callback, context)
+ process.spawn(path.concat { server.root_dir, "gradlew" }, {
+ args = opts.args,
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end
+end
+
+function M.ensure_executables(executables)
+ return vim.schedule_wrap(function(_, callback, context)
+ for i = 1, #executables do
+ local executable = executables[i]
+ if vim.fn.executable(executable) ~= 1 then
+ context.stdio_sink.stderr(("Missing required %q executable."):format(executable))
+ callback(false)
+ return
+ end
+ end
+ callback(true)
+ end)
+end
+
+function M.chmod(flags, files)
+ return installers.on {
+ unix = function(server, callback, context)
+ process.spawn("chmod", {
+ args = vim.list_extend({ flags }, files),
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end,
+ }
+end
+
+return M
diff --git a/lua/nvim-lsp-installer/installers/zx.lua b/lua/nvim-lsp-installer/installers/zx.lua
index 04be94c6..85392e2c 100644
--- a/lua/nvim-lsp-installer/installers/zx.lua
+++ b/lua/nvim-lsp-installer/installers/zx.lua
@@ -35,7 +35,6 @@ local function zx_installer(force)
fs.mkdirp(INSTALL_DIR)
- -- todo use process installer
local handle, pid = process.spawn(platform.is_win and "npm.cmd" or "npm", {
args = { npm_command, "zx@1" },
cwd = INSTALL_DIR,
@@ -67,11 +66,12 @@ local function exec(file)
end
end
+-- @deprecated Compose your installer using the Lua `std` installers instead.
function M.file(relpath)
local script_path = path.realpath(relpath, 3)
- return installers.compose {
- exec(("file:///%s"):format(script_path)),
+ return installers.pipe {
zx_installer(false),
+ exec(("file:///%s"):format(script_path)),
}
end
diff --git a/lua/nvim-lsp-installer/platform.lua b/lua/nvim-lsp-installer/platform.lua
index 7a30bf47..7c754e45 100644
--- a/lua/nvim-lsp-installer/platform.lua
+++ b/lua/nvim-lsp-installer/platform.lua
@@ -1,6 +1,18 @@
local M = {}
+local uname = vim.loop.os_uname()
+
+local arch_aliases = {
+ ["x86_64"] = "x64",
+}
+
+M.arch = arch_aliases[uname.machine] or uname.machine
+
M.is_win = vim.fn.has "win32" == 1
M.is_unix = vim.fn.has "unix" == 1
+M.is_mac = vim.fn.has "mac" == 1
+
+-- PATH separator
+M.path_sep = M.is_win and ";" or ":"
return M
diff --git a/lua/nvim-lsp-installer/process.lua b/lua/nvim-lsp-installer/process.lua
index 5195f06a..d98a2ed5 100644
--- a/lua/nvim-lsp-installer/process.lua
+++ b/lua/nvim-lsp-installer/process.lua
@@ -131,8 +131,8 @@ end
function M.simple_sink()
return {
- stdout = print,
- stderr = vim.api.nvim_err_writeln,
+ stdout = vim.schedule_wrap(print),
+ stderr = vim.schedule_wrap(vim.api.nvim_err_writeln),
}
end
diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua
index ccad4c77..2e1a477c 100644
--- a/lua/nvim-lsp-installer/server.lua
+++ b/lua/nvim-lsp-installer/server.lua
@@ -1,5 +1,6 @@
local dispatcher = require "nvim-lsp-installer.dispatcher"
local fs = require "nvim-lsp-installer.fs"
+local installers = require "nvim-lsp-installer.installers"
local path = require "nvim-lsp-installer.path"
local status_win = require "nvim-lsp-installer.ui.status-win"
@@ -24,8 +25,6 @@ M.Server.__index = M.Server
--
-- @field default_options (table) The default options to be passed to lspconfig's .setup() function. Each server should provide at least the `cmd` field.
--
--- @field pre_install_check (function) An optional function to be executed before the installer. This allows ensuring that any prerequisites are fulfilled.
--- This could for example be verifying that required build tools are installed.
--
-- @field post_setup (function) An optional function to be executed after the setup function has been successfully called.
-- Use this to defer setting up server specific things until they're actually
@@ -39,9 +38,8 @@ function M.Server:new(opts)
name = opts.name,
root_dir = opts.root_dir,
_root_dir = opts.root_dir, -- @deprecated Use the `root_dir` property instead.
- _installer = opts.installer,
+ _installer = type(opts.installer) == "function" and opts.installer or installers.pipe(opts.installer),
_default_options = opts.default_options,
- _pre_install_check = opts.pre_install_check,
_post_setup = opts.post_setup,
_pre_setup = opts.pre_setup,
}, M.Server)
@@ -65,11 +63,11 @@ function M.Server:get_default_options()
end
function M.Server:is_installed()
- return fs.dir_exists(self._root_dir)
+ return fs.dir_exists(self.root_dir)
end
function M.Server:create_root_dir()
- fs.mkdirp(self._root_dir)
+ fs.mkdirp(self.root_dir)
end
function M.Server:install()
@@ -77,15 +75,13 @@ function M.Server:install()
end
function M.Server:install_attached(opts, callback)
- local ok, err = pcall(self.pre_install, self)
- if not ok then
- opts.stdio_sink.stderr(tostring(err))
- callback(false)
- return
- end
- self._installer(self, function(success)
+ self:uninstall()
+ self:create_root_dir()
+ local install_ok, install_err = pcall(self._installer, self, function(success)
if not success then
- pcall(self.uninstall, self)
+ vim.schedule(function()
+ pcall(self.uninstall, self)
+ end)
else
vim.schedule(function()
dispatcher.dispatch_server_ready(self)
@@ -93,24 +89,15 @@ function M.Server:install_attached(opts, callback)
end
callback(success)
end, opts)
-end
-
-function M.Server:pre_install()
- if self._pre_install_check then
- self._pre_install_check()
+ if not install_ok then
+ opts.stdio_sink.stderr(tostring(install_err))
+ callback(false)
end
-
- -- We run uninstall after pre_install_check because we don't want to
- -- unnecessarily uninstall a server should it no longer pass the
- -- pre_install_check.
- self:uninstall()
-
- self:create_root_dir()
end
function M.Server:uninstall()
- if fs.dir_exists(self._root_dir) then
- fs.rmrf(self._root_dir)
+ if fs.dir_exists(self.root_dir) then
+ fs.rmrf(self.root_dir)
end
end
diff --git a/lua/nvim-lsp-installer/servers/ansiblels/init.lua b/lua/nvim-lsp-installer/servers/ansiblels/init.lua
index b6899b70..8a997fea 100644
--- a/lua/nvim-lsp-installer/servers/ansiblels/init.lua
+++ b/lua/nvim-lsp-installer/servers/ansiblels/init.lua
@@ -1,20 +1,18 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local installers = require "nvim-lsp-installer.installers"
-local shell = require "nvim-lsp-installer.installers.shell"
+local std = require "nvim-lsp-installer.installers.std"
+local npm = require "nvim-lsp-installer.installers.npm"
local root_dir = server.get_server_root_path "ansiblels"
return server.Server:new {
name = "ansiblels",
root_dir = root_dir,
- installer = installers.when {
- unix = shell.bash [[
- git clone --depth 1 https://github.com/ansible/ansible-language-server .;
- npm install;
- npm run build;
- npm install --production;
- ]],
+ installer = {
+ std.git_clone "https://github.com/ansible/ansible-language-server",
+ npm.install(),
+ npm.run "compile",
+ npm.install(true),
},
default_options = {
filetypes = { "yaml", "yaml.ansible" },
diff --git a/lua/nvim-lsp-installer/servers/clangd/init.lua b/lua/nvim-lsp-installer/servers/clangd/init.lua
index 6028af24..d5bba9f8 100644
--- a/lua/nvim-lsp-installer/servers/clangd/init.lua
+++ b/lua/nvim-lsp-installer/servers/clangd/init.lua
@@ -1,17 +1,24 @@
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"
+local platform = require "nvim-lsp-installer.platform"
+local Data = require "nvim-lsp-installer.data"
+local std = require "nvim-lsp-installer.installers.std"
-local root_dir = server.get_server_root_path "c-family"
+local root_dir = server.get_server_root_path "clangd"
+
+local VERSION = "12.0.1"
+
+local target = Data.coalesce(
+ Data.when(platform.is_mac, "clangd-mac-%s.zip"),
+ Data.when(platform.is_unix, "clangd-linux-%s.zip"),
+ Data.when(platform.is_win, "clangd-windows-%s.zip")
+):format(VERSION)
return server.Server:new {
name = "clangd",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
- },
+ installer = std.unzip_remote(("https://github.com/clangd/clangd/releases/download/%s/%s"):format(VERSION, target)),
default_options = {
- cmd = { path.concat { root_dir, "clangd", "bin", "clangd" } },
+ cmd = { path.concat { root_dir, ("clangd_%s"):format(VERSION), "bin", "clangd" } },
},
}
diff --git a/lua/nvim-lsp-installer/servers/clangd/install.mjs b/lua/nvim-lsp-installer/servers/clangd/install.mjs
deleted file mode 100644
index 048a33c2..00000000
--- a/lua/nvim-lsp-installer/servers/clangd/install.mjs
+++ /dev/null
@@ -1,18 +0,0 @@
-const VERSION = "12.0.0";
-
-const target = (() => {
- const platform = os.platform();
- switch (platform) {
- case "darwin":
- return `clangd-mac-${VERSION}.zip`;
- default:
- return `clangd-linux-${VERSION}.zip`;
- }
-})();
-
-const downloadUrl = `https://github.com/clangd/clangd/releases/download/${VERSION}/${target}`;
-
-await $`wget -O clangd.zip ${downloadUrl}`;
-await $`unzip clangd.zip`;
-await $`rm clangd.zip`;
-await $`mv clangd_${VERSION} clangd`;
diff --git a/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua b/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua
index 8f22b676..a1331309 100644
--- a/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua
+++ b/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua
@@ -1,15 +1,25 @@
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"
+local std = require "nvim-lsp-installer.installers.std"
+local Data = require "nvim-lsp-installer.data"
+local platform = require "nvim-lsp-installer.platform"
local root_dir = server.get_server_root_path "clojure_lsp"
+local VERSION = "2021.07.01-19.49.02"
+
+local target = Data.coalesce(
+ Data.when(platform.is_mac, "clojure-lsp-native-macos-amd64.zip"),
+ Data.when(platform.is_unix, "clojure-lsp-native-linux-amd64.zip"),
+ Data.when(platform.is_win, "clojure-lsp-native-windows-amd64.zip")
+)
+
return server.Server:new {
name = "clojure_lsp",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
+ installer = {
+ std.unzip_remote(("https://github.com/clojure-lsp/clojure-lsp/releases/download/%s/%s"):format(VERSION, target)),
+ std.chmod("+x", { "clojure-lsp" }),
},
default_options = {
cmd = { path.concat { root_dir, "clojure-lsp" } },
diff --git a/lua/nvim-lsp-installer/servers/clojure_lsp/install.mjs b/lua/nvim-lsp-installer/servers/clojure_lsp/install.mjs
deleted file mode 100644
index 049e983c..00000000
--- a/lua/nvim-lsp-installer/servers/clojure_lsp/install.mjs
+++ /dev/null
@@ -1,17 +0,0 @@
-const VERSION = "2021.07.01-19.49.02";
-
-const target = (() => {
- switch (os.platform()) {
- case "darwin":
- return "clojure-lsp-native-macos-amd64.zip";
- default:
- return "clojure-lsp-native-linux-amd64.zip";
- }
-})();
-
-const downloadUrl = `https://github.com/clojure-lsp/clojure-lsp/releases/download/${VERSION}/${target}`;
-
-await $`wget ${downloadUrl}`;
-await $`unzip -o ${target}`;
-await $`chmod +x clojure-lsp`;
-await $`rm ${target}`;
diff --git a/lua/nvim-lsp-installer/servers/elixirls/init.lua b/lua/nvim-lsp-installer/servers/elixirls/init.lua
index 5c6c2040..cc98f5c6 100644
--- a/lua/nvim-lsp-installer/servers/elixirls/init.lua
+++ b/lua/nvim-lsp-installer/servers/elixirls/init.lua
@@ -1,20 +1,15 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local installers = require "nvim-lsp-installer.installers"
-local shell = require "nvim-lsp-installer.installers.shell"
+local std = require "nvim-lsp-installer.installers.std"
local root_dir = server.get_server_root_path "elixir"
return server.Server:new {
name = "elixirls",
root_dir = root_dir,
- installer = installers.when {
- unix = shell.bash [[
- wget -O elixir-ls.zip https://github.com/elixir-lsp/elixir-ls/releases/download/v0.8.1/elixir-ls.zip;
- unzip elixir-ls.zip -d elixir-ls;
- rm elixir-ls.zip;
- chmod +x elixir-ls/language_server.sh;
- ]],
+ installer = {
+ std.unzip_remote("https://github.com/elixir-lsp/elixir-ls/releases/download/v0.8.1/elixir-ls.zip", "elixir-ls"),
+ std.chmod("+x", { "elixir-ls/language_server.sh" }),
},
default_options = {
cmd = { path.concat { root_dir, "elixir-ls", "language_server.sh" } },
diff --git a/lua/nvim-lsp-installer/servers/groovyls/init.lua b/lua/nvim-lsp-installer/servers/groovyls/init.lua
index f885d933..1b492c4d 100644
--- a/lua/nvim-lsp-installer/servers/groovyls/init.lua
+++ b/lua/nvim-lsp-installer/servers/groovyls/init.lua
@@ -1,21 +1,18 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local installers = require "nvim-lsp-installer.installers"
-local shell = require "nvim-lsp-installer.installers.shell"
+local std = require "nvim-lsp-installer.installers.std"
local root_dir = server.get_server_root_path "groovyls"
return server.Server:new {
name = "groovyls",
root_dir = root_dir,
- pre_install_check = function()
- if vim.fn.executable "javac" ~= 1 then
- error "Missing a Javac installation."
- end
- end,
- installer = installers.when {
- unix = shell.bash [[ git clone --depth 1 https://github.com/GroovyLanguageServer/groovy-language-server . && ./gradlew build ]],
- win = shell.cmd [[ git clone --depth 1 https://github.com/GroovyLanguageServer/groovy-language-server . && .\gradlew build ]],
+ installer = {
+ std.ensure_executables { "javac" },
+ std.git_clone "https://github.com/GroovyLanguageServer/groovy-language-server",
+ std.gradlew {
+ args = { "build" },
+ },
},
default_options = {
cmd = { "java", "-jar", path.concat { root_dir, "build", "libs", "groovyls-all.jar" } },
diff --git a/lua/nvim-lsp-installer/servers/hls/init.lua b/lua/nvim-lsp-installer/servers/hls/init.lua
index 2ce227f9..88b48e99 100644
--- a/lua/nvim-lsp-installer/servers/hls/init.lua
+++ b/lua/nvim-lsp-installer/servers/hls/init.lua
@@ -1,17 +1,37 @@
local server = require "nvim-lsp-installer.server"
+local platform = require "nvim-lsp-installer.platform"
local installers = require "nvim-lsp-installer.installers"
local path = require "nvim-lsp-installer.path"
-local zx = require "nvim-lsp-installer.installers.zx"
+local std = require "nvim-lsp-installer.installers.std"
+local shell = require "nvim-lsp-installer.installers.shell"
+local Data = require "nvim-lsp-installer.data"
local root_dir = server.get_server_root_path "haskell"
+local VERSION = "1.3.0"
+
+local target = Data.coalesce(
+ Data.when(platform.is_mac, "haskell-language-server-macOS-%s.tar.gz"),
+ Data.when(platform.is_unix, "haskell-language-server-Linux-%s.tar.gz"),
+ Data.when(platform.is_win, "haskell-language-server-Windows-%s.tar.gz")
+):format(VERSION)
+
return server.Server:new {
name = "hls",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
+ installer = {
+ std.untargz_remote(
+ ("https://github.com/haskell/haskell-language-server/releases/download/%s/%s"):format(VERSION, target)
+ ),
+ installers.on {
+ -- we can't use std.chmod because of shell wildcard expansion
+ unix = shell.bash [[ chmod +x haskell*]],
+ },
},
default_options = {
- cmd = { path.concat { root_dir, "hls" } },
+ cmd = { path.concat { root_dir, "haskell-language-server-wrapper", "--lsp" } },
+ cmd_env = {
+ PATH = table.concat({ root_dir, vim.env.PATH }, platform.path_sep),
+ },
},
}
diff --git a/lua/nvim-lsp-installer/servers/hls/install.mjs b/lua/nvim-lsp-installer/servers/hls/install.mjs
deleted file mode 100644
index c9460e7c..00000000
--- a/lua/nvim-lsp-installer/servers/hls/install.mjs
+++ /dev/null
@@ -1,26 +0,0 @@
-const VERSION = "1.3.0";
-
-const target = (() => {
- const platform = os.platform();
- switch (platform) {
- case "darwin":
- return `haskell-language-server-macOS-${VERSION}.tar.gz`;
- default:
- return `haskell-language-server-Linux-${VERSION}.tar.gz`;
- }
-})();
-
-const downloadUrl = `https://github.com/haskell/haskell-language-server/releases/download/${VERSION}/${target}`;
-
-await $`wget -O hls.tar.gz ${downloadUrl}`;
-await $`tar -xf hls.tar.gz`;
-await $`rm hls.tar.gz`;
-await $`chmod +x haskell*`;
-
-const scriptContent = `#!/usr/bin/env bash
-HLS_DIR=$(dirname "$0")
-export PATH=$PATH:$HLS_DIR
-haskell-language-server-wrapper --lsp`;
-
-await fs.writeFile("./hls", scriptContent);
-await $`chmod +x hls`
diff --git a/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua b/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua
index 7b4a481d..45c4d9e1 100644
--- a/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua
+++ b/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua
@@ -1,22 +1,14 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local installers = require "nvim-lsp-installer.installers"
local platform = require "nvim-lsp-installer.platform"
-local shell = require "nvim-lsp-installer.installers.shell"
+local std = require "nvim-lsp-installer.installers.std"
local root_dir = server.get_server_root_path "kotlin"
return server.Server:new {
name = "kotlin_language_server",
root_dir = root_dir,
- installer = installers.when {
- unix = shell.bash [[
- wget -O server.zip https://github.com/fwcd/kotlin-language-server/releases/latest/download/server.zip;
- unzip server.zip;
- rm server.zip;
- ]],
- win = shell.cmd [[ curl -fLo server.zip https://github.com/fwcd/kotlin-language-server/releases/latest/download/server.zip && tar -xvf server.zip && del /f server.zip ]],
- },
+ installer = std.unzip_remote "https://github.com/fwcd/kotlin-language-server/releases/latest/download/server.zip",
default_options = {
cmd = {
path.concat {
diff --git a/lua/nvim-lsp-installer/servers/omnisharp/common.mjs b/lua/nvim-lsp-installer/servers/omnisharp/common.mjs
deleted file mode 100644
index cd41b089..00000000
--- a/lua/nvim-lsp-installer/servers/omnisharp/common.mjs
+++ /dev/null
@@ -1,35 +0,0 @@
-const VERSION = "v1.37.11";
-
-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 "darwin":
- return "omnisharp-osx.zip";
- case "win32":
- switch (os.arch()) {
- case "arm64":
- return "omnisharp-win-arm64.zip";
- case "x64":
- return "omnisharp-win-x64.zip";
- default:
- return exitNotSupported();
- }
- default:
- switch (os.arch()) {
- case "arm64":
- return exitNotSupported();
- case "x64":
- return "omnisharp-linux-x64.zip";
- default:
- return exitNotSupported();
- }
- }
- })();
-
- return `https://github.com/OmniSharp/omnisharp-roslyn/releases/download/${VERSION}/${target}`;
-};
diff --git a/lua/nvim-lsp-installer/servers/omnisharp/init.lua b/lua/nvim-lsp-installer/servers/omnisharp/init.lua
index 825ba811..4bb2a7ec 100644
--- a/lua/nvim-lsp-installer/servers/omnisharp/init.lua
+++ b/lua/nvim-lsp-installer/servers/omnisharp/init.lua
@@ -1,17 +1,34 @@
local server = require "nvim-lsp-installer.server"
-local installers = require "nvim-lsp-installer.installers"
local platform = require "nvim-lsp-installer.platform"
local path = require "nvim-lsp-installer.path"
-local zx = require "nvim-lsp-installer.installers.zx"
+local Data = require "nvim-lsp-installer.data"
+local std = require "nvim-lsp-installer.installers.std"
local root_dir = server.get_server_root_path "omnisharp"
+local VERSION = "v1.37.15"
+
+local target = Data.coalesce(
+ Data.when(platform.is_mac, "omnisharp-osx.zip"),
+ Data.when(platform.is_unix and platform.arch == "x64", "omnisharp-linux-x64.zip"),
+ Data.when(
+ platform.is_win,
+ Data.coalesce(
+ Data.when(platform.arch == "x64", "omnisharp-win-x64.zip"),
+ Data.when(platform.arch == "arm64", "omnisharp-win-arm64.zip")
+ )
+ )
+)
+
return server.Server:new {
name = "omnisharp",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
- win = zx.file "./install.win.mjs",
+ installer = {
+ std.unzip_remote(
+ ("https://github.com/OmniSharp/omnisharp-roslyn/releases/download/%s/%s"):format(VERSION, target),
+ "omnisharp"
+ ),
+ std.chmod("+x", { "omnisharp/run" }),
},
default_options = {
cmd = {
diff --git a/lua/nvim-lsp-installer/servers/omnisharp/install.mjs b/lua/nvim-lsp-installer/servers/omnisharp/install.mjs
deleted file mode 100644
index 14d705b3..00000000
--- a/lua/nvim-lsp-installer/servers/omnisharp/install.mjs
+++ /dev/null
@@ -1,6 +0,0 @@
-import { getDownloadUrl } from "./common.mjs";
-
-await $`wget -O omnisharp.zip ${getDownloadUrl()}`;
-await $`unzip omnisharp.zip -d omnisharp`;
-await $`chmod +x omnisharp/run`;
-await $`rm omnisharp.zip`;
diff --git a/lua/nvim-lsp-installer/servers/omnisharp/install.win.mjs b/lua/nvim-lsp-installer/servers/omnisharp/install.win.mjs
deleted file mode 100644
index 286c60f5..00000000
--- a/lua/nvim-lsp-installer/servers/omnisharp/install.win.mjs
+++ /dev/null
@@ -1,10 +0,0 @@
-import { getDownloadUrl } from "./common.mjs";
-
-// TODO: can this be... less hacky?
-$.shell = "powershell.exe";
-$.prefix = "";
-$.quote = (a) => a;
-
-await $`wget -O omnisharp.zip ${getDownloadUrl()}`;
-await $`tar -xvf omnisharp.zip`;
-await $`rm omnisharp.zip`;
diff --git a/lua/nvim-lsp-installer/servers/rescriptls/init.lua b/lua/nvim-lsp-installer/servers/rescriptls/init.lua
index f7aad87a..f61ff241 100644
--- a/lua/nvim-lsp-installer/servers/rescriptls/init.lua
+++ b/lua/nvim-lsp-installer/servers/rescriptls/init.lua
@@ -1,24 +1,13 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local installers = require "nvim-lsp-installer.installers"
-local shell = require "nvim-lsp-installer.installers.shell"
+local std = require "nvim-lsp-installer.installers.std"
local root_dir = server.get_server_root_path "rescriptls"
return server.Server:new {
name = "rescriptls",
root_dir = root_dir,
- installer = installers.when {
- unix = shell.bash [[
- curl -fs https://api.github.com/repos/rescript-lang/rescript-vscode/releases/latest \
- | grep "browser_download_url.*vsix" \
- | cut -d : -f 2,3 \
- | tr -d '"' \
- | wget -i - -O vscode-rescript.vsix;
- unzip -q -o vscode-rescript.vsix;
- rm -f vscode-rescript.vsix;
- ]],
- },
+ installer = std.unzip_remote "https://github.com/rescript-lang/rescript-vscode/releases/download/1.1.3/rescript-vscode-1.1.3.vsix",
default_options = {
cmd = { "node", path.concat { root_dir, "extension", "server", "out", "server.js" }, "--stdio" },
},
diff --git a/lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs b/lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs
deleted file mode 100644
index 0f54a71e..00000000
--- a/lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs
+++ /dev/null
@@ -1,41 +0,0 @@
-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 58cb53e2..c5592be8 100644
--- a/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua
+++ b/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua
@@ -1,16 +1,46 @@
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"
+local platform = require "nvim-lsp-installer.platform"
+local std = require "nvim-lsp-installer.installers.std"
+local Data = require "nvim-lsp-installer.data"
local root_dir = server.get_server_root_path "rust"
+local VERSION = "2021-06-28"
+
+local target = Data.coalesce(
+ Data.when(
+ platform.is_mac,
+ Data.coalesce(
+ Data.when(platform.arch == "arm64", "rust-analyzer-aarch64-apple-darwin.gz"),
+ Data.when(platform.arch == "x64", "rust-analyzer-x86_64-apple-darwin.gz")
+ )
+ ),
+ Data.when(
+ platform.is_unix,
+ Data.coalesce(
+ Data.when(platform.arch == "arm64", "rust-analyzer-aarch64-unknown-linux-gnu.gz"),
+ Data.when(platform.arch == "x64", "rust-analyzer-x86_64-unknown-linux-gnu.gz")
+ )
+ ),
+ Data.when(
+ platform.is_win,
+ Data.coalesce(
+ Data.when(platform.arch == "arm64", "rust-analyzer-aarch64-pc-windows-msvc.gz"),
+ Data.when(platform.arch == "x64", "rust-analyzer-x86_64-pc-windows-msvc.gz")
+ )
+ )
+)
+
return server.Server:new {
name = "rust_analyzer",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
- win = zx.file "./install.win.mjs",
+ installer = {
+ std.gunzip_remote(
+ ("https://github.com/rust-analyzer/rust-analyzer/releases/download/%s/%s"):format(VERSION, target),
+ platform.is_win and "rust-analyzer.exe" or "rust-analyzer"
+ ),
+ std.chmod("+x", { "rust-analyzer" }),
},
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
deleted file mode 100644
index 4d3fec85..00000000
--- a/lua/nvim-lsp-installer/servers/rust_analyzer/install.mjs
+++ /dev/null
@@ -1,5 +0,0 @@
-import { getDownloadUrl } from "./common.mjs";
-
-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
deleted file mode 100644
index 22ad75f7..00000000
--- a/lua/nvim-lsp-installer/servers/rust_analyzer/install.win.mjs
+++ /dev/null
@@ -1,9 +0,0 @@
-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`;
diff --git a/lua/nvim-lsp-installer/servers/solargraph/init.lua b/lua/nvim-lsp-installer/servers/solargraph/init.lua
index d23b029e..458bb7ea 100644
--- a/lua/nvim-lsp-installer/servers/solargraph/init.lua
+++ b/lua/nvim-lsp-installer/servers/solargraph/init.lua
@@ -1,22 +1,14 @@
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"
+local gem = require "nvim-lsp-installer.installers.gem"
-local root_dir = server.get_server_root_path "ruby"
+local root_dir = server.get_server_root_path "solargraph"
return server.Server:new {
name = "solargraph",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
- },
- pre_install_check = function()
- if vim.fn.executable "bundle" ~= 1 then
- error "bundle not installed"
- end
- end,
+ installer = gem.packages { "solargraph" },
default_options = {
- cmd = { path.concat { root_dir, "solargraph", "solargraph" }, "stdio" },
+ cmd = { gem.executable(root_dir, "solargraph"), "stdio" },
+ cmd_env = gem.env(root_dir),
},
}
diff --git a/lua/nvim-lsp-installer/servers/solargraph/install.mjs b/lua/nvim-lsp-installer/servers/solargraph/install.mjs
deleted file mode 100644
index 94db0bc8..00000000
--- a/lua/nvim-lsp-installer/servers/solargraph/install.mjs
+++ /dev/null
@@ -1,14 +0,0 @@
-await $`git clone --depth 1 https://github.com/castwide/solargraph.git .`;
-
-await $`bundle config set --local without 'development'`;
-await $`bundle config set --local path 'vendor/bundle'`;
-await $`bundle install`;
-
-await fs.writeFile(
- "./solargraph",
- `#!/usr/bin/env bash
-cd "$(dirname "$0")" || exit 1
-bundle exec solargraph $*`
-);
-
-await $`chmod +x solargraph`;
diff --git a/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua b/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua
index 7ad00ebe..696679b0 100644
--- a/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua
+++ b/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua
@@ -1,32 +1,33 @@
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"
+local platform = require "nvim-lsp-installer.platform"
+local Data = require "nvim-lsp-installer.data"
+local std = require "nvim-lsp-installer.installers.std"
-local root_dir = server.get_server_root_path "lua"
+local root_dir = server.get_server_root_path "sumneko_lua"
-local uname_alias = {
- Darwin = "macOS",
-}
-local uname = vim.fn.system("uname"):gsub("%s+", "")
-local bin_dir = uname_alias[uname] or uname
+local bin_dir = Data.coalesce(
+ Data.when(platform.is_mac, "macOS"),
+ Data.when(platform.is_unix, "Linux"),
+ Data.when(platform.is_win, "Windows")
+)
return server.Server:new {
name = "sumneko_lua",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
+ installer = {
+ std.unzip_remote "https://github.com/sumneko/vscode-lua/releases/download/v2.3.6/lua-2.3.6.vsix",
+ -- see https://github.com/sumneko/vscode-lua/pull/43
+ std.chmod(
+ "+x",
+ { "extension/server/bin/macOS/lua-language-server", "extension/server/bin/Linux/lua-language-server" }
+ ),
},
- pre_install_check = function()
- if vim.fn.executable "ninja" ~= 1 then
- error "ninja not installed (see https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages)"
- end
- end,
default_options = {
cmd = {
- path.concat { root_dir, "bin", bin_dir, "lua-language-server" },
+ path.concat { root_dir, "extension", "server", "bin", bin_dir, "lua-language-server" },
"-E",
- path.concat { root_dir, "main.lua" },
+ path.concat { root_dir, "extension", "server", "main.lua" },
},
settings = {
Lua = {
diff --git a/lua/nvim-lsp-installer/servers/sumneko_lua/install.mjs b/lua/nvim-lsp-installer/servers/sumneko_lua/install.mjs
deleted file mode 100644
index 3f2d20e0..00000000
--- a/lua/nvim-lsp-installer/servers/sumneko_lua/install.mjs
+++ /dev/null
@@ -1,17 +0,0 @@
-await $`git clone --depth 1 https://github.com/sumneko/lua-language-server.git .`;
-await $`git submodule update --init --recursive`;
-
-cd("3rd/luamake");
-switch (os.platform()) {
- case "darwin": {
- await $`ninja -f compile/ninja/macos.ninja`;
- break;
- }
- default: {
- await $`ninja -f compile/ninja/linux.ninja`;
- break;
- }
-}
-
-cd(".");
-await $`./3rd/luamake/luamake rebuild &> /dev/null`;
diff --git a/lua/nvim-lsp-installer/servers/tailwindcss/init.lua b/lua/nvim-lsp-installer/servers/tailwindcss/init.lua
index cf76d0b0..c674f11c 100644
--- a/lua/nvim-lsp-installer/servers/tailwindcss/init.lua
+++ b/lua/nvim-lsp-installer/servers/tailwindcss/init.lua
@@ -1,21 +1,13 @@
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"
+local npm = require "nvim-lsp-installer.installers.npm"
-local root_dir = server.get_server_root_path "tailwindcss"
+local root_dir = server.get_server_root_path "tailwindcss_npm"
return server.Server:new {
name = "tailwindcss",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
- },
+ installer = npm.packages { "@tailwindcss/language-server" },
default_options = {
- cmd = {
- "node",
- path.concat { root_dir, "tailwindcss", "extension", "dist", "server", "tailwindServer.js" },
- "--stdio",
- },
+ cmd = { npm.executable(root_dir, "tailwindcss-language-server"), "--stdio" },
},
}
diff --git a/lua/nvim-lsp-installer/servers/tailwindcss/install.mjs b/lua/nvim-lsp-installer/servers/tailwindcss/install.mjs
deleted file mode 100644
index 31d9083d..00000000
--- a/lua/nvim-lsp-installer/servers/tailwindcss/install.mjs
+++ /dev/null
@@ -1,7 +0,0 @@
-const VERSION = "v0.6.12"
-
-const downloadUrl = `https://github.com/tailwindlabs/tailwindcss-intellisense/releases/download/${VERSION}/vscode-tailwindcss-${VERSION.replace(/^v/, "")}.vsix`
-
-await $`wget -O tailwindcss-intellisense.vsix ${downloadUrl}`
-await $`unzip tailwindcss-intellisense.vsix -d tailwindcss`
-await $`rm tailwindcss-intellisense.vsix`
diff --git a/lua/nvim-lsp-installer/servers/terraformls/init.lua b/lua/nvim-lsp-installer/servers/terraformls/init.lua
index 5df3cecc..17aa0859 100644
--- a/lua/nvim-lsp-installer/servers/terraformls/init.lua
+++ b/lua/nvim-lsp-installer/servers/terraformls/init.lua
@@ -1,16 +1,39 @@
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"
+local platform = require "nvim-lsp-installer.platform"
+local std = require "nvim-lsp-installer.installers.std"
+local Data = require "nvim-lsp-installer.data"
local root_dir = server.get_server_root_path "terraform"
+local VERSION = "0.21.0"
+
+local target = Data.coalesce(
+ Data.when(
+ platform.is_mac,
+ Data.coalesce(
+ Data.when(platform.arch == "arm64", "terraform-ls_%s_darwin_arm64.zip"),
+ Data.when(platform.arch == "x64", "terraform-ls_%s_darwin_amd64.zip")
+ )
+ ),
+ Data.when(
+ platform.is_unix,
+ Data.coalesce(
+ Data.when(platform.arch == "arm64", "terraform-ls_%s_linux_arm64.zip"),
+ Data.when(platform.arch == "arm", "terraform-ls_%s_linux_arm.zip"),
+ Data.when(platform.arch == "x64", "terraform-ls_%s_linux_amd64.zip")
+ )
+ ),
+ Data.when(platform.is_win, Data.coalesce(Data.when(platform.arch == "x64", "terraform-ls_%s_windows_amd64.zip")))
+):format(VERSION)
+
return server.Server:new {
name = "terraformls",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
- },
+ installer = std.unzip_remote(
+ ("https://github.com/hashicorp/terraform-ls/releases/download/v%s/%s"):format(VERSION, target),
+ "terraform-ls"
+ ),
default_options = {
cmd = { path.concat { root_dir, "terraform-ls", "terraform-ls" }, "serve" },
},
diff --git a/lua/nvim-lsp-installer/servers/terraformls/install.mjs b/lua/nvim-lsp-installer/servers/terraformls/install.mjs
deleted file mode 100644
index 04efc288..00000000
--- a/lua/nvim-lsp-installer/servers/terraformls/install.mjs
+++ /dev/null
@@ -1,35 +0,0 @@
-const VERSION = "v0.18.3";
-
-const exitNotSupported = () => {
- console.error(chalk.red(`${os.platform()} ${os.arch()} is currently not supported.`));
- process.exit(1);
-};
-
-const target = (() => {
- switch (os.platform()) {
- case "darwin":
- switch (os.arch()) {
- case "arm64":
- return "terraform-ls_0.18.3_darwin_arm64.zip";
- case "x64":
- return "terraform-ls_0.18.3_darwin_amd64.zip";
- default: {
- exitNotSupported();
- break;
- }
- }
- default:
- switch (os.arch()) {
- case "arm64":
- return "terraform-ls_0.18.3_linux_arm64.zip";
- default:
- return "terraform-ls_0.18.3_linux_amd64.zip";
- }
- }
-})();
-
-const downloadUrl = `https://github.com/hashicorp/terraform-ls/releases/download/${VERSION}/${target}`;
-
-await $`wget -O terraform-ls.zip ${downloadUrl}`;
-await $`unzip terraform-ls.zip -d terraform-ls`;
-await $`rm terraform-ls.zip`;
diff --git a/lua/nvim-lsp-installer/servers/texlab/init.lua b/lua/nvim-lsp-installer/servers/texlab/init.lua
index c669806b..a28b4273 100644
--- a/lua/nvim-lsp-installer/servers/texlab/init.lua
+++ b/lua/nvim-lsp-installer/servers/texlab/init.lua
@@ -1,23 +1,26 @@
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"
+local std = require "nvim-lsp-installer.installers.std"
+local Data = require "nvim-lsp-installer.data"
+local platform = require "nvim-lsp-installer.platform"
local root_dir = server.get_server_root_path "latex"
+local VERSION = "v3.2.0"
+
+local target = Data.coalesce(
+ Data.when(platform.is_mac, "texlab-x86_64-macos.tar.gz"),
+ Data.when(platform.is_unix, "texlab-x86_64-linux.tar.gz"),
+ Data.when(platform.is_win, "texlab-x86_64-windows.tar.gz")
+)
+
return server.Server:new {
name = "texlab",
root_dir = root_dir,
- installer = installers.when {
- unix = zx.file "./install.mjs",
+ installer = {
+ std.ensure_executables { "pdflatex" },
+ std.untargz_remote(("https://github.com/latex-lsp/texlab/releases/download/%s/%s"):format(VERSION, target)),
},
- pre_install_check = function()
- if vim.fn.executable "wget" ~= 1 then
- error "Missing wget. Please, refer to https://www.gnu.org/software/wget/ to install it."
- elseif vim.fn.executable "pdflatex" ~= 1 then
- error "The program pdflatex wasn't found. Please install a TeX distribution: https://www.latex-project.org/get/#tex-distributions"
- end
- end,
default_options = {
cmd = { path.concat { root_dir, "texlab" } },
},
diff --git a/lua/nvim-lsp-installer/servers/texlab/install.mjs b/lua/nvim-lsp-installer/servers/texlab/install.mjs
deleted file mode 100644
index bc7fefe1..00000000
--- a/lua/nvim-lsp-installer/servers/texlab/install.mjs
+++ /dev/null
@@ -1,16 +0,0 @@
-const VERSION = "v3.2.0";
-
-const platform = os.platform();
-
-const target = (() => {
- switch (platform) {
- case "darwin":
- return `https://github.com/latex-lsp/texlab/releases/download/${VERSION}/texlab-x86_64-macos.tar.gz`;
- default:
- return `https://github.com/latex-lsp/texlab/releases/download/${VERSION}/texlab-x86_64-linux.tar.gz`;
- }
-})();
-
-await $`wget -O texlab.tar.gz ${target}`;
-await $`tar xf texlab.tar.gz`;
-await $`rm texlab.tar.gz`;