diff options
| author | William Boman <william@redwill.se> | 2021-09-07 02:44:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-07 02:44:09 +0200 |
| commit | 00294b84031711013a385f18c0fb0e8db84ebaf9 (patch) | |
| tree | e45de668229c6b41643c5d1fa0fdb5beb0ff60fa /lua/nvim-lsp-installer/installers/init.lua | |
| parent | lazily require servers for faster startup times (#77) (diff) | |
| download | mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.gz mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.bz2 mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.lz mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.xz mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.zst mason-00294b84031711013a385f18c0fb0e8db84ebaf9.zip | |
add direct integration with libuv instead of going through termopen, also implement a UI (#79)
* add direct integration with libuv instead of going through termopen, also implement a UI
* alleged free perf boosts
yo that's free cycles
Diffstat (limited to 'lua/nvim-lsp-installer/installers/init.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/init.lua | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/lua/nvim-lsp-installer/installers/init.lua b/lua/nvim-lsp-installer/installers/init.lua index f394a33d..991c773e 100644 --- a/lua/nvim-lsp-installer/installers/init.lua +++ b/lua/nvim-lsp-installer/installers/init.lua @@ -1,48 +1,57 @@ local platform = require "nvim-lsp-installer.platform" +local Data = require "nvim-lsp-installer.data" local M = {} -function M.compose(installers) +function M.join(installers) if #installers == 0 then - error "No installers to compose." + error "No installers to join." end - return function(server, callback) + return function(server, callback, context) local function execute(idx) - installers[idx](server, function(success, result) + installers[idx](server, function(success) if not success then -- oh no, error. exit early - callback(success, result) - elseif installers[idx - 1] then + callback(success) + elseif installers[idx + 1] then -- iterate - execute(idx - 1) + execute(idx + 1) else -- we done - callback(success, result) + callback(success) end - end) + end, context) end - execute(#installers) + execute(1) end end +-- much fp, very wow +function M.compose(installers) + return M.join(Data.list_reverse(installers)) +end + function M.when(platform_table) - return function(server, callback) + return function(server, callback, context) if platform.is_unix() then if platform_table.unix then - platform_table.unix(server, callback) + platform_table.unix(server, callback, context) else - callback(false, ("Unix is not yet supported for server %q."):format(server.name)) + context.stdio_sink.stderr(("Unix is not yet supported for server %q."):format(server.name)) + callback(false) end elseif platform.is_win() then if platform_table.win then - platform_table.win(server, callback) + platform_table.win(server, callback, context) else - callback(false, ("Windows is not yet supported for server %q."):format(server.name)) + context.stdio_sink.stderr(("Windows is not yet supported for server %q."):format(server.name)) + callback(false) end else - callback(false, "installers.when: Could not find installer for current platform.") + context.sdtio_sink.stderr "installers.when: Could not find installer for current platform." + callback(false) end end end |
