diff options
| author | Jürgen Steitz <JSteitz@users.noreply.github.com> | 2022-01-15 15:02:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-15 15:02:23 +0100 |
| commit | 50f82f6042d72fd370f752ec6a4f2033cea22ab6 (patch) | |
| tree | 57849632ac79f8bdd18d9642186afcf7381a6087 /lua/nvim-lsp-installer/installers | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-50f82f6042d72fd370f752ec6a4f2033cea22ab6.tar mason-50f82f6042d72fd370f752ec6a4f2033cea22ab6.tar.gz mason-50f82f6042d72fd370f752ec6a4f2033cea22ab6.tar.bz2 mason-50f82f6042d72fd370f752ec6a4f2033cea22ab6.tar.lz mason-50f82f6042d72fd370f752ec6a4f2033cea22ab6.tar.xz mason-50f82f6042d72fd370f752ec6a4f2033cea22ab6.tar.zst mason-50f82f6042d72fd370f752ec6a4f2033cea22ab6.zip | |
add server psalm (#426)
Co-authored-by: William Boman <william@redwill.se>
Diffstat (limited to 'lua/nvim-lsp-installer/installers')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/composer.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/installers/composer.lua b/lua/nvim-lsp-installer/installers/composer.lua index 1e8a1717..26e4e7be 100644 --- a/lua/nvim-lsp-installer/installers/composer.lua +++ b/lua/nvim-lsp-installer/installers/composer.lua @@ -2,6 +2,11 @@ local installers = require "nvim-lsp-installer.installers" local std = require "nvim-lsp-installer.installers.std" local platform = require "nvim-lsp-installer.platform" local process = require "nvim-lsp-installer.process" +local fs = require "nvim-lsp-installer.fs" +local path = require "nvim-lsp-installer.path" +local Data = require "nvim-lsp-installer.data" + +local list_copy = Data.list_copy local M = {} @@ -18,6 +23,37 @@ local function ensure_composer(installer) } end +---@param packages string[] The composer packages to install. The first item in this list will be the recipient of the server version, should the user request a specific one. +function M.require(packages) + return ensure_composer( + ---@type ServerInstallerFunction + function(_, callback, ctx) + local pkgs = list_copy(packages) + local c = process.chain { + cwd = ctx.install_dir, + stdio_sink = ctx.stdio_sink, + } + + ctx.receipt:with_primary_source(ctx.receipt.composer(pkgs[1])) + for i = 2, #pkgs do + ctx.receipt:with_secondary_source(ctx.receipt.composer(pkgs[i])) + end + + if not (fs.file_exists(path.concat { ctx.install_dir, "composer.json" })) then + c.run(M.composer_cmd, { "init", "--no-interaction", "--stability=stable" }) + end + + if ctx.requested_server_version then + -- The "head" package is the recipient for the requested version. It's.. by design... don't ask. + pkgs[1] = ("%s:%s"):format(pkgs[1], ctx.requested_server_version) + end + + c.run(M.composer_cmd, vim.list_extend({ "require" }, pkgs)) + c.spawn(callback) + end + ) +end + function M.install() return ensure_composer( ---@type ServerInstallerFunction @@ -37,4 +73,11 @@ function M.install() ) end +---@param root_dir string The directory to resolve the executable from. +function M.env(root_dir) + return { + PATH = process.extend_path { path.concat { root_dir, "vendor", "bin" } }, + } +end + return M |
