----@param method string
----@param fn fun(client:vim.lsp.Client, buffer)
-function M.on_supports_method(method, fn)
- M._supports_method[method] = M._supports_method[method] or setmetatable({}, { __mode = "k" })
- return vim.api.nvim_create_autocmd("User", {
- pattern = "LspSupportsMethod",
- callback = function(args)
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- local buffer = args.data.buffer ---@type number
- if client and method == args.data.method then
- return fn(client, buffer)
- end
- end,
- })
-end
-
----@return _.lspconfig.options
-function M.get_config(server)
- local configs = require("lspconfig.configs")
- return rawget(configs, server)
-end
-
----@return {default_config:lspconfig.Config}
-function M.get_raw_config(server)
- local ok, ret = pcall(require, "lspconfig.configs." .. server)
- if ok then
- return ret
- end
- return require("lspconfig.server_configurations." .. server)
-end
-
-function M.is_enabled(server)
- local c = M.get_config(server)
- return c and c.enabled ~= false
-end
-
----@param server string
----@param cond fun( root_dir, config): boolean
-function M.disable(server, cond)
- local util = require("lspconfig.util")
- local def = M.get_config(server)
- ---@diagnostic disable-next-line: undefined-field
- def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir)
- if cond(root_dir, config) then
- config.enabled = false
- end
- end)
-end
-