]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/rmz/util/lsp.lua
nvim: remove unused functions from rmz.util.lsp
[dotfiles.git] / nvim / lua / rmz / util / lsp.lua
index 662781cfebeafd9d711a33b2fc8195380f27dca2..70bcc2fe33cf8ac718926ccb19e82ee8273e3a70 100644 (file)
@@ -73,9 +73,6 @@ function M.on_attach(on_attach, name)
   })
 end
 
----@type table<string, table<vim.lsp.Client, table<number, boolean>>>
-M._supports_method = {}
-
 function M.setup()
   local register_capability = vim.lsp.handlers["client/registerCapability"]
   vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx)
@@ -92,36 +89,6 @@ function M.setup()
     end
     return ret
   end
-  M.on_attach(M._check_methods)
-  M.on_dynamic_capability(M._check_methods)
-end
-
----@param client vim.lsp.Client
-function M._check_methods(client, buffer)
-  -- don't trigger on invalid buffers
-  if not vim.api.nvim_buf_is_valid(buffer) then
-    return
-  end
-  -- don't trigger on non-listed buffers
-  if not vim.bo[buffer].buflisted then
-    return
-  end
-  -- don't trigger on nofile buffers
-  if vim.bo[buffer].buftype == "nofile" then
-    return
-  end
-  for method, clients in pairs(M._supports_method) do
-    clients[client] = clients[client] or {}
-    if not clients[client][buffer] then
-      if client.supports_method and client.supports_method(method, { bufnr = buffer }) then
-        clients[client][buffer] = true
-        vim.api.nvim_exec_autocmds("User", {
-          pattern = "LspSupportsMethod",
-          data = { client_id = client.id, buffer = buffer, method = method },
-        })
-      end
-    end
-  end
 end
 
 ---@param fn fun(client:vim.lsp.Client, buffer):boolean?
@@ -140,55 +107,6 @@ function M.on_dynamic_capability(fn, opts)
   })
 end
 
----@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
-
 M.action = setmetatable({}, {
   __index = function(_, action)
     return function()