aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/installers/composer.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-lsp-installer/installers/composer.lua')
-rw-r--r--lua/nvim-lsp-installer/installers/composer.lua70
1 files changed, 40 insertions, 30 deletions
diff --git a/lua/nvim-lsp-installer/installers/composer.lua b/lua/nvim-lsp-installer/installers/composer.lua
index d206cc46..ebe591d4 100644
--- a/lua/nvim-lsp-installer/installers/composer.lua
+++ b/lua/nvim-lsp-installer/installers/composer.lua
@@ -8,6 +8,7 @@ local process = require "nvim-lsp-installer.process"
local composer = platform.is_win and "composer.bat" or "composer"
+---@param installer ServerInstallerFunction
local function ensure_composer(installer)
return installers.pipe {
std.ensure_executables {
@@ -20,45 +21,54 @@ end
local M = {}
+---@param packages string[] @The Gem 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.packages(packages)
- return ensure_composer(function(server, callback, context)
- local c = process.chain {
- cwd = server.root_dir,
- stdio_sink = context.stdio_sink,
- }
+ return ensure_composer(
+ ---@type ServerInstallerFunction
+ function(server, callback, context)
+ local c = process.chain {
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }
- if not (fs.file_exists(path.concat { server.root_dir, "composer.json" })) then
- c.run(composer, { "init", "--no-interaction", "--stability=dev" })
- c.run(composer, { "config", "prefer-stable", "true" })
- end
+ if not (fs.file_exists(path.concat { server.root_dir, "composer.json" })) then
+ c.run(composer, { "init", "--no-interaction", "--stability=dev" })
+ c.run(composer, { "config", "prefer-stable", "true" })
+ end
- local pkgs = Data.list_copy(packages or {})
- if context.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], context.requested_server_version)
- end
+ local pkgs = Data.list_copy(packages or {})
+ if context.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], context.requested_server_version)
+ end
- c.run(composer, vim.list_extend({ "require" }, pkgs))
- c.spawn(callback)
- end)
+ c.run(composer, vim.list_extend({ "require" }, pkgs))
+ c.spawn(callback)
+ end
+ )
end
function M.install()
- return ensure_composer(function(server, callback, context)
- process.spawn(composer, {
- args = {
- "install",
- "--no-interaction",
- "--no-dev",
- "--optimize-autoloader",
- "--classmap-authoritative",
- },
- cwd = server.root_dir,
- stdio_sink = context.stdio_sink,
- }, callback)
- end)
+ return ensure_composer(
+ ---@type ServerInstallerFunction
+ function(server, callback, context)
+ process.spawn(composer, {
+ args = {
+ "install",
+ "--no-interaction",
+ "--no-dev",
+ "--optimize-autoloader",
+ "--classmap-authoritative",
+ },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end
+ )
end
+---@param root_dir string @The directory to resolve the executable from.
+---@param executable string
function M.executable(root_dir, executable)
return path.concat { root_dir, "vendor", "bin", platform.is_win and ("%s.bat"):format(executable) or executable }
end