aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/erlangls/init.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-21 12:09:59 +0200
committerGitHub <noreply@github.com>2022-04-21 12:09:59 +0200
commitb68fcc6bb2c770495ff8e2508c06dfdd49abcc80 (patch)
treedf7c71efb59958deb21a18eeccf3e3c43c4cd704 /lua/nvim-lsp-installer/servers/erlangls/init.lua
parentrun autogen_metadata.lua (diff)
downloadmason-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/erlangls/init.lua')
-rw-r--r--lua/nvim-lsp-installer/servers/erlangls/init.lua43
1 files changed, 22 insertions, 21 deletions
diff --git a/lua/nvim-lsp-installer/servers/erlangls/init.lua b/lua/nvim-lsp-installer/servers/erlangls/init.lua
index 749a57b0..52b2e8ea 100644
--- a/lua/nvim-lsp-installer/servers/erlangls/init.lua
+++ b/lua/nvim-lsp-installer/servers/erlangls/init.lua
@@ -1,9 +1,11 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local process = require "nvim-lsp-installer.process"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local platform = require "nvim-lsp-installer.platform"
+local std = require "nvim-lsp-installer.core.managers.std"
+local github_client = require "nvim-lsp-installer.core.managers.github.client"
+local git = require "nvim-lsp-installer.core.managers.git"
+local Optional = require "nvim-lsp-installer.core.optional"
return function(name, root_dir)
local rebar3 = platform.is_win and "rebar3.cmd" or "rebar3"
@@ -13,25 +15,24 @@ return function(name, root_dir)
root_dir = root_dir,
languages = { "erlang" },
homepage = "https://erlang-ls.github.io/",
- installer = {
- std.ensure_executables {
- { rebar3, ("%s was not found in path. Refer to http://rebar3.org/docs/."):format(rebar3) },
- },
- context.use_github_latest_tag "erlang-ls/erlang_ls",
- std.git_clone "https://github.com/erlang-ls/erlang_ls.git",
- function(_, callback, ctx)
- local c = process.chain {
- cwd = ctx.install_dir,
- stdio_sink = ctx.stdio_sink,
- }
- c.run(rebar3, { "escriptize" })
- c.run(rebar3, { "as", "dap", "escriptize" })
- c.spawn(callback)
- end,
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_tag(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ std.ensure_executable(rebar3, { help_url = "http://rebar3.org/docs/" })
+
+ local repo = "erlang-ls/erlang_ls"
+ ctx.requested_version = ctx.requested_version:or_(function()
+ return Optional.of(github_client.fetch_latest_tag(repo)
+ :map(function(tag)
+ return tag.name
+ end)
+ :get_or_throw "Failed to fetch latest tag.")
+ end)
+ git.clone({ ("https://github.com/%s.git"):format(repo) }).with_receipt()
+
+ ctx.spawn[rebar3] { "escriptize" }
+ ctx.spawn[rebar3] { "as", "dap", "escriptize" }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "_build", "default", "bin" } },