From b7c821c1e38ad7f52195186b0f5d17a6d64a55aa Mon Sep 17 00:00:00 2001 From: William Boman Date: Fri, 29 Oct 2021 19:26:49 +0200 Subject: add public API to close installer window (#208) --- lua/nvim-lsp-installer.lua | 17 ++++++++++++++++- lua/nvim-lsp-installer/installers/context.lua | 2 +- lua/nvim-lsp-installer/ui/status-win/init.lua | 9 ++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/nvim-lsp-installer.lua b/lua/nvim-lsp-installer.lua index 5253e654..d1ab5f20 100644 --- a/lua/nvim-lsp-installer.lua +++ b/lua/nvim-lsp-installer.lua @@ -12,8 +12,23 @@ local M = {} M.settings = settings.set ---- Opens the status window. +M.info_window = { + ---Opens the status window. + open = function() + status_win().open() + end, + ---Closes the status window. + close = function() + status_win().close() + end, +} + +---Deprecated. Use info_window.open(). function M.display() + notify( + "The lsp_installer.display() function has been deprecated. Use lsp_installer.info_window.open() instead.", + vim.log.levels.WARN + ) status_win().open() end diff --git a/lua/nvim-lsp-installer/installers/context.lua b/lua/nvim-lsp-installer/installers/context.lua index b5be573f..71f2f991 100644 --- a/lua/nvim-lsp-installer/installers/context.lua +++ b/lua/nvim-lsp-installer/installers/context.lua @@ -89,7 +89,7 @@ function M.use_github_release(repo) end ---@param repo string @The GitHub report ("username/repo"). ----@param file string @The name of a file availabine in the provided repo's GitHub releases. +---@param file string|fun(resolved_version: string): string @The name of a file available in the provided repo's GitHub releases. function M.use_github_release_file(repo, file) return installers.pipe { M.use_github_release(repo), diff --git a/lua/nvim-lsp-installer/ui/status-win/init.lua b/lua/nvim-lsp-installer/ui/status-win/init.lua index 887f6df1..d08536b6 100644 --- a/lua/nvim-lsp-installer/ui/status-win/init.lua +++ b/lua/nvim-lsp-installer/ui/status-win/init.lua @@ -729,6 +729,12 @@ local function init(all_servers) start_delay_ms = 1000, } + local function close() + if window then + window.close() + end + end + local function open() local open_filetypes = {} for _, open_bufnr in ipairs(vim.api.nvim_list_bufs()) do @@ -774,7 +780,7 @@ local function init(all_servers) end) end, ["CLOSE_WINDOW"] = function() - window.close() + close() end, ["TOGGLE_EXPAND_CURRENT_SETTINGS"] = function() mutate_state(function(state) @@ -814,6 +820,7 @@ local function init(all_servers) return { open = open, + close = close, install_server = install_server, uninstall_server = uninstall_server, mark_all_servers_uninstalled = mark_all_servers_uninstalled, -- cgit v1.2.3-70-g09d2