How can I automatically set up all LSP language servers

I have the following code in my Neovim Lua configuration which sets up all my Neovim language servers.

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
local lspconfig = require("lspconfig")

for _,server in pairs({ lspconfig.clangd, lspconfig.sumneko_lua, lspconfig.vimls, lspconfig.bashls }) do
	server.setup { capabilities = capabilities }
end

This is inconvenient because I have to change this code every time I install a new language server. It would be cool if there was a way to detect all of the language servers in require("lspconfig"). I tried the following.

for _,lsp in pairs(lspconfig) do
	for _,server in pairs(lsp) do
		server.setup { capabilities = capabilities }
	end
end

But it did not work as it gave me an error saying “expected table, got function”.