diff options
| author | William Boman <william@redwill.se> | 2021-10-18 13:59:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-18 13:59:43 +0200 |
| commit | cee25503cd6df85366c5106c40cc5240634e647e (patch) | |
| tree | 6e242bc0b0c5a6c3e40b165323a6c1a9c20576a1 /lua/nvim-lsp-installer.lua | |
| parent | Remove the pdflatex check (#174) (diff) | |
| download | mason-cee25503cd6df85366c5106c40cc5240634e647e.tar mason-cee25503cd6df85366c5106c40cc5240634e647e.tar.gz mason-cee25503cd6df85366c5106c40cc5240634e647e.tar.bz2 mason-cee25503cd6df85366c5106c40cc5240634e647e.tar.lz mason-cee25503cd6df85366c5106c40cc5240634e647e.tar.xz mason-cee25503cd6df85366c5106c40cc5240634e647e.tar.zst mason-cee25503cd6df85366c5106c40cc5240634e647e.zip | |
speed up :LspInstall, :LspUninstall, :LspUninstallAll commands (#175)
- `:LspUninstallAll` now just nukes the entire install directory immediately,
instead of uninstalling each server one by one. There's also a confirmation
prompt now.
- `:LspInstall` & `:LspUninstall` now sources its autocompletion directly from
a Lua table, instead of sourcing the server names from each server module (thus
avoiding unnecessary `require` calls).
Diffstat (limited to 'lua/nvim-lsp-installer.lua')
| -rw-r--r-- | lua/nvim-lsp-installer.lua | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/lua/nvim-lsp-installer.lua b/lua/nvim-lsp-installer.lua index b05ac31c..5c41864d 100644 --- a/lua/nvim-lsp-installer.lua +++ b/lua/nvim-lsp-installer.lua @@ -1,9 +1,11 @@ +local fs = require "nvim-lsp-installer.fs" local notify = require "nvim-lsp-installer.notify" local dispatcher = require "nvim-lsp-installer.dispatcher" local process = require "nvim-lsp-installer.process" local status_win = require "nvim-lsp-installer.ui.status-win" local servers = require "nvim-lsp-installer.servers" local settings = require "nvim-lsp-installer.settings" +local log = require "nvim-lsp-installer.log" local M = {} @@ -33,18 +35,31 @@ function M.uninstall(server_name) end function M.uninstall_all() - local installed_servers = servers.get_installed_servers() - status_win().open() - if #installed_servers > 0 then - local function uninstall(idx) - status_win().uninstall_server(installed_servers[idx]) - if installed_servers[idx + 1] then - vim.schedule(function() - uninstall(idx + 1) - end) - end + local choice = vim.fn.confirm( + ("This will uninstall all servers currently installed at %q. Continue?"):format( + vim.fn.fnamemodify(settings.current.install_root_dir, ":~") + ), + "&Yes\n&No", + 2 + ) + if settings.current.install_root_dir ~= settings._DEFAULT_SETTINGS.install_root_dir then + choice = vim.fn.confirm( + ( + "WARNING: You are using a non-default install_root_dir (%q). This command will delete the entire directory. Continue?" + ):format(vim.fn.fnamemodify(settings.current.install_root_dir, ":~")), + "&Yes\n&No", + 2 + ) + end + if choice == 1 then + log.info "Uninstalling all servers." + if fs.dir_exists(settings.current.install_root_dir) then + fs.rmrf(settings.current.install_root_dir) end - uninstall(1) + status_win().mark_all_servers_uninstalled() + status_win().open() + else + print "Uninstalling all servers was aborted." end end |
