aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/installers
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-01-02 14:08:54 +0100
committerGitHub <noreply@github.com>2022-01-02 14:08:54 +0100
commit264d499bcdc3d48a76b0344ad243fc9a2d033142 (patch)
tree2789e83625186bd860dc40a7b37a8f4a2e7225f1 /lua/nvim-lsp-installer/installers
parenthealth: add java check (diff)
downloadmason-264d499bcdc3d48a76b0344ad243fc9a2d033142.tar
mason-264d499bcdc3d48a76b0344ad243fc9a2d033142.tar.gz
mason-264d499bcdc3d48a76b0344ad243fc9a2d033142.tar.bz2
mason-264d499bcdc3d48a76b0344ad243fc9a2d033142.tar.lz
mason-264d499bcdc3d48a76b0344ad243fc9a2d033142.tar.xz
mason-264d499bcdc3d48a76b0344ad243fc9a2d033142.tar.zst
mason-264d499bcdc3d48a76b0344ad243fc9a2d033142.zip
add taplo (#373)
Diffstat (limited to 'lua/nvim-lsp-installer/installers')
-rw-r--r--lua/nvim-lsp-installer/installers/cargo.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/installers/cargo.lua b/lua/nvim-lsp-installer/installers/cargo.lua
new file mode 100644
index 00000000..8f4bf0ed
--- /dev/null
+++ b/lua/nvim-lsp-installer/installers/cargo.lua
@@ -0,0 +1,30 @@
+local process = require "nvim-lsp-installer.process"
+local path = require "nvim-lsp-installer.path"
+
+local M = {}
+
+---@param crates string[] The crates to install.
+function M.crates(crates)
+ ---@type ServerInstallerFunction
+ return function(_, callback, ctx)
+ local args = { "install", "--root", ".", "--locked" }
+ if ctx.requested_server_version then
+ vim.list_extend(args, { "--version", ctx.requested_server_version })
+ end
+ vim.list_extend(args, crates)
+
+ process.spawn("cargo", {
+ cwd = ctx.install_dir,
+ args = args,
+ stdio_sink = ctx.stdio_sink,
+ }, callback)
+ end
+end
+
+---@param root_dir string The directory to resolve the executable from.
+---@param executable string
+function M.executable(root_dir, executable)
+ return path.concat { root_dir, "bin", executable }
+end
+
+return M