perf(util): closure for get_clients to prevent loading vim.lsp cascade early

This commit is contained in:
Folke Lemaitre 2023-10-08 20:22:47 +02:00
parent 3f67ac3c73
commit 1eac633c4f
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -3,6 +3,10 @@ local Util = require("lazy.core.util")
local M = {} local M = {}
M.root_patterns = { ".git", "lua" } M.root_patterns = { ".git", "lua" }
function M.get_clients(...)
local fn = vim.lsp.get_clients or vim.lsp.get_active_clients
return fn(...)
end
---@param on_attach fun(client, buffer) ---@param on_attach fun(client, buffer)
function M.on_attach(on_attach) function M.on_attach(on_attach)
@ -49,8 +53,6 @@ function M.opts(name)
return Plugin.values(plugin, "opts", false) return Plugin.values(plugin, "opts", false)
end end
M.get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients
-- returns the root directory based on: -- returns the root directory based on:
-- * lsp workspace folders -- * lsp workspace folders
-- * lsp root_dir -- * lsp root_dir