From 8e2f53359adbca5797785d3d4a4021b3db4a0dff Mon Sep 17 00:00:00 2001 From: William Boman Date: Tue, 5 Oct 2021 20:23:29 +0200 Subject: add serve_d (#133) --- lua/nvim-lsp-installer/installers/std.lua | 19 +++++++++---- lua/nvim-lsp-installer/servers/init.lua | 1 + lua/nvim-lsp-installer/servers/serve_d/init.lua | 38 +++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 lua/nvim-lsp-installer/servers/serve_d/init.lua (limited to 'lua') diff --git a/lua/nvim-lsp-installer/installers/std.lua b/lua/nvim-lsp-installer/installers/std.lua index 35c9ab21..bd1f7f61 100644 --- a/lua/nvim-lsp-installer/installers/std.lua +++ b/lua/nvim-lsp-installer/installers/std.lua @@ -52,11 +52,14 @@ function M.unzip_remote(url, dest) } end -function M.untar(file) +function M.untar(file, opts) + opts = opts or { + strip_components = 0, + } return installers.pipe { function(server, callback, context) process.spawn("tar", { - args = { "-xvf", file }, + args = { "-xvf", file, "--strip-components", opts.strip_components }, cwd = server.root_dir, stdio_sink = context.stdio_sink, }, callback) @@ -65,11 +68,17 @@ function M.untar(file) } end -function M.untargz_remote(url) +function M.untarxz_remote(url, tar_opts) + return installers.pipe { + M.download_file(url, "archive.tar.xz"), + M.untar("archive.tar.xz", tar_opts), + } +end + +function M.untargz_remote(url, tar_opts) return installers.pipe { M.download_file(url, "archive.tar.gz"), - M.gunzip "archive.tar.gz", - M.untar "archive.tar", + M.untar("archive.tar", tar_opts), } end diff --git a/lua/nvim-lsp-installer/servers/init.lua b/lua/nvim-lsp-installer/servers/init.lua index b7f497a2..fbae3c47 100644 --- a/lua/nvim-lsp-installer/servers/init.lua +++ b/lua/nvim-lsp-installer/servers/init.lua @@ -79,6 +79,7 @@ local CORE_SERVERS = Data.set_of { "rescriptls", "rome", "rust_analyzer", + "serve_d", "solargraph", "sqlls", "sqls", diff --git a/lua/nvim-lsp-installer/servers/serve_d/init.lua b/lua/nvim-lsp-installer/servers/serve_d/init.lua new file mode 100644 index 00000000..719d9d5f --- /dev/null +++ b/lua/nvim-lsp-installer/servers/serve_d/init.lua @@ -0,0 +1,38 @@ +local server = require "nvim-lsp-installer.server" +local platform = require "nvim-lsp-installer.platform" +local path = require "nvim-lsp-installer.path" +local std = require "nvim-lsp-installer.installers.std" +local context = require "nvim-lsp-installer.installers.context" +local Data = require "nvim-lsp-installer.data" + +return function(name, root_dir) + return server.Server:new { + name = name, + root_dir = root_dir, + installer = { + context.set(function(ctx) + -- Consider the latest (as of writing) beta release as "latest", instead of 0.6.0. + -- This is because 1) 0.6.0 is really old, but mostly 2) there are inconcistencies in which assets are + -- available 0.6.0 vs 0.7.0 beta releases. + ctx.requested_server_version = Data.coalesce(ctx.requested_server_version, "v0.7.0-beta.7") + end), + context.github_release_file("Pure-D/serve-d", function(version) + return Data.coalesce( + Data.when(platform.is_mac, "serve-d_%s-osx-x86_64.tar.xz"), + Data.when(platform.is_linux, "serve-d_%s-linux-x86_64.tar.xz"), + Data.when(platform.is_win, "serve-d_%s-windows-x86_64.zip") + ):format(version:gsub("^v", "")) + end), + context.capture(function(ctx) + if platform.is_win then + return std.unzip_remote(ctx.github_release_file) + else + return std.untarxz_remote(ctx.github_release_file) + end + end), + }, + default_options = { + cmd = { path.concat { root_dir, "serve-d" } }, + }, + } +end -- cgit v1.2.3-70-g09d2