diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/std.lua | 41 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/init.lua | 1 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/vala_ls/init.lua | 45 |
3 files changed, 68 insertions, 19 deletions
diff --git a/lua/nvim-lsp-installer/installers/std.lua b/lua/nvim-lsp-installer/installers/std.lua index b9e6f74f..c011279d 100644 --- a/lua/nvim-lsp-installer/installers/std.lua +++ b/lua/nvim-lsp-installer/installers/std.lua @@ -43,7 +43,7 @@ function M.unzip(file, dest) end, win = shell.powershell(("Expand-Archive -Path %q -DestinationPath %q"):format(file, dest)), }, - installers.always_succeed(M.delete_file(file)), + installers.always_succeed(M.rmrf(file)), } end @@ -63,7 +63,7 @@ function M.untar(file) stdio_sink = context.stdio_sink, }, callback) end, - installers.always_succeed(M.delete_file(file)), + installers.always_succeed(M.rmrf(file)), } end @@ -91,7 +91,7 @@ local function win_extract(file) on_finish = callback, } end, - installers.always_succeed(M.delete_file(file)), + installers.always_succeed(M.rmrf(file)), } end @@ -112,7 +112,7 @@ local function win_arc_unarchive(file) stdio_sink = context.stdio_sink, }, callback) end, - installers.always_succeed(M.delete_file(file)), + installers.always_succeed(M.rmrf(file)), } end @@ -154,21 +154,24 @@ function M.gunzip_remote(url, out_file) return installers.pipe { M.download_file(url, archive), M.gunzip(archive), - installers.always_succeed(M.delete_file(archive)), + installers.always_succeed(M.rmrf(archive)), } end -function M.delete_file(file) - return installers.when { - unix = function(server, callback, context) - process.spawn("rm", { - args = { "-f", file }, - cwd = server.root_dir, - stdio_sink = context.stdio_sink, - }, callback) - end, - win = shell.powershell(("rm %q"):format(file)), - } +function M.rmrf(rel_path) + return function(server, callback, context) + local abs_path = path.concat { server.root_dir, rel_path } + context.stdio_sink.stdout(("Deleting %q\n"):format(abs_path)) + vim.schedule(function() + local ok = pcall(fs.rmrf, abs_path) + if ok then + callback(true) + else + context.stdio_sink.stderr(("Failed to delete %q.\n"):format(abs_path)) + callback(false) + end + end) + end end function M.git_clone(repo_url) @@ -201,17 +204,17 @@ end function M.ensure_executables(executables) return vim.schedule_wrap(function(_, callback, context) + local has_error = false for i = 1, #executables do local entry = executables[i] local executable = entry[1] local error_msg = entry[2] if vim.fn.executable(executable) ~= 1 then + has_error = true context.stdio_sink.stderr(error_msg .. "\n") - callback(false) - return end end - callback(true) + callback(not has_error) end) end diff --git a/lua/nvim-lsp-installer/servers/init.lua b/lua/nvim-lsp-installer/servers/init.lua index abace672..6124ba5a 100644 --- a/lua/nvim-lsp-installer/servers/init.lua +++ b/lua/nvim-lsp-installer/servers/init.lua @@ -99,6 +99,7 @@ local CORE_SERVERS = Data.set_of { "texlab", "tflint", "tsserver", + "vala_ls", "vimls", "volar", "vuels", diff --git a/lua/nvim-lsp-installer/servers/vala_ls/init.lua b/lua/nvim-lsp-installer/servers/vala_ls/init.lua new file mode 100644 index 00000000..5ed52b4e --- /dev/null +++ b/lua/nvim-lsp-installer/servers/vala_ls/init.lua @@ -0,0 +1,45 @@ +local server = require "nvim-lsp-installer.server" +local path = require "nvim-lsp-installer.path" +local std = require "nvim-lsp-installer.installers.std" +local context = require "nvim-lsp-installer.installers.context" +local installers = require "nvim-lsp-installer.installers" +local process = require "nvim-lsp-installer.process" + +return function(name, root_dir) + return server.Server:new { + name = name, + root_dir = root_dir, + homepage = "https://wiki.gnome.org/Projects/Vala", + installer = { + std.ensure_executables { + { "meson", "meson was not found in path. Refer to https://mesonbuild.com/Getting-meson.html" }, + { "ninja", "ninja was not found in path. Refer to https://ninja-build.org/" }, + { "valac", "valac was not found in path. Refer to https://wiki.gnome.org/Projects/Vala" }, + }, + context.github_release_file("Prince781/vala-language-server", function(version) + return ("vala-language-server-%s.tar.xz"):format(version) + end), + context.capture(function(ctx) + return installers.pipe { + std.untarxz_remote(ctx.github_release_file), + std.rename(("vala-language-server-%s"):format(ctx.requested_server_version), "vala-language-server"), + } + end), + function(server, callback, context) + local c = process.chain { + cwd = path.concat { server.root_dir, "vala-language-server" }, + stdio_sink = context.stdio_sink, + } + + c.run("meson", { ("-Dprefix=%s"):format(server.root_dir), "build" }) + c.run("ninja", { "-C", "build", "install" }) + + c.spawn(callback) + end, + std.rmrf "vala-language-server", + }, + default_options = { + cmd = { path.concat { root_dir, "bin", "vala-language-server" } }, + }, + } +end |
