diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index b84130b6..5b087513 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -1,6 +1,4 @@ -local Util = require("lazyvim.util") - -_G.LazyVim = Util +_G.LazyVim = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} @@ -151,7 +149,7 @@ function M.json.load() if ok then M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {}) if M.json.data.version ~= M.json.version then - Util.json.migrate() + LazyVim.json.migrate() end end end @@ -180,12 +178,12 @@ function M.setup(opts) end M.load("keymaps") - Util.format.setup() - Util.news.setup() - Util.root.setup() + LazyVim.format.setup() + LazyVim.news.setup() + LazyVim.root.setup() vim.api.nvim_create_user_command("LazyExtras", function() - Util.extras.show() + LazyVim.extras.show() end, { desc = "Manage LazyVim extras" }) vim.api.nvim_create_user_command("LazyHealth", function() @@ -195,8 +193,8 @@ function M.setup(opts) end, }) - Util.track("colorscheme") - Util.try(function() + LazyVim.track("colorscheme") + LazyVim.try(function() if type(M.colorscheme) == "function" then M.colorscheme() else @@ -205,11 +203,11 @@ function M.setup(opts) end, { msg = "Could not load your colorscheme", on_error = function(msg) - Util.error(msg) + LazyVim.error(msg) vim.cmd.colorscheme("habamax") end, }) - Util.track() + LazyVim.track() end ---@param buf? number @@ -231,7 +229,7 @@ end function M.load(name) local function _load(mod) if require("lazy.core.cache").find(mod)[1] then - Util.try(function() + LazyVim.try(function() require(mod) end, { msg = "Failed loading " .. mod }) end @@ -261,19 +259,19 @@ function M.init() end package.preload["lazyvim.plugins.lsp.format"] = function() - Util.deprecate([[require("lazyvim.plugins.lsp.format")]], [[require("lazyvim.util").format]]) - return Util.format + LazyVim.deprecate([[require("lazyvim.plugins.lsp.format")]], [[LazyVim.format]]) + return LazyVim.format end -- delay notifications till vim.notify was replaced or after 500ms - require("lazyvim.util").lazy_notify() + LazyVim.lazy_notify() -- load options here, before lazy init while sourcing plugin modules -- this is needed to make sure options will be correctly applied -- after installing missing plugins M.load("options") - Util.plugin.setup() + LazyVim.plugin.setup() M.json.load() end diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index e6bbc2ab..e5790d8f 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -1,9 +1,8 @@ -- This file is automatically loaded by lazyvim.config.init -local Util = require("lazyvim.util") -- DO NOT USE THIS IN YOU OWN CONFIG!! -- use `vim.keymap.set` instead -local map = Util.safe_keymap_set +local map = LazyVim.safe_keymap_set -- better up/down map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) @@ -88,7 +87,7 @@ map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) -- formatting map({ "n", "v" }, "cf", function() - Util.format({ force = true }) + LazyVim.format({ force = true }) end, { desc = "Format" }) -- diagnostic @@ -110,28 +109,28 @@ map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) -- stylua: ignore start -- toggle options -map("n", "uf", function() Util.format.toggle() end, { desc = "Toggle auto format (global)" }) -map("n", "uF", function() Util.format.toggle(true) end, { desc = "Toggle auto format (buffer)" }) -map("n", "us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" }) -map("n", "uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" }) -map("n", "uL", function() Util.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) -map("n", "ul", function() Util.toggle.number() end, { desc = "Toggle Line Numbers" }) -map("n", "ud", function() Util.toggle.diagnostics() end, { desc = "Toggle Diagnostics" }) +map("n", "uf", function() LazyVim.format.toggle() end, { desc = "Toggle auto format (global)" }) +map("n", "uF", function() LazyVim.format.toggle(true) end, { desc = "Toggle auto format (buffer)" }) +map("n", "us", function() LazyVim.toggle("spell") end, { desc = "Toggle Spelling" }) +map("n", "uw", function() LazyVim.toggle("wrap") end, { desc = "Toggle Word Wrap" }) +map("n", "uL", function() LazyVim.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) +map("n", "ul", function() LazyVim.toggle.number() end, { desc = "Toggle Line Numbers" }) +map("n", "ud", function() LazyVim.toggle.diagnostics() end, { desc = "Toggle Diagnostics" }) local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3 -map("n", "uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" }) +map("n", "uc", function() LazyVim.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" }) if vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint then - map( "n", "uh", function() Util.toggle.inlay_hints() end, { desc = "Toggle Inlay Hints" }) + map( "n", "uh", function() LazyVim.toggle.inlay_hints() end, { desc = "Toggle Inlay Hints" }) end map("n", "uT", function() if vim.b.ts_highlight then vim.treesitter.stop() else vim.treesitter.start() end end, { desc = "Toggle Treesitter Highlight" }) -map("n", "ub", function() Util.toggle("background", false, {"light", "dark"}) end, { desc = "Toggle Background" }) +map("n", "ub", function() LazyVim.toggle("background", false, {"light", "dark"}) end, { desc = "Toggle Background" }) -- lazygit -map("n", "gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root.git(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) -map("n", "gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) +map("n", "gg", function() LazyVim.terminal({ "lazygit" }, { cwd = LazyVim.root.git(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) +map("n", "gG", function() LazyVim.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) map("n", "gf", function() local git_path = vim.api.nvim_buf_get_name(0) - Util.terminal({ "lazygit", "-f", vim.trim(git_path) }, { esc_esc = false, ctrl_hjkl = false }) + LazyVim.terminal({ "lazygit", "-f", vim.trim(git_path) }, { esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit current file history" }) -- quit @@ -141,12 +140,12 @@ map("n", "qq", "qa", { desc = "Quit all" }) map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) -- LazyVim Changelog -map("n", "L", function() Util.news.changelog() end, { desc = "LazyVim Changelog" }) +map("n", "L", function() LazyVim.news.changelog() end, { desc = "LazyVim Changelog" }) -- floating terminal -local lazyterm = function() Util.terminal(nil, { cwd = Util.root() }) end +local lazyterm = function() LazyVim.terminal(nil, { cwd = LazyVim.root() }) end map("n", "ft", lazyterm, { desc = "Terminal (root dir)" }) -map("n", "fT", function() Util.terminal() end, { desc = "Terminal (cwd)" }) +map("n", "fT", function() LazyVim.terminal() end, { desc = "Terminal (cwd)" }) map("n", "", lazyterm, { desc = "Terminal (root dir)" }) map("n", "", lazyterm, { desc = "which_key_ignore" }) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 6b30614d..6aec8b85 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -122,12 +122,11 @@ return { { "up", function() - local Util = require("lazy.core.util") vim.g.minipairs_disable = not vim.g.minipairs_disable if vim.g.minipairs_disable then - Util.warn("Disabled auto pairs", { title = "Option" }) + LazyVim.warn("Disabled auto pairs", { title = "Option" }) else - Util.info("Enabled auto pairs", { title = "Option" }) + LazyVim.info("Enabled auto pairs", { title = "Option" }) end end, desc = "Toggle auto pairs", @@ -238,7 +237,7 @@ return { config = function(_, opts) require("mini.ai").setup(opts) -- register all text objects with which-key - require("lazyvim.util").on_load("which-key.nvim", function() + LazyVim.on_load("which-key.nvim", function() ---@type table local i = { [" "] = "Whitespace", diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 805be479..73063a57 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- file explorer @@ -11,7 +9,7 @@ return { { "fe", function() - require("neo-tree.command").execute({ toggle = true, dir = Util.root() }) + require("neo-tree.command").execute({ toggle = true, dir = LazyVim.root() }) end, desc = "Explorer NeoTree (root dir)", }, @@ -82,7 +80,7 @@ return { }, config = function(_, opts) local function on_move(data) - Util.lsp.on_rename(data.source, data.destination) + LazyVim.lsp.on_rename(data.source, data.destination) end local events = require("neo-tree.events") @@ -129,7 +127,7 @@ return { build = "make", enabled = vim.fn.executable("make") == 1, config = function() - Util.on_load("telescope.nvim", function() + LazyVim.on_load("telescope.nvim", function() require("telescope").load_extension("fzf") end) end, @@ -141,17 +139,17 @@ return { "Telescope buffers sort_mru=true sort_lastused=true", desc = "Switch Buffer", }, - { "/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, + { "/", LazyVim.telescope("live_grep"), desc = "Grep (root dir)" }, { ":", "Telescope command_history", desc = "Command History" }, - { "", Util.telescope("files"), desc = "Find Files (root dir)" }, + { "", LazyVim.telescope("files"), desc = "Find Files (root dir)" }, -- find { "fb", "Telescope buffers sort_mru=true sort_lastused=true", desc = "Buffers" }, - { "fc", Util.telescope.config_files(), desc = "Find Config File" }, - { "ff", Util.telescope("files"), desc = "Find Files (root dir)" }, - { "fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, + { "fc", LazyVim.telescope.config_files(), desc = "Find Config File" }, + { "ff", LazyVim.telescope("files"), desc = "Find Files (root dir)" }, + { "fF", LazyVim.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, { "fg", "Telescope git_files", desc = "Find Files (git-files)" }, { "fr", "Telescope oldfiles", desc = "Recent" }, - { "fR", Util.telescope("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" }, + { "fR", LazyVim.telescope("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" }, -- git { "gc", "Telescope git_commits", desc = "commits" }, { "gs", "Telescope git_status", desc = "status" }, @@ -163,8 +161,8 @@ return { { "sC", "Telescope commands", desc = "Commands" }, { "sd", "Telescope diagnostics bufnr=0", desc = "Document diagnostics" }, { "sD", "Telescope diagnostics", desc = "Workspace diagnostics" }, - { "sg", Util.telescope("live_grep"), desc = "Grep (root dir)" }, - { "sG", Util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" }, + { "sg", LazyVim.telescope("live_grep"), desc = "Grep (root dir)" }, + { "sG", LazyVim.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" }, { "sh", "Telescope help_tags", desc = "Help Pages" }, { "sH", "Telescope highlights", desc = "Search Highlight Groups" }, { "sk", "Telescope keymaps", desc = "Key Maps" }, @@ -172,11 +170,11 @@ return { { "sm", "Telescope marks", desc = "Jump to Mark" }, { "so", "Telescope vim_options", desc = "Options" }, { "sR", "Telescope resume", desc = "Resume" }, - { "sw", Util.telescope("grep_string", { word_match = "-w" }), desc = "Word (root dir)" }, - { "sW", Util.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" }, - { "sw", Util.telescope("grep_string"), mode = "v", desc = "Selection (root dir)" }, - { "sW", Util.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" }, - { "uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" }, + { "sw", LazyVim.telescope("grep_string", { word_match = "-w" }), desc = "Word (root dir)" }, + { "sW", LazyVim.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" }, + { "sw", LazyVim.telescope("grep_string"), mode = "v", desc = "Selection (root dir)" }, + { "sW", LazyVim.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" }, + { "uC", LazyVim.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" }, { "ss", function() @@ -208,12 +206,12 @@ return { local find_files_no_ignore = function() local action_state = require("telescope.actions.state") local line = action_state.get_current_line() - Util.telescope("find_files", { no_ignore = true, default_text = line })() + LazyVim.telescope("find_files", { no_ignore = true, default_text = line })() end local find_files_with_hidden = function() local action_state = require("telescope.actions.state") local line = action_state.get_current_line() - Util.telescope("find_files", { hidden = true, default_text = line })() + LazyVim.telescope("find_files", { hidden = true, default_text = line })() end return { @@ -277,7 +275,7 @@ return { "nvim-telescope/telescope.nvim", optional = true, opts = function(_, opts) - if not Util.has("flash.nvim") then + if not LazyVim.has("flash.nvim") then return end local function flash(prompt_bufnr) diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua index a9f40624..b95ad433 100644 --- a/lua/lazyvim/plugins/extras/coding/codeium.lua +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -27,7 +27,7 @@ return { optional = true, event = "VeryLazy", opts = function(_, opts) - table.insert(opts.sections.lualine_x, 2, require("lazyvim.util").lualine.cmp_source("codeium")) + table.insert(opts.sections.lualine_x, 2, LazyVim.lualine.cmp_source("codeium")) end, }, } diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 279a974f..86c54a6e 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -19,12 +19,11 @@ return { optional = true, event = "VeryLazy", opts = function(_, opts) - local Util = require("lazyvim.util") local colors = { - [""] = Util.ui.fg("Special"), - ["Normal"] = Util.ui.fg("Special"), - ["Warning"] = Util.ui.fg("DiagnosticError"), - ["InProgress"] = Util.ui.fg("DiagnosticWarn"), + [""] = LazyVim.ui.fg("Special"), + ["Normal"] = LazyVim.ui.fg("Special"), + ["Warning"] = LazyVim.ui.fg("DiagnosticError"), + ["InProgress"] = LazyVim.ui.fg("DiagnosticWarn"), } table.insert(opts.sections.lualine_x, 2, { function() @@ -36,7 +35,7 @@ return { if not package.loaded["copilot"] then return end - local ok, clients = pcall(require("lazyvim.util").lsp.get_clients, { name = "copilot", bufnr = 0 }) + local ok, clients = pcall(LazyVim.lsp.get_clients, { name = "copilot", bufnr = 0 }) if not ok then return false end @@ -66,7 +65,7 @@ return { copilot_cmp.setup(opts) -- attach cmp source whenever copilot attaches -- fixes lazy-loading issues with the copilot cmp source - require("lazyvim.util").lsp.on_attach(function(client) + LazyVim.lsp.on_attach(function(client) if client.name == "copilot" then copilot_cmp._on_insert_enter({}) end diff --git a/lua/lazyvim/plugins/extras/coding/tabnine.lua b/lua/lazyvim/plugins/extras/coding/tabnine.lua index aac8519e..a255120e 100644 --- a/lua/lazyvim/plugins/extras/coding/tabnine.lua +++ b/lua/lazyvim/plugins/extras/coding/tabnine.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- Tabnine cmp source { @@ -8,7 +6,7 @@ return { { "tzachar/cmp-tabnine", build = { - Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh", + LazyVim.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh", ":CmpTabnineHub", }, dependencies = "hrsh7th/nvim-cmp", @@ -30,7 +28,7 @@ return { priority = 100, }) - opts.formatting.format = Util.inject.args(opts.formatting.format, function(entry, item) + opts.formatting.format = LazyVim.inject.args(opts.formatting.format, function(entry, item) -- Hide percentage in the menu if entry.source.name == "cmp_tabnine" then item.menu = "" @@ -45,7 +43,7 @@ return { event = "VeryLazy", opts = function(_, opts) local icon = require("lazyvim.config").icons.kinds.TabNine - table.insert(opts.sections.lualine_x, 2, require("lazyvim.util").lualine.cmp_source("cmp_tabnine", icon)) + table.insert(opts.sections.lualine_x, 2, LazyVim.lualine.cmp_source("cmp_tabnine", icon)) end, }, } diff --git a/lua/lazyvim/plugins/extras/editor/aerial.lua b/lua/lazyvim/plugins/extras/editor/aerial.lua index 440c9fda..15a209ba 100644 --- a/lua/lazyvim/plugins/extras/editor/aerial.lua +++ b/lua/lazyvim/plugins/extras/editor/aerial.lua @@ -1,5 +1,4 @@ local Config = require("lazyvim.config") -local Util = require("lazyvim.util") return { desc = "Aerial Symbol Browser", @@ -55,7 +54,7 @@ return { "nvim-telescope/telescope.nvim", optional = true, opts = function() - Util.on_load("telescope.nvim", function() + LazyVim.on_load("telescope.nvim", function() require("telescope").load_extension("aerial") end) end, @@ -73,11 +72,11 @@ return { "folke/edgy.nvim", optional = true, opts = function(_, opts) - local edgy_idx = Util.plugin.extra_idx("ui.edgy") - local aerial_idx = Util.plugin.extra_idx("editor.aerial") + local edgy_idx = LazyVim.plugin.extra_idx("ui.edgy") + local aerial_idx = LazyVim.plugin.extra_idx("editor.aerial") if edgy_idx and edgy_idx > aerial_idx then - Util.warn("The `edgy.nvim` extra must be **imported** before the `aerial.nvim` extra to work properly.", { + LazyVim.warn("The `edgy.nvim` extra must be **imported** before the `aerial.nvim` extra to work properly.", { title = "LazyVim", }) end diff --git a/lua/lazyvim/plugins/extras/editor/mini-files.lua b/lua/lazyvim/plugins/extras/editor/mini-files.lua index 1d6dd560..cc829bb5 100644 --- a/lua/lazyvim/plugins/extras/editor/mini-files.lua +++ b/lua/lazyvim/plugins/extras/editor/mini-files.lua @@ -57,7 +57,7 @@ return { vim.api.nvim_create_autocmd("User", { pattern = "MiniFilesActionRename", callback = function(event) - require("lazyvim.util").lsp.on_rename(event.data.from, event.data.to) + LazyVim.lsp.on_rename(event.data.from, event.data.to) end, }) end, diff --git a/lua/lazyvim/plugins/extras/editor/navic.lua b/lua/lazyvim/plugins/extras/editor/navic.lua index 359c42d4..ad31d575 100644 --- a/lua/lazyvim/plugins/extras/editor/navic.lua +++ b/lua/lazyvim/plugins/extras/editor/navic.lua @@ -7,7 +7,7 @@ return { lazy = true, init = function() vim.g.navic_silence = true - require("lazyvim.util").lsp.on_attach(function(client, buffer) + LazyVim.lsp.on_attach(function(client, buffer) if client.supports_method("textDocument/documentSymbol") then require("nvim-navic").attach(client, buffer) end diff --git a/lua/lazyvim/plugins/extras/editor/outline.lua b/lua/lazyvim/plugins/extras/editor/outline.lua index 841bf288..c571d789 100644 --- a/lua/lazyvim/plugins/extras/editor/outline.lua +++ b/lua/lazyvim/plugins/extras/editor/outline.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { { "hedyhli/outline.nvim", @@ -37,11 +35,11 @@ return { "folke/edgy.nvim", optional = true, opts = function(_, opts) - local edgy_idx = Util.plugin.extra_idx("ui.edgy") - local symbols_idx = Util.plugin.extra_idx("editor.outline") + local edgy_idx = LazyVim.plugin.extra_idx("ui.edgy") + local symbols_idx = LazyVim.plugin.extra_idx("editor.outline") if edgy_idx and edgy_idx > symbols_idx then - Util.warn( + LazyVim.warn( "The `edgy.nvim` extra must be **imported** before the `outline.nvim` extra to work properly.", { title = "LazyVim" } ) diff --git a/lua/lazyvim/plugins/extras/lang/clangd.lua b/lua/lazyvim/plugins/extras/lang/clangd.lua index 08017700..7705360d 100644 --- a/lua/lazyvim/plugins/extras/lang/clangd.lua +++ b/lua/lazyvim/plugins/extras/lang/clangd.lua @@ -85,7 +85,7 @@ return { }, setup = { clangd = function(_, opts) - local clangd_ext_opts = require("lazyvim.util").opts("clangd_extensions.nvim") + local clangd_ext_opts = LazyVim.opts("clangd_extensions.nvim") require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts })) return false end, diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index c6b18093..036eab6f 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -61,7 +61,7 @@ return { gopls = function(_, opts) -- workaround for gopls not supporting semanticTokensProvider -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 - require("lazyvim.util").lsp.on_attach(function(client, _) + LazyVim.lsp.on_attach(function(client, _) if client.name == "gopls" then if not client.server_capabilities.semanticTokensProvider then local semantic = client.config.capabilities.textDocument.semanticTokens diff --git a/lua/lazyvim/plugins/extras/lang/helm.lua b/lua/lazyvim/plugins/extras/lang/helm.lua index 8af1b512..3f1fe00d 100644 --- a/lua/lazyvim/plugins/extras/lang/helm.lua +++ b/lua/lazyvim/plugins/extras/lang/helm.lua @@ -1,4 +1,4 @@ -require("lazyvim.util").lsp.on_attach(function(client, buffer) +LazyVim.lsp.on_attach(function(client, buffer) if client.name == "yamlls" then if vim.api.nvim_get_option_value("filetype", { buf = buffer }) == "helm" then vim.schedule(function() diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index fcc35b07..a3b529b5 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - -- This is the same as in lspconfig.server_configurations.jdtls, but avoids -- needing to require that when this module loads. local java_filetypes = { "java" } @@ -109,13 +107,13 @@ return { } end, config = function() - local opts = Util.opts("nvim-jdtls") or {} + local opts = LazyVim.opts("nvim-jdtls") or {} -- Find the extra bundles that should be passed on the jdtls command-line -- if nvim-dap is enabled with java debug/test. local mason_registry = require("mason-registry") local bundles = {} ---@type string[] - if opts.dap and Util.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then + if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then local java_dbg_pkg = mason_registry.get_package("java-debug-adapter") local java_dbg_path = java_dbg_pkg:get_install_path() local jar_patterns = { @@ -196,7 +194,7 @@ return { }, }, { mode = "v", buffer = args.buf }) - if opts.dap and Util.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then + if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then -- custom init for Java debugger require("jdtls").setup_dap(opts.dap) require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main) diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index f5948903..104b664b 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -43,7 +43,7 @@ return { }, setup = { ruff_lsp = function() - require("lazyvim.util").lsp.on_attach(function(client, _) + LazyVim.lsp.on_attach(function(client, _) if client.name == "ruff_lsp" then -- Disable hover in favor of Pyright client.server_capabilities.hoverProvider = false @@ -89,7 +89,7 @@ return { "linux-cultist/venv-selector.nvim", cmd = "VenvSelect", opts = function(_, opts) - if require("lazyvim.util").has("nvim-dap-python") then + if LazyVim.has("nvim-dap-python") then opts.dap_enabled = true end return vim.tbl_deep_extend("force", opts, { diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index faa3c1e1..b199b4f1 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { { "nvim-treesitter/nvim-treesitter", @@ -58,7 +56,7 @@ return { { "ANGkeith/telescope-terraform-doc.nvim", config = function() - Util.on_load("telescope.nvim", function() + LazyVim.on_load("telescope.nvim", function() require("telescope").load_extension("terraform_doc") end) end, @@ -66,7 +64,7 @@ return { { "cappyzawa/telescope-terraform.nvim", config = function() - Util.on_load("telescope.nvim", function() + LazyVim.on_load("telescope.nvim", function() require("telescope").load_extension("terraform") end) end, diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua index 5afe1b83..9fd88a3b 100644 --- a/lua/lazyvim/plugins/extras/lang/yaml.lua +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -64,7 +64,7 @@ return { yamlls = function() -- Neovim < 0.10 does not have dynamic registration for formatting if vim.fn.has("nvim-0.10") == 0 then - require("lazyvim.util").lsp.on_attach(function(client, _) + LazyVim.lsp.on_attach(function(client, _) if client.name == "yamlls" then client.server_capabilities.documentFormattingProvider = true end diff --git a/lua/lazyvim/plugins/extras/lazyrc.lua b/lua/lazyvim/plugins/extras/lazyrc.lua index 4ae88441..24d06b51 100644 --- a/lua/lazyvim/plugins/extras/lazyrc.lua +++ b/lua/lazyvim/plugins/extras/lazyrc.lua @@ -23,11 +23,10 @@ vim.api.nvim_create_autocmd("User", { once = true, callback = function() local Config = require("lazy.core.config") - local Util = require("lazyvim.util") - local lazyrc_idx = Util.plugin.extra_idx("lazyrc") + local lazyrc_idx = LazyVim.plugin.extra_idx("lazyrc") if lazyrc_idx and lazyrc_idx ~= #Config.spec.modules then - Util.warn({ + LazyVim.warn({ "The `lazyrc` extra must be the last plugin spec added to **lazy.nvim**. ", "", "Add `{ import = 'lazyvim.plugins.extras.lazyrc' }` to file `config.lazy`. ", diff --git a/lua/lazyvim/plugins/extras/linting/eslint.lua b/lua/lazyvim/plugins/extras/linting/eslint.lua index a92a2191..df6e79dd 100644 --- a/lua/lazyvim/plugins/extras/linting/eslint.lua +++ b/lua/lazyvim/plugins/extras/linting/eslint.lua @@ -15,10 +15,10 @@ return { setup = { eslint = function() local function get_client(buf) - return require("lazyvim.util").lsp.get_clients({ name = "eslint", bufnr = buf })[1] + return LazyVim.lsp.get_clients({ name = "eslint", bufnr = buf })[1] end - local formatter = require("lazyvim.util").lsp.formatter({ + local formatter = LazyVim.lsp.formatter({ name = "eslint: lsp", primary = false, priority = 200, @@ -44,7 +44,7 @@ return { end -- register the formatter with LazyVim - require("lazyvim.util").format.register(formatter) + LazyVim.format.register(formatter) end, }, }, diff --git a/lua/lazyvim/plugins/extras/lsp/none-ls.lua b/lua/lazyvim/plugins/extras/lsp/none-ls.lua index aa907b8e..40651e2d 100644 --- a/lua/lazyvim/plugins/extras/lsp/none-ls.lua +++ b/lua/lazyvim/plugins/extras/lsp/none-ls.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- none-ls { @@ -7,14 +5,14 @@ return { event = "LazyFile", dependencies = { "mason.nvim" }, init = function() - Util.on_very_lazy(function() + LazyVim.on_very_lazy(function() -- register the formatter with LazyVim - require("lazyvim.util").format.register({ + LazyVim.format.register({ name = "none-ls.nvim", priority = 200, -- set higher than conform, the builtin formatter primary = true, format = function(buf) - return Util.lsp.format({ + return LazyVim.lsp.format({ bufnr = buf, filter = function(client) return client.name == "null-ls" diff --git a/lua/lazyvim/plugins/extras/test/core.lua b/lua/lazyvim/plugins/extras/test/core.lua index 5554b6af..e7dbd792 100644 --- a/lua/lazyvim/plugins/extras/test/core.lua +++ b/lua/lazyvim/plugins/extras/test/core.lua @@ -27,7 +27,7 @@ return { output = { open_on_run = true }, quickfix = { open = function() - if require("lazyvim.util").has("trouble.nvim") then + if LazyVim.has("trouble.nvim") then require("trouble").open({ mode = "quickfix", focus = false }) else vim.cmd("copen") @@ -47,7 +47,7 @@ return { }, }, neotest_ns) - if require("lazyvim.util").has("trouble.nvim") then + if LazyVim.has("trouble.nvim") then opts.consumers = opts.consumers or {} -- Refresh and auto close trouble after running tests ---@type neotest.Consumer diff --git a/lua/lazyvim/plugins/extras/util/gitui.lua b/lua/lazyvim/plugins/extras/util/gitui.lua index 5c519ba4..53869c33 100644 --- a/lua/lazyvim/plugins/extras/util/gitui.lua +++ b/lua/lazyvim/plugins/extras/util/gitui.lua @@ -6,12 +6,12 @@ return { keys = { { "gG", function() - require("lazyvim.util").terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false }) + LazyVim.terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false }) end, desc = "gitui (cwd)" }, { "gg", function() - require("lazyvim.util").terminal.open({ "gitui" }, { cwd = require("lazyvim.util").root.get(), esc_esc = false, ctrl_hjkl = false }) + LazyVim.terminal.open({ "gitui" }, { cwd = LazyVim.root.get(), esc_esc = false, ctrl_hjkl = false }) end, desc = "gitui (root dir)" } }, diff --git a/lua/lazyvim/plugins/extras/util/project.lua b/lua/lazyvim/plugins/extras/util/project.lua index 3936c96a..16e72077 100644 --- a/lua/lazyvim/plugins/extras/util/project.lua +++ b/lua/lazyvim/plugins/extras/util/project.lua @@ -11,7 +11,7 @@ return { event = "VeryLazy", config = function(_, opts) require("project_nvim").setup(opts) - require("lazyvim.util").on_load("telescope.nvim", function() + LazyVim.on_load("telescope.nvim", function() require("telescope").load_extension("projects") end) end, diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index d1c9a34c..718cb0f9 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - local M = {} ---@param opts ConformOpts @@ -10,14 +8,17 @@ function M.setup(_, opts) if formatter.extra_args then ---@diagnostic disable-next-line: undefined-field formatter.prepend_args = formatter.extra_args - Util.deprecate(("opts.formatters.%s.extra_args"):format(name), ("opts.formatters.%s.prepend_args"):format(name)) + LazyVim.deprecate( + ("opts.formatters.%s.extra_args"):format(name), + ("opts.formatters.%s.prepend_args"):format(name) + ) end end end for _, key in ipairs({ "format_on_save", "format_after_save" }) do if opts[key] then - Util.warn( + LazyVim.warn( ("Don't set `opts.%s` for `conform.nvim`.\n**LazyVim** will use the conform formatter automatically"):format( key ) @@ -47,8 +48,8 @@ return { }, init = function() -- Install the conform formatter on VeryLazy - require("lazyvim.util").on_very_lazy(function() - require("lazyvim.util").format.register({ + LazyVim.on_very_lazy(function() + LazyVim.format.register({ name = "conform.nvim", priority = 100, primary = true, @@ -56,7 +57,7 @@ return { local plugin = require("lazy.core.config").plugins["conform.nvim"] local Plugin = require("lazy.core.plugin") local opts = Plugin.values(plugin, "opts", false) - require("conform").format(Util.merge({}, opts.format, { bufnr = buf })) + require("conform").format(LazyVim.merge({}, opts.format, { bufnr = buf })) end, sources = function(buf) local ret = require("conform").list_formatters(buf) @@ -71,7 +72,7 @@ return { opts = function() local plugin = require("lazy.core.config").plugins["conform.nvim"] if plugin.config ~= M.setup then - Util.error({ + LazyVim.error({ "Don't set `plugin.config` for `conform.nvim`.\n", "This will break **LazyVim** formatting.\n", "Please refer to the docs at https://www.lazyvim.org/plugins/formatting", diff --git a/lua/lazyvim/plugins/linting.lua b/lua/lazyvim/plugins/linting.lua index b9b83165..caeaf6ec 100644 --- a/lua/lazyvim/plugins/linting.lua +++ b/lua/lazyvim/plugins/linting.lua @@ -27,8 +27,6 @@ return { }, }, config = function(_, opts) - local Util = require("lazyvim.util") - local M = {} local lint = require("lint") @@ -73,7 +71,7 @@ return { names = vim.tbl_filter(function(name) local linter = lint.linters[name] if not linter then - Util.warn("Linter not found: " .. name, { title = "nvim-lint" }) + LazyVim.warn("Linter not found: " .. name, { title = "nvim-lint" }) end return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) end, names) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 86f9d7e4..f353e28b 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -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 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 diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index 3e8976bb..0f5aecb7 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -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] = { "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) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 7e4dd40a..30130dc6 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -124,13 +124,12 @@ return { { "ut", function() - local Util = require("lazyvim.util") local tsc = require("treesitter-context") tsc.toggle() - if Util.inject.get_upvalue(tsc.toggle, "enabled") then - Util.info("Enabled Treesitter Context", { title = "Option" }) + if LazyVim.inject.get_upvalue(tsc.toggle, "enabled") then + LazyVim.info("Enabled Treesitter Context", { title = "Option" }) else - Util.warn("Disabled Treesitter Context", { title = "Option" }) + LazyVim.warn("Disabled Treesitter Context", { title = "Option" }) end end, desc = "Toggle Treesitter Context", diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 2a5e5e3e..d77b3293 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- Better `vim.notify()` { @@ -27,8 +25,8 @@ return { }, init = function() -- when noice is not enabled, install notify on VeryLazy - if not Util.has("noice.nvim") then - Util.on_very_lazy(function() + if not LazyVim.has("noice.nvim") then + LazyVim.on_very_lazy(function() vim.notify = require("notify") end) end @@ -140,7 +138,7 @@ return { lualine_b = { "branch" }, lualine_c = { - Util.lualine.root_dir(), + LazyVim.lualine.root_dir(), { "diagnostics", symbols = { @@ -151,31 +149,31 @@ return { }, }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { Util.lualine.pretty_path() }, + { LazyVim.lualine.pretty_path() }, }, lualine_x = { -- stylua: ignore { function() return require("noice").api.status.command.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, - color = Util.ui.fg("Statement"), + color = LazyVim.ui.fg("Statement"), }, -- stylua: ignore { function() return require("noice").api.status.mode.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, - color = Util.ui.fg("Constant"), + color = LazyVim.ui.fg("Constant"), }, -- stylua: ignore { function() return " " .. require("dap").status() end, cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, - color = Util.ui.fg("Debug"), + color = LazyVim.ui.fg("Debug"), }, { require("lazy.status").updates, cond = require("lazy.status").has_updates, - color = Util.ui.fg("Special"), + color = LazyVim.ui.fg("Special"), }, { "diff", @@ -278,7 +276,7 @@ return { { "folke/which-key.nvim", opts = function(_, opts) - if require("lazyvim.util").has("noice.nvim") then + if LazyVim.has("noice.nvim") then opts.defaults["sn"] = { name = "+noice" } end end, @@ -338,7 +336,7 @@ return { "goolord/alpha-nvim", optional = true, enabled = function() - require("lazyvim.util").warn({ + LazyVim.warn({ "`dashboard.nvim` is now the default LazyVim starter plugin.", "", "To keep using `alpha.nvim`, please enable the `lazyvim.plugins.extras.ui.alpha` extra.", @@ -373,11 +371,11 @@ return { header = vim.split(logo, "\n"), -- stylua: ignore center = { - { action = Util.telescope("files"), desc = " Find file", icon = " ", key = "f" }, + { action = LazyVim.telescope("files"), desc = " Find file", icon = " ", key = "f" }, { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, - { action = [[lua require("lazyvim.util").telescope.config_files()()]], desc = " Config", icon = " ", key = "c" }, + { action = [[lua LazyVim.telescope.config_files()()]], desc = " Config", icon = " ", key = "c" }, { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "x" }, { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua index a75c8413..74ab4b4c 100644 --- a/lua/lazyvim/util/extras.lua +++ b/lua/lazyvim/util/extras.lua @@ -3,7 +3,6 @@ local Float = require("lazy.view.float") local LazyConfig = require("lazy.core.config") local Plugin = require("lazy.core.plugin") local Text = require("lazy.view.text") -local Util = require("lazyvim.util") ---@class LazyExtraSource ---@field name string @@ -39,9 +38,9 @@ function M.get() M.state = M.state or LazyConfig.spec.modules local extras = {} ---@type LazyExtra[] for _, source in ipairs(M.sources) do - local root = Util.find_root(source.module) + local root = LazyVim.find_root(source.module) if root then - Util.walk(root, function(path, name, type) + LazyVim.walk(root, function(path, name, type) if (type == "file" or type == "link") and name:match("%.lua$") then name = path:sub(#root + 2, -5):gsub("/", ".") local ok, extra = pcall(M.get_extra, source, source.module .. "." .. name) @@ -119,7 +118,7 @@ function X:toggle() for _, extra in ipairs(self.extras) do if extra.row == pos[1] then if not extra.managed then - Util.error( + LazyVim.error( "Not managed by LazyExtras. Remove from your config to enable/disable here.", { title = "LazyExtras" } ) @@ -137,8 +136,8 @@ function X:toggle() M.state[#M.state + 1] = extra.module end table.sort(Config.json.data.extras) - Util.json.save() - Util.info( + LazyVim.json.save() + LazyVim.info( "`" .. extra.name .. "`" diff --git a/lua/lazyvim/util/format.lua b/lua/lazyvim/util/format.lua index fa972296..e6325538 100644 --- a/lua/lazyvim/util/format.lua +++ b/lua/lazyvim/util/format.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.format ---@overload fun(opts?: {force?:boolean}) local M = setmetatable({}, { @@ -26,7 +24,7 @@ function M.register(formatter) end function M.formatexpr() - if Util.has("conform.nvim") then + if LazyVim.has("conform.nvim") then return require("conform").formatexpr() end return vim.lsp.formatexpr({ timeout_ms = 3000 }) @@ -76,7 +74,7 @@ function M.info(buf) if not have then lines[#lines + 1] = "\n***No formatters available for this buffer.***" end - Util[enabled and "info" or "warn"]( + LazyVim[enabled and "info" or "warn"]( table.concat(lines, "\n"), { title = "LazyFormat (" .. (enabled and "enabled" or "disabled") .. ")" } ) @@ -120,14 +118,14 @@ function M.format(opts) for _, formatter in ipairs(M.resolve(buf)) do if formatter.active then done = true - Util.try(function() + LazyVim.try(function() return formatter.format(buf) end, { msg = "Formatter `" .. formatter.name .. "` failed" }) end end if not done and opts and opts.force then - Util.warn("No formatter available", { title = "LazyVim" }) + LazyVim.warn("No formatter available", { title = "LazyVim" }) end end @@ -136,7 +134,7 @@ function M.health() local has_plugin = Config.spec.plugins["none-ls.nvim"] local has_extra = vim.tbl_contains(Config.spec.modules, "lazyvim.plugins.extras.lsp.none-ls") if has_plugin and not has_extra then - Util.warn({ + LazyVim.warn({ "`conform.nvim` and `nvim-lint` are now the default formatters and linters in LazyVim.", "", "You can use those plugins together with `none-ls.nvim`,", diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 54c8706c..4de0d3e7 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -38,7 +38,7 @@ setmetatable(M, { if dep then local mod = type(dep) == "table" and dep[1] or dep local key = type(dep) == "table" and dep[2] or k - M.deprecate([[require("lazyvim.util").]] .. k, [[require("lazyvim.util").]] .. mod .. "." .. key) + M.deprecate([[LazyVim.]] .. k, [[LazyVim.]] .. mod .. "." .. key) ---@diagnostic disable-next-line: no-unknown t[mod] = require("lazyvim.util." .. mod) -- load here to prevent loops return t[mod][key] diff --git a/lua/lazyvim/util/json.lua b/lua/lazyvim/util/json.lua index 83aee5a3..3df7aecd 100644 --- a/lua/lazyvim/util/json.lua +++ b/lua/lazyvim/util/json.lua @@ -1,5 +1,4 @@ local Config = require("lazyvim.config") -local Util = require("lazyvim.util") ---@class lazyvim.util.json local M = {} @@ -14,7 +13,7 @@ local function encode(value, indent) elseif t == "number" or t == "boolean" then return tostring(value) elseif t == "table" then - local is_list = Util.is_list(value) + local is_list = LazyVim.is_list(value) local parts = {} local next_indent = indent .. " " @@ -51,13 +50,13 @@ function M.save() local path = vim.fn.stdpath("config") .. "/lazyvim.json" local f = io.open(path, "w") if f then - f:write(Util.json.encode(Config.json.data)) + f:write(LazyVim.json.encode(Config.json.data)) f:close() end end function M.migrate() - Util.info("Migrating `lazyvim.json` to version `" .. Config.json.version .. "`") + LazyVim.info("Migrating `lazyvim.json` to version `" .. Config.json.version .. "`") local json = Config.json -- v0 diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua index d9ef04e6..e712120a 100644 --- a/lua/lazyvim/util/lsp.lua +++ b/lua/lazyvim/util/lsp.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.lsp local M = {} @@ -87,10 +85,10 @@ function M.formatter(opts) primary = true, priority = 1, format = function(buf) - M.format(Util.merge({}, filter, { bufnr = buf })) + M.format(LazyVim.merge({}, filter, { bufnr = buf })) end, sources = function(buf) - local clients = M.get_clients(Util.merge({}, filter, { bufnr = buf })) + local clients = M.get_clients(LazyVim.merge({}, filter, { bufnr = buf })) ---@param client lsp.Client local ret = vim.tbl_filter(function(client) return client.supports_method("textDocument/formatting") @@ -102,7 +100,7 @@ function M.formatter(opts) end, ret) end, } - return Util.merge(ret, opts) --[[@as LazyFormatter]] + return LazyVim.merge(ret, opts) --[[@as LazyFormatter]] end ---@alias lsp.Client.format {timeout_ms?: number, format_options?: table} | lsp.Client.filter @@ -113,8 +111,8 @@ function M.format(opts) "force", {}, opts or {}, - require("lazyvim.util").opts("nvim-lspconfig").format or {}, - require("lazyvim.util").opts("conform.nvim").format or {} + LazyVim.opts("nvim-lspconfig").format or {}, + LazyVim.opts("conform.nvim").format or {} ) local ok, conform = pcall(require, "conform") -- use conform for formatting with LSP when available, diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index b4ffd633..db4600f4 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.lualine local M = {} @@ -25,9 +23,9 @@ function M.cmp_source(name, icon) end local colors = { - ok = Util.ui.fg("Special"), - error = Util.ui.fg("DiagnosticError"), - pending = Util.ui.fg("DiagnosticWarn"), + ok = LazyVim.ui.fg("Special"), + error = LazyVim.ui.fg("DiagnosticError"), + pending = LazyVim.ui.fg("DiagnosticWarn"), } return { @@ -90,8 +88,8 @@ function M.pretty_path(opts) return "" end - local root = Util.root.get({ normalize = true }) - local cwd = Util.root.cwd() + local root = LazyVim.root.get({ normalize = true }) + local cwd = LazyVim.root.cwd() if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then path = path:sub(#cwd + 2) @@ -130,12 +128,12 @@ function M.root_dir(opts) parent = true, other = true, icon = "󱉭 ", - color = Util.ui.fg("Special"), + color = LazyVim.ui.fg("Special"), }, opts or {}) local function get() - local cwd = Util.root.cwd() - local root = Util.root.get({ normalize = true }) + local cwd = LazyVim.root.cwd() + local root = LazyVim.root.get({ normalize = true }) local name = vim.fs.basename(root) if root == cwd then diff --git a/lua/lazyvim/util/news.lua b/lua/lazyvim/util/news.lua index ae71e67c..5434649a 100644 --- a/lua/lazyvim/util/news.lua +++ b/lua/lazyvim/util/news.lua @@ -1,5 +1,4 @@ local Config = require("lazyvim.config") -local Util = require("lazyvim.util") ---@class lazyvim.util.news local M = {} @@ -27,7 +26,7 @@ function M.setup() end function M.welcome() - Util.info("Welcome to LazyVim!") + LazyVim.info("Welcome to LazyVim!") end function M.changelog() @@ -50,7 +49,7 @@ function M.open(file, opts) if opts.plugin then local plugin = require("lazy.core.config").plugins[opts.plugin] --[[@as LazyPlugin?]] if not plugin then - return Util.error("plugin not found: " .. opts.plugin) + return LazyVim.error("plugin not found: " .. opts.plugin) end file = plugin.dir .. "/" .. file elseif opts.rtp then @@ -58,7 +57,7 @@ function M.open(file, opts) end if not file then - return Util.error("File not found") + return LazyVim.error("File not found") end if opts.when_changed then @@ -68,7 +67,7 @@ function M.open(file, opts) return end Config.json.data.news[ref] = hash - Util.json.save() + LazyVim.json.save() -- don't open if file has never been opened if is_new then return diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index 7ab69134..a8e784b6 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -1,5 +1,4 @@ local Plugin = require("lazy.core.plugin") -local Util = require("lazyvim.util") ---@class lazyvim.util.plugin local M = {} @@ -35,7 +34,7 @@ function M.setup() M.lazy_file() table.insert(package.loaders, function(module) if M.deprecated_modules[module] then - Util.warn( + LazyVim.warn( ("`%s` is no longer included by default in **LazyVim**.\nPlease install the `%s` extra if you still want to use it."):format( module, M.deprecated_modules[module] @@ -125,21 +124,21 @@ function M.lazy_file() end function M.fix_imports() - Plugin.Spec.import = Util.inject.args(Plugin.Spec.import, function(_, spec) + Plugin.Spec.import = LazyVim.inject.args(Plugin.Spec.import, function(_, spec) local dep = M.deprecated_extras[spec and spec.import] if dep then dep = dep .. "\n" .. "Please remove the extra to hide this warning." - Util.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 }) + LazyVim.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 }) return false end end) end function M.fix_renames() - Plugin.Spec.add = Util.inject.args(Plugin.Spec.add, function(self, plugin) + Plugin.Spec.add = LazyVim.inject.args(Plugin.Spec.add, function(self, plugin) if type(plugin) == "table" then if M.renames[plugin[1]] then - Util.warn( + LazyVim.warn( ("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format( plugin[1], M.renames[plugin[1]], diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index e4bdeab1..4143206c 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.root ---@overload fun(): string local M = setmetatable({}, { @@ -31,7 +29,7 @@ function M.detectors.lsp(buf) return {} end local roots = {} ---@type string[] - for _, client in pairs(Util.lsp.get_clients({ bufnr = buf })) do + for _, client in pairs(LazyVim.lsp.get_clients({ bufnr = buf })) do -- only check workspace folders, since we're not interested in clients -- running in single file mode local workspace = client.config.workspace_folders @@ -40,7 +38,7 @@ function M.detectors.lsp(buf) end end return vim.tbl_filter(function(path) - path = Util.norm(path) + path = LazyVim.norm(path) return path and bufpath:find(path, 1, true) == 1 end, roots) end @@ -66,7 +64,7 @@ function M.realpath(path) return nil end path = vim.uv.fs_realpath(path) or path - return Util.norm(path) + return LazyVim.norm(path) end ---@param spec LazyRootSpec @@ -132,7 +130,7 @@ function M.info() lines[#lines + 1] = "```lua" lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec) lines[#lines + 1] = "```" - require("lazyvim.util").info(lines, { title = "LazyVim Roots" }) + LazyVim.info(lines, { title = "LazyVim Roots" }) return roots[1] and roots[1].paths[1] or vim.uv.cwd() end @@ -141,7 +139,7 @@ M.cache = {} function M.setup() vim.api.nvim_create_user_command("LazyRoot", function() - Util.root.info() + LazyVim.root.info() end, { desc = "LazyVim roots for the current buffer" }) vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged" }, { @@ -170,7 +168,7 @@ function M.get(opts) if opts and opts.normalize then return ret end - return Util.is_win() and ret:gsub("/", "\\") or ret + return LazyVim.is_win() and ret:gsub("/", "\\") or ret end function M.git() diff --git a/lua/lazyvim/util/telescope.lua b/lua/lazyvim/util/telescope.lua index 86dc02f0..641c751a 100644 --- a/lua/lazyvim/util/telescope.lua +++ b/lua/lazyvim/util/telescope.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.telescope.opts ---@field cwd? string|boolean ---@field show_untracked? boolean @@ -22,7 +20,7 @@ function M.telescope(builtin, opts) return function() builtin = params.builtin opts = params.opts - opts = vim.tbl_deep_extend("force", { cwd = Util.root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]] + opts = vim.tbl_deep_extend("force", { cwd = LazyVim.root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]] if builtin == "files" then if vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git") @@ -59,7 +57,7 @@ function M.telescope(builtin, opts) end function M.config_files() - return Util.telescope("find_files", { cwd = vim.fn.stdpath("config") }) + return LazyVim.telescope("find_files", { cwd = vim.fn.stdpath("config") }) end return M diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua index 409556d1..cb380d0d 100644 --- a/lua/lazyvim/util/toggle.lua +++ b/lua/lazyvim/util/toggle.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.toggle local M = {} @@ -14,15 +12,15 @@ function M.option(option, silent, values) ---@diagnostic disable-next-line: no-unknown vim.opt_local[option] = values[1] end - return Util.info("Set " .. option .. " to " .. vim.opt_local[option]:get(), { title = "Option" }) + return LazyVim.info("Set " .. option .. " to " .. vim.opt_local[option]:get(), { title = "Option" }) end ---@diagnostic disable-next-line: no-unknown vim.opt_local[option] = not vim.opt_local[option]:get() if not silent then if vim.opt_local[option]:get() then - Util.info("Enabled " .. option, { title = "Option" }) + LazyVim.info("Enabled " .. option, { title = "Option" }) else - Util.warn("Disabled " .. option, { title = "Option" }) + LazyVim.warn("Disabled " .. option, { title = "Option" }) end end end @@ -33,11 +31,11 @@ function M.number() nu = { number = vim.opt_local.number:get(), relativenumber = vim.opt_local.relativenumber:get() } vim.opt_local.number = false vim.opt_local.relativenumber = false - Util.warn("Disabled line numbers", { title = "Option" }) + LazyVim.warn("Disabled line numbers", { title = "Option" }) else vim.opt_local.number = nu.number vim.opt_local.relativenumber = nu.relativenumber - Util.info("Enabled line numbers", { title = "Option" }) + LazyVim.info("Enabled line numbers", { title = "Option" }) end end @@ -52,10 +50,10 @@ function M.diagnostics() if enabled then vim.diagnostic.enable() - Util.info("Enabled diagnostics", { title = "Diagnostics" }) + LazyVim.info("Enabled diagnostics", { title = "Diagnostics" }) else vim.diagnostic.disable() - Util.warn("Disabled diagnostics", { title = "Diagnostics" }) + LazyVim.warn("Disabled diagnostics", { title = "Diagnostics" }) end end