diff options
| author | William Boman <william@redwill.se> | 2022-04-21 12:09:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-21 12:09:59 +0200 |
| commit | b68fcc6bb2c770495ff8e2508c06dfdd49abcc80 (patch) | |
| tree | df7c71efb59958deb21a18eeccf3e3c43c4cd704 /lua/nvim-lsp-installer/servers/beancount/init.lua | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.gz mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.bz2 mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.lz mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.xz mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.zst mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.zip | |
chore: refactor remaining installers to async impl (#616)
Diffstat (limited to 'lua/nvim-lsp-installer/servers/beancount/init.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/servers/beancount/init.lua | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/lua/nvim-lsp-installer/servers/beancount/init.lua b/lua/nvim-lsp-installer/servers/beancount/init.lua index b9908488..e857e44b 100644 --- a/lua/nvim-lsp-installer/servers/beancount/init.lua +++ b/lua/nvim-lsp-installer/servers/beancount/init.lua @@ -1,8 +1,6 @@ local server = require "nvim-lsp-installer.server" -local installers = require "nvim-lsp-installer.installers" -local context = require "nvim-lsp-installer.installers.context" -local pip3 = require "nvim-lsp-installer.installers.pip3" -local std = require "nvim-lsp-installer.installers.std" +local github = require "nvim-lsp-installer.core.managers.github" +local pip3 = require "nvim-lsp-installer.core.managers.pip3" local Data = require "nvim-lsp-installer.data" local platform = require "nvim-lsp-installer.platform" local process = require "nvim-lsp-installer.process" @@ -10,47 +8,37 @@ local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when return function(name, root_dir) - local file_ext = platform.is_win and ".exe" or "" return server.Server:new { name = name, root_dir = root_dir, languages = { "beancount" }, homepage = "https://github.com/polarmutex/beancount-language-server", - installer = { - context.use_github_release_file( - "polarmutex/beancount-language-server", + async = true, + ---@param ctx InstallContext + installer = function(ctx) + local asset_file = assert( coalesce( when(platform.is_mac, "beancount-language-server-macos-x64.zip"), when(platform.is_linux and platform.arch == "x64", "beancount-language-server-linux-x64.zip"), when(platform.is_win and platform.arch == "x64", "beancount-language-server-windows-x64.zip") - ) - ), - context.capture(function(ctx) - return installers.pipe { - std.unzip_remote(ctx.github_release_file), - -- We rename the binary to conform with lspconfig - std.rename( - ("beancount-language-server%s"):format(file_ext), - ("beancount-langserver%s"):format(file_ext) - ), - } - end), - context.promote_install_dir(), - installers.branch_context { - context.set(function(ctx) - ctx.requested_server_version = nil - end), - pip3.packages { "beancount" }, - }, - context.receipt(function(receipt, ctx) - receipt - :with_primary_source(receipt.github_release_file(ctx)) - :with_secondary_source(receipt.pip3 "beancount") - end), - }, + ), + "Unsupported platform" + ) + github.unzip_release_file({ + repo = "polarmutex/beancount-language-server", + asset_file = asset_file, + }).with_receipt() + + local file_ext = platform.is_win and ".exe" or "" + -- We rename the binary to conform with lspconfig + ctx.fs:rename(("beancount-language-server%s"):format(file_ext), ("beancount-langserver%s"):format(file_ext)) + + pip3.install { "beancount" } + ctx.receipt:with_secondary_source(ctx.receipt.pip3 "beancount") + end, default_options = { cmd_env = { - PATH = process.extend_path { root_dir, pip3.path(root_dir) }, + PATH = process.extend_path { root_dir, pip3.venv_path(root_dir) }, }, }, } |
