diff options
| author | William Boman <william@redwill.se> | 2021-10-31 23:00:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-31 23:00:56 +0100 |
| commit | 3ba7961db19a66595085f06304b13f97155611bd (patch) | |
| tree | 36eb51df040428d7bc279209ec1a8e5af114913f /lua/nvim-lsp-installer/installers | |
| parent | sumneko_lua: remove settings (diff) | |
| download | mason-3ba7961db19a66595085f06304b13f97155611bd.tar mason-3ba7961db19a66595085f06304b13f97155611bd.tar.gz mason-3ba7961db19a66595085f06304b13f97155611bd.tar.bz2 mason-3ba7961db19a66595085f06304b13f97155611bd.tar.lz mason-3ba7961db19a66595085f06304b13f97155611bd.tar.xz mason-3ba7961db19a66595085f06304b13f97155611bd.tar.zst mason-3ba7961db19a66595085f06304b13f97155611bd.zip | |
pip3: promote install_dir to server's root dir immediately (#230)
Diffstat (limited to 'lua/nvim-lsp-installer/installers')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/context.lua | 16 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/installers/init.lua | 4 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/installers/pip3.lua | 6 |
3 files changed, 23 insertions, 3 deletions
diff --git a/lua/nvim-lsp-installer/installers/context.lua b/lua/nvim-lsp-installer/installers/context.lua index 71f2f991..97f200d5 100644 --- a/lua/nvim-lsp-installer/installers/context.lua +++ b/lua/nvim-lsp-installer/installers/context.lua @@ -123,6 +123,22 @@ function M.use_github_release_file(repo, file) } end +---Creates an installer that moves the current installation directory to the server's root directory. +function M.promote_install_dir() + ---@type ServerInstallerFunction + return function(server, callback, context) + if server:promote_install_dir(context.install_dir) then + context.install_dir = server.root_dir + callback(true) + else + context.stdio_sink.stderr( + ("Failed to promote temporary install directory to %s.\n"):format(server.root_dir) + ) + callback(false) + end + end +end + ---Access the context ojbect to create a new installer. ---@param fn fun(context: ServerInstallContext): ServerInstallerFunction function M.capture(fn) diff --git a/lua/nvim-lsp-installer/installers/init.lua b/lua/nvim-lsp-installer/installers/init.lua index 08218945..fdf3b0f4 100644 --- a/lua/nvim-lsp-installer/installers/init.lua +++ b/lua/nvim-lsp-installer/installers/init.lua @@ -97,7 +97,7 @@ function M.always_succeed(installer) end ---@param platform_table table<Platform, ServerInstallerFunction> ----@return ServerInstallerFunction | nil +---@return ServerInstallerFunction | ServerInstallerFunction[] | nil local function get_by_platform(platform_table) if platform.is_mac then return platform_table.mac or platform_table.unix @@ -133,7 +133,7 @@ end --- Creates a server installer that executes the given installer for the current platform. --- If there is no server installer provided for the current platform, the installer will instantly exit with a failure. ----@param platform_table table<Platform, ServerInstallerFunction> +---@param platform_table table<Platform, ServerInstallerFunction|ServerInstallerFunction[]> ---@return ServerInstallerFunction function M.when(platform_table) return function(server, callback, context) diff --git a/lua/nvim-lsp-installer/installers/pip3.lua b/lua/nvim-lsp-installer/installers/pip3.lua index 0d2b9338..c8586eb3 100644 --- a/lua/nvim-lsp-installer/installers/pip3.lua +++ b/lua/nvim-lsp-installer/installers/pip3.lua @@ -5,6 +5,7 @@ local std = require "nvim-lsp-installer.installers.std" local platform = require "nvim-lsp-installer.platform" local process = require "nvim-lsp-installer.process" local settings = require "nvim-lsp-installer.settings" +local context = require "nvim-lsp-installer.installers.context" local M = {} @@ -47,7 +48,10 @@ end function M.packages(packages) local py3 = create_installer("python3", packages) local py = create_installer("python", packages) - return installers.first_successful(platform.is_win and { py, py3 } or { py3, py }) -- see https://github.com/williamboman/nvim-lsp-installer/issues/128 + return installers.pipe { + context.promote_install_dir(), + installers.first_successful(platform.is_win and { py, py3 } or { py3, py }), -- see https://github.com/williamboman/nvim-lsp-installer/issues/128 + } end ---@param root_dir string @The directory to resolve the executable from. |
