aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/core/managers/std
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-11 17:19:01 +0200
committerGitHub <noreply@github.com>2022-04-11 17:19:01 +0200
commit88f590ce0e01767bcc8dfdc862a456efde77d4a0 (patch)
tree2f5faaffa76b9147a873b2adc3286b6624144976 /lua/nvim-lsp-installer/core/managers/std
parentfix(verible): use correct unpacked directory name on Windows (#589) (diff)
downloadmason-88f590ce0e01767bcc8dfdc862a456efde77d4a0.tar
mason-88f590ce0e01767bcc8dfdc862a456efde77d4a0.tar.gz
mason-88f590ce0e01767bcc8dfdc862a456efde77d4a0.tar.bz2
mason-88f590ce0e01767bcc8dfdc862a456efde77d4a0.tar.lz
mason-88f590ce0e01767bcc8dfdc862a456efde77d4a0.tar.xz
mason-88f590ce0e01767bcc8dfdc862a456efde77d4a0.tar.zst
mason-88f590ce0e01767bcc8dfdc862a456efde77d4a0.zip
more async refactor (#587)
Diffstat (limited to 'lua/nvim-lsp-installer/core/managers/std')
-rw-r--r--lua/nvim-lsp-installer/core/managers/std/init.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/core/managers/std/init.lua b/lua/nvim-lsp-installer/core/managers/std/init.lua
new file mode 100644
index 00000000..49a7f53d
--- /dev/null
+++ b/lua/nvim-lsp-installer/core/managers/std/init.lua
@@ -0,0 +1,44 @@
+local a = require "nvim-lsp-installer.core.async"
+local installer = require "nvim-lsp-installer.core.installer"
+
+local M = {}
+
+local function with_system_executable_receipt(executable)
+ return function()
+ local ctx = installer.context()
+ ctx.receipt:with_primary_source(ctx.receipt.system(executable))
+ end
+end
+
+---@async
+---@param executable string
+---@param opts {help_url:string|nil}
+function M.system_executable(executable, opts)
+ return function()
+ M.ensure_executable(executable, opts).with_receipt()
+ end
+end
+
+---@async
+---@param executable string
+---@param opts {help_url:string|nil}
+function M.ensure_executable(executable, opts)
+ local ctx = installer.context()
+ opts = opts or {}
+ if vim.in_fast_event() then
+ a.scheduler()
+ end
+ if vim.fn.executable(executable) ~= 1 then
+ ctx.stdio_sink.stderr(("%s was not found in path.\n"):format(executable))
+ if opts.help_url then
+ ctx.stdio_sink.stderr(("See %s for installation instructions.\n"):format(opts.help_url))
+ end
+ error("Installation failed: system executable was not found.", 0)
+ end
+
+ return {
+ with_receipt = with_system_executable_receipt(executable),
+ }
+end
+
+return M