feat: use LazyVim everywhere instead of require("lazyvim.util")

This commit is contained in:
Folke Lemaitre
2024-03-22 09:15:09 +01:00
parent 3a87c08cda
commit 7a5dbeae75
41 changed files with 188 additions and 229 deletions

View File

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
return {
-- lspconfig
{
@ -95,22 +93,22 @@ return {
},
---@param opts PluginLspOpts
config = function(_, opts)
if Util.has("neoconf.nvim") then
if LazyVim.has("neoconf.nvim") then
local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"]
require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false))
end
-- setup autoformat
Util.format.register(Util.lsp.formatter())
LazyVim.format.register(LazyVim.lsp.formatter())
-- deprecated options
if opts.autoformat ~= nil then
vim.g.autoformat = opts.autoformat
Util.deprecate("nvim-lspconfig.opts.autoformat", "vim.g.autoformat")
LazyVim.deprecate("nvim-lspconfig.opts.autoformat", "vim.g.autoformat")
end
-- setup keymaps
Util.lsp.on_attach(function(client, buffer)
LazyVim.lsp.on_attach(function(client, buffer)
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
end)
@ -134,16 +132,16 @@ return {
-- inlay hints
if opts.inlay_hints.enabled then
Util.lsp.on_attach(function(client, buffer)
LazyVim.lsp.on_attach(function(client, buffer)
if client.supports_method("textDocument/inlayHint") then
Util.toggle.inlay_hints(buffer, true)
LazyVim.toggle.inlay_hints(buffer, true)
end
end)
end
-- code lens
if opts.codelens.enabled and vim.lsp.codelens then
Util.lsp.on_attach(function(client, buffer)
LazyVim.lsp.on_attach(function(client, buffer)
if client.supports_method("textDocument/codeLens") then
vim.lsp.codelens.refresh()
--- autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh()
@ -220,10 +218,10 @@ return {
mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } })
end
if Util.lsp.get_config("denols") and Util.lsp.get_config("tsserver") then
if LazyVim.lsp.get_config("denols") and LazyVim.lsp.get_config("tsserver") then
local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc")
Util.lsp.disable("tsserver", is_deno)
Util.lsp.disable("denols", function(root_dir)
LazyVim.lsp.disable("tsserver", is_deno)
LazyVim.lsp.disable("denols", function(root_dir)
return not is_deno(root_dir)
end)
end

View File

@ -41,7 +41,7 @@ function M.get()
has = "codeAction",
}
}
if require("lazyvim.util").has("inc-rename.nvim") then
if LazyVim.has("inc-rename.nvim") then
M._keys[#M._keys + 1] = {
"<leader>cr",
function()
@ -61,7 +61,7 @@ end
---@param method string
function M.has(buffer, method)
method = method:find("/") and method or "textDocument/" .. method
local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer })
local clients = LazyVim.lsp.get_clients({ bufnr = buffer })
for _, client in ipairs(clients) do
if client.supports_method(method) then
return true
@ -77,8 +77,8 @@ function M.resolve(buffer)
return {}
end
local spec = M.get()
local opts = require("lazyvim.util").opts("nvim-lspconfig")
local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer })
local opts = LazyVim.opts("nvim-lspconfig")
local clients = LazyVim.lsp.get_clients({ bufnr = buffer })
for _, client in ipairs(clients) do
local maps = opts.servers[client.name] and opts.servers[client.name].keys or {}
vim.list_extend(spec, maps)