diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/zx.lua | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/lua/nvim-lsp-installer/installers/zx.lua b/lua/nvim-lsp-installer/installers/zx.lua deleted file mode 100644 index 0bba8583..00000000 --- a/lua/nvim-lsp-installer/installers/zx.lua +++ /dev/null @@ -1,79 +0,0 @@ -local fs = require "nvim-lsp-installer.fs" -local path = require "nvim-lsp-installer.path" -local installers = require "nvim-lsp-installer.installers" -local platform = require "nvim-lsp-installer.platform" -local npm = require "nvim-lsp-installer.installers.npm" -local process = require "nvim-lsp-installer.process" - -local M = {} - -local INSTALL_DIR = path.concat { vim.fn.stdpath "data", "lsp_servers", ".zx" } -local ZX_EXECUTABLE = npm.executable(INSTALL_DIR, "zx") - -local has_installed_zx = false - -local function zx_installer(force) - force = force or false -- be careful with boolean logic if flipping this - - return function(_, callback, context) - if has_installed_zx and not force then - callback(true, "zx already installed") - return - end - - if vim.fn.executable "npm" ~= 1 or vim.fn.executable "node" ~= 1 then - callback(false, "Cannot install zx because npm and/or node not installed.") - return - end - - local is_zx_already_installed = fs.file_exists(ZX_EXECUTABLE) - local npm_command = is_zx_already_installed and "update" or "install" - - if not is_zx_already_installed then - context.stdio_sink.stdout(("Preparing for installation… (npm %s zx)\n"):format(npm_command)) - end - - fs.mkdirp(INSTALL_DIR) - - local handle, pid = process.spawn(platform.is_win and "npm.cmd" or "npm", { - args = { npm_command, "zx@1" }, - cwd = INSTALL_DIR, - stdio_sink = context.stdio_sink, - }, function(success) - if success then - has_installed_zx = true - callback(true) - else - context.stdio_sink.stderr "Failed to install zx.\n" - callback(false) - end - end) - - if handle == nil then - context.stdio_sink.stderr(("Failed to install/update zx. %s\n"):format(pid)) - callback(false) - end - end -end - -local function exec(file) - ---@type ServerInstallerFunction - return function(_, callback, context) - process.spawn(ZX_EXECUTABLE, { - args = { file }, - cwd = context.install_dir, - stdio_sink = context.stdio_sink, - }, callback) - 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.pipe { - zx_installer(false), - exec(("file:///%s"):format(script_path)), - } -end - -return M |
