aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/installers
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-01-10 19:33:09 +0100
committerGitHub <noreply@github.com>2022-01-10 19:33:09 +0100
commit57398ee78d055b3fc566092c1a09ca8df9df1d71 (patch)
tree21fb975fb20ba5d28fab5559f399803ed0f778ae /lua/nvim-lsp-installer/installers
parentAdd OpenFOAM language server (#405) (diff)
downloadmason-57398ee78d055b3fc566092c1a09ca8df9df1d71.tar
mason-57398ee78d055b3fc566092c1a09ca8df9df1d71.tar.gz
mason-57398ee78d055b3fc566092c1a09ca8df9df1d71.tar.bz2
mason-57398ee78d055b3fc566092c1a09ca8df9df1d71.tar.lz
mason-57398ee78d055b3fc566092c1a09ca8df9df1d71.tar.xz
mason-57398ee78d055b3fc566092c1a09ca8df9df1d71.tar.zst
mason-57398ee78d055b3fc566092c1a09ca8df9df1d71.zip
add rnix (#408)
Diffstat (limited to 'lua/nvim-lsp-installer/installers')
-rw-r--r--lua/nvim-lsp-installer/installers/cargo.lua33
1 files changed, 33 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..11b69ea5
--- /dev/null
+++ b/lua/nvim-lsp-installer/installers/cargo.lua
@@ -0,0 +1,33 @@
+local process = require "nvim-lsp-installer.process"
+local path = require "nvim-lsp-installer.path"
+
+local M = {}
+
+---@param crate string The crate to install.
+function M.crate(crate)
+ ---@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, { crate })
+
+ ctx.receipt:with_primary_source(ctx.receipt.cargo(crate))
+
+ 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.
+function M.env(root_dir)
+ return {
+ PATH = process.extend_path { path.concat { root_dir, "bin" } },
+ }
+end
+
+return M