diff options
| author | Harry Tran <huydtran19@gmail.com> | 2022-02-22 08:25:25 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-22 14:25:25 +0100 |
| commit | 43661e1485311102cabfb3afcd35cce54bae009f (patch) | |
| tree | 4d4b0be62a789db22cf40755b46529863af9982c /lua/nvim-lsp-installer/installers | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-43661e1485311102cabfb3afcd35cce54bae009f.tar mason-43661e1485311102cabfb3afcd35cce54bae009f.tar.gz mason-43661e1485311102cabfb3afcd35cce54bae009f.tar.bz2 mason-43661e1485311102cabfb3afcd35cce54bae009f.tar.lz mason-43661e1485311102cabfb3afcd35cce54bae009f.tar.xz mason-43661e1485311102cabfb3afcd35cce54bae009f.tar.zst mason-43661e1485311102cabfb3afcd35cce54bae009f.zip | |
add ocamllsp (#498)
Co-authored-by: William Boman <william@redwill.se>
Diffstat (limited to 'lua/nvim-lsp-installer/installers')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/opam.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/installers/opam.lua b/lua/nvim-lsp-installer/installers/opam.lua new file mode 100644 index 00000000..a161028a --- /dev/null +++ b/lua/nvim-lsp-installer/installers/opam.lua @@ -0,0 +1,53 @@ +local std = require "nvim-lsp-installer.installers.std" +local installers = require "nvim-lsp-installer.installers" +local process = require "nvim-lsp-installer.process" +local path = require "nvim-lsp-installer.path" +local Data = require "nvim-lsp-installer.data" + +local list_copy = Data.list_copy + +local M = {} + +---@param packages string[] The OPAM packages to install. The first item in this list will be the recipient of the server version, should the user request a specific one. +function M.packages(packages) + return installers.pipe { + std.ensure_executables { + { "opam", "opam was not found in path, refer to https://opam.ocaml.org/doc/Install.html" }, + }, + ---@type ServerInstallerFunction + function(_, callback, ctx) + local pkgs = list_copy(packages) + + ctx.receipt:with_primary_source(ctx.receipt.opam(pkgs[1])) + for i = 2, #pkgs do + ctx.receipt:with_secondary_source(ctx.receipt.opam(pkgs[i])) + end + + if ctx.requested_server_version then + pkgs[1] = ("%s.%s"):format(pkgs[1], ctx.requested_server_version) + end + + local install_args = { + "install", + ("--destdir=%s"):format(ctx.install_dir), + "--yes", + "--verbose", + } + vim.list_extend(install_args, pkgs) + + process.spawn("opam", { + args = install_args, + cwd = ctx.install_dir, + stdio_sink = ctx.stdio_sink, + }, callback) + end, + } +end + +function M.env(root_dir) + return { + PATH = process.extend_path { path.concat { root_dir, "bin" } }, + } +end + +return M |
