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
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
41 changed files with 188 additions and 229 deletions

View file

@ -1,6 +1,4 @@
local Util = require("lazyvim.util") _G.LazyVim = require("lazyvim.util")
_G.LazyVim = Util
---@class LazyVimConfig: LazyVimOptions ---@class LazyVimConfig: LazyVimOptions
local M = {} local M = {}
@ -151,7 +149,7 @@ function M.json.load()
if ok then if ok then
M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {}) M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {})
if M.json.data.version ~= M.json.version then if M.json.data.version ~= M.json.version then
Util.json.migrate() LazyVim.json.migrate()
end end
end end
end end
@ -180,12 +178,12 @@ function M.setup(opts)
end end
M.load("keymaps") M.load("keymaps")
Util.format.setup() LazyVim.format.setup()
Util.news.setup() LazyVim.news.setup()
Util.root.setup() LazyVim.root.setup()
vim.api.nvim_create_user_command("LazyExtras", function() vim.api.nvim_create_user_command("LazyExtras", function()
Util.extras.show() LazyVim.extras.show()
end, { desc = "Manage LazyVim extras" }) end, { desc = "Manage LazyVim extras" })
vim.api.nvim_create_user_command("LazyHealth", function() vim.api.nvim_create_user_command("LazyHealth", function()
@ -195,8 +193,8 @@ function M.setup(opts)
end, end,
}) })
Util.track("colorscheme") LazyVim.track("colorscheme")
Util.try(function() LazyVim.try(function()
if type(M.colorscheme) == "function" then if type(M.colorscheme) == "function" then
M.colorscheme() M.colorscheme()
else else
@ -205,11 +203,11 @@ function M.setup(opts)
end, { end, {
msg = "Could not load your colorscheme", msg = "Could not load your colorscheme",
on_error = function(msg) on_error = function(msg)
Util.error(msg) LazyVim.error(msg)
vim.cmd.colorscheme("habamax") vim.cmd.colorscheme("habamax")
end, end,
}) })
Util.track() LazyVim.track()
end end
---@param buf? number ---@param buf? number
@ -231,7 +229,7 @@ end
function M.load(name) function M.load(name)
local function _load(mod) local function _load(mod)
if require("lazy.core.cache").find(mod)[1] then if require("lazy.core.cache").find(mod)[1] then
Util.try(function() LazyVim.try(function()
require(mod) require(mod)
end, { msg = "Failed loading " .. mod }) end, { msg = "Failed loading " .. mod })
end end
@ -261,19 +259,19 @@ function M.init()
end end
package.preload["lazyvim.plugins.lsp.format"] = function() package.preload["lazyvim.plugins.lsp.format"] = function()
Util.deprecate([[require("lazyvim.plugins.lsp.format")]], [[require("lazyvim.util").format]]) LazyVim.deprecate([[require("lazyvim.plugins.lsp.format")]], [[LazyVim.format]])
return Util.format return LazyVim.format
end end
-- delay notifications till vim.notify was replaced or after 500ms -- 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 -- load options here, before lazy init while sourcing plugin modules
-- this is needed to make sure options will be correctly applied -- this is needed to make sure options will be correctly applied
-- after installing missing plugins -- after installing missing plugins
M.load("options") M.load("options")
Util.plugin.setup() LazyVim.plugin.setup()
M.json.load() M.json.load()
end end

View file

@ -1,9 +1,8 @@
-- This file is automatically loaded by lazyvim.config.init -- This file is automatically loaded by lazyvim.config.init
local Util = require("lazyvim.util")
-- DO NOT USE THIS IN YOU OWN CONFIG!! -- DO NOT USE THIS IN YOU OWN CONFIG!!
-- use `vim.keymap.set` instead -- use `vim.keymap.set` instead
local map = Util.safe_keymap_set local map = LazyVim.safe_keymap_set
-- better up/down -- better up/down
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) 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 -- formatting
map({ "n", "v" }, "<leader>cf", function() map({ "n", "v" }, "<leader>cf", function()
Util.format({ force = true }) LazyVim.format({ force = true })
end, { desc = "Format" }) end, { desc = "Format" })
-- diagnostic -- diagnostic
@ -110,28 +109,28 @@ map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" })
-- stylua: ignore start -- stylua: ignore start
-- toggle options -- toggle options
map("n", "<leader>uf", function() Util.format.toggle() end, { desc = "Toggle auto format (global)" }) map("n", "<leader>uf", function() LazyVim.format.toggle() end, { desc = "Toggle auto format (global)" })
map("n", "<leader>uF", function() Util.format.toggle(true) end, { desc = "Toggle auto format (buffer)" }) map("n", "<leader>uF", function() LazyVim.format.toggle(true) end, { desc = "Toggle auto format (buffer)" })
map("n", "<leader>us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" }) map("n", "<leader>us", function() LazyVim.toggle("spell") end, { desc = "Toggle Spelling" })
map("n", "<leader>uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" }) map("n", "<leader>uw", function() LazyVim.toggle("wrap") end, { desc = "Toggle Word Wrap" })
map("n", "<leader>uL", function() Util.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) map("n", "<leader>uL", function() LazyVim.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" })
map("n", "<leader>ul", function() Util.toggle.number() end, { desc = "Toggle Line Numbers" }) map("n", "<leader>ul", function() LazyVim.toggle.number() end, { desc = "Toggle Line Numbers" })
map("n", "<leader>ud", function() Util.toggle.diagnostics() end, { desc = "Toggle Diagnostics" }) map("n", "<leader>ud", function() LazyVim.toggle.diagnostics() end, { desc = "Toggle Diagnostics" })
local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3 local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
map("n", "<leader>uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" }) map("n", "<leader>uc", function() LazyVim.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" })
if vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint then if vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint then
map( "n", "<leader>uh", function() Util.toggle.inlay_hints() end, { desc = "Toggle Inlay Hints" }) map( "n", "<leader>uh", function() LazyVim.toggle.inlay_hints() end, { desc = "Toggle Inlay Hints" })
end end
map("n", "<leader>uT", function() if vim.b.ts_highlight then vim.treesitter.stop() else vim.treesitter.start() end end, { desc = "Toggle Treesitter Highlight" }) map("n", "<leader>uT", function() if vim.b.ts_highlight then vim.treesitter.stop() else vim.treesitter.start() end end, { desc = "Toggle Treesitter Highlight" })
map("n", "<leader>ub", function() Util.toggle("background", false, {"light", "dark"}) end, { desc = "Toggle Background" }) map("n", "<leader>ub", function() LazyVim.toggle("background", false, {"light", "dark"}) end, { desc = "Toggle Background" })
-- lazygit -- lazygit
map("n", "<leader>gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root.git(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) map("n", "<leader>gg", function() LazyVim.terminal({ "lazygit" }, { cwd = LazyVim.root.git(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" })
map("n", "<leader>gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) map("n", "<leader>gG", function() LazyVim.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" })
map("n", "<leader>gf", function() map("n", "<leader>gf", function()
local git_path = vim.api.nvim_buf_get_name(0) 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" }) end, { desc = "Lazygit current file history" })
-- quit -- quit
@ -141,12 +140,12 @@ map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit all" })
map("n", "<leader>ui", vim.show_pos, { desc = "Inspect Pos" }) map("n", "<leader>ui", vim.show_pos, { desc = "Inspect Pos" })
-- LazyVim Changelog -- LazyVim Changelog
map("n", "<leader>L", function() Util.news.changelog() end, { desc = "LazyVim Changelog" }) map("n", "<leader>L", function() LazyVim.news.changelog() end, { desc = "LazyVim Changelog" })
-- floating terminal -- floating terminal
local lazyterm = function() Util.terminal(nil, { cwd = Util.root() }) end local lazyterm = function() LazyVim.terminal(nil, { cwd = LazyVim.root() }) end
map("n", "<leader>ft", lazyterm, { desc = "Terminal (root dir)" }) map("n", "<leader>ft", lazyterm, { desc = "Terminal (root dir)" })
map("n", "<leader>fT", function() Util.terminal() end, { desc = "Terminal (cwd)" }) map("n", "<leader>fT", function() LazyVim.terminal() end, { desc = "Terminal (cwd)" })
map("n", "<c-/>", lazyterm, { desc = "Terminal (root dir)" }) map("n", "<c-/>", lazyterm, { desc = "Terminal (root dir)" })
map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" }) map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" })

View file

@ -122,12 +122,11 @@ return {
{ {
"<leader>up", "<leader>up",
function() function()
local Util = require("lazy.core.util")
vim.g.minipairs_disable = not vim.g.minipairs_disable vim.g.minipairs_disable = not vim.g.minipairs_disable
if vim.g.minipairs_disable then if vim.g.minipairs_disable then
Util.warn("Disabled auto pairs", { title = "Option" }) LazyVim.warn("Disabled auto pairs", { title = "Option" })
else else
Util.info("Enabled auto pairs", { title = "Option" }) LazyVim.info("Enabled auto pairs", { title = "Option" })
end end
end, end,
desc = "Toggle auto pairs", desc = "Toggle auto pairs",
@ -238,7 +237,7 @@ return {
config = function(_, opts) config = function(_, opts)
require("mini.ai").setup(opts) require("mini.ai").setup(opts)
-- register all text objects with which-key -- 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<string, string|table> ---@type table<string, string|table>
local i = { local i = {
[" "] = "Whitespace", [" "] = "Whitespace",

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
return { return {
-- file explorer -- file explorer
@ -11,7 +9,7 @@ return {
{ {
"<leader>fe", "<leader>fe",
function() function()
require("neo-tree.command").execute({ toggle = true, dir = Util.root() }) require("neo-tree.command").execute({ toggle = true, dir = LazyVim.root() })
end, end,
desc = "Explorer NeoTree (root dir)", desc = "Explorer NeoTree (root dir)",
}, },
@ -82,7 +80,7 @@ return {
}, },
config = function(_, opts) config = function(_, opts)
local function on_move(data) local function on_move(data)
Util.lsp.on_rename(data.source, data.destination) LazyVim.lsp.on_rename(data.source, data.destination)
end end
local events = require("neo-tree.events") local events = require("neo-tree.events")
@ -129,7 +127,7 @@ return {
build = "make", build = "make",
enabled = vim.fn.executable("make") == 1, enabled = vim.fn.executable("make") == 1,
config = function() config = function()
Util.on_load("telescope.nvim", function() LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("fzf") require("telescope").load_extension("fzf")
end) end)
end, end,
@ -141,17 +139,17 @@ return {
"<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>", "<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>",
desc = "Switch Buffer", desc = "Switch Buffer",
}, },
{ "<leader>/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, { "<leader>/", LazyVim.telescope("live_grep"), desc = "Grep (root dir)" },
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" }, { "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
{ "<leader><space>", Util.telescope("files"), desc = "Find Files (root dir)" }, { "<leader><space>", LazyVim.telescope("files"), desc = "Find Files (root dir)" },
-- find -- find
{ "<leader>fb", "<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>", desc = "Buffers" }, { "<leader>fb", "<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>", desc = "Buffers" },
{ "<leader>fc", Util.telescope.config_files(), desc = "Find Config File" }, { "<leader>fc", LazyVim.telescope.config_files(), desc = "Find Config File" },
{ "<leader>ff", Util.telescope("files"), desc = "Find Files (root dir)" }, { "<leader>ff", LazyVim.telescope("files"), desc = "Find Files (root dir)" },
{ "<leader>fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, { "<leader>fF", LazyVim.telescope("files", { cwd = false }), desc = "Find Files (cwd)" },
{ "<leader>fg", "<cmd>Telescope git_files<cr>", desc = "Find Files (git-files)" }, { "<leader>fg", "<cmd>Telescope git_files<cr>", desc = "Find Files (git-files)" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" }, { "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
{ "<leader>fR", Util.telescope("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" }, { "<leader>fR", LazyVim.telescope("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" },
-- git -- git
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" }, { "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" },
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" }, { "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" },
@ -163,8 +161,8 @@ return {
{ "<leader>sC", "<cmd>Telescope commands<cr>", desc = "Commands" }, { "<leader>sC", "<cmd>Telescope commands<cr>", desc = "Commands" },
{ "<leader>sd", "<cmd>Telescope diagnostics bufnr=0<cr>", desc = "Document diagnostics" }, { "<leader>sd", "<cmd>Telescope diagnostics bufnr=0<cr>", desc = "Document diagnostics" },
{ "<leader>sD", "<cmd>Telescope diagnostics<cr>", desc = "Workspace diagnostics" }, { "<leader>sD", "<cmd>Telescope diagnostics<cr>", desc = "Workspace diagnostics" },
{ "<leader>sg", Util.telescope("live_grep"), desc = "Grep (root dir)" }, { "<leader>sg", LazyVim.telescope("live_grep"), desc = "Grep (root dir)" },
{ "<leader>sG", Util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" }, { "<leader>sG", LazyVim.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" },
{ "<leader>sh", "<cmd>Telescope help_tags<cr>", desc = "Help Pages" }, { "<leader>sh", "<cmd>Telescope help_tags<cr>", desc = "Help Pages" },
{ "<leader>sH", "<cmd>Telescope highlights<cr>", desc = "Search Highlight Groups" }, { "<leader>sH", "<cmd>Telescope highlights<cr>", desc = "Search Highlight Groups" },
{ "<leader>sk", "<cmd>Telescope keymaps<cr>", desc = "Key Maps" }, { "<leader>sk", "<cmd>Telescope keymaps<cr>", desc = "Key Maps" },
@ -172,11 +170,11 @@ return {
{ "<leader>sm", "<cmd>Telescope marks<cr>", desc = "Jump to Mark" }, { "<leader>sm", "<cmd>Telescope marks<cr>", desc = "Jump to Mark" },
{ "<leader>so", "<cmd>Telescope vim_options<cr>", desc = "Options" }, { "<leader>so", "<cmd>Telescope vim_options<cr>", desc = "Options" },
{ "<leader>sR", "<cmd>Telescope resume<cr>", desc = "Resume" }, { "<leader>sR", "<cmd>Telescope resume<cr>", desc = "Resume" },
{ "<leader>sw", Util.telescope("grep_string", { word_match = "-w" }), desc = "Word (root dir)" }, { "<leader>sw", LazyVim.telescope("grep_string", { word_match = "-w" }), desc = "Word (root dir)" },
{ "<leader>sW", Util.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" }, { "<leader>sW", LazyVim.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" },
{ "<leader>sw", Util.telescope("grep_string"), mode = "v", desc = "Selection (root dir)" }, { "<leader>sw", LazyVim.telescope("grep_string"), mode = "v", desc = "Selection (root dir)" },
{ "<leader>sW", Util.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" }, { "<leader>sW", LazyVim.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" },
{ "<leader>uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" }, { "<leader>uC", LazyVim.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" },
{ {
"<leader>ss", "<leader>ss",
function() function()
@ -208,12 +206,12 @@ return {
local find_files_no_ignore = function() local find_files_no_ignore = function()
local action_state = require("telescope.actions.state") local action_state = require("telescope.actions.state")
local line = action_state.get_current_line() 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 end
local find_files_with_hidden = function() local find_files_with_hidden = function()
local action_state = require("telescope.actions.state") local action_state = require("telescope.actions.state")
local line = action_state.get_current_line() 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 end
return { return {
@ -277,7 +275,7 @@ return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
optional = true, optional = true,
opts = function(_, opts) opts = function(_, opts)
if not Util.has("flash.nvim") then if not LazyVim.has("flash.nvim") then
return return
end end
local function flash(prompt_bufnr) local function flash(prompt_bufnr)

View file

@ -27,7 +27,7 @@ return {
optional = true, optional = true,
event = "VeryLazy", event = "VeryLazy",
opts = function(_, opts) 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, end,
}, },
} }

View file

@ -19,12 +19,11 @@ return {
optional = true, optional = true,
event = "VeryLazy", event = "VeryLazy",
opts = function(_, opts) opts = function(_, opts)
local Util = require("lazyvim.util")
local colors = { local colors = {
[""] = Util.ui.fg("Special"), [""] = LazyVim.ui.fg("Special"),
["Normal"] = Util.ui.fg("Special"), ["Normal"] = LazyVim.ui.fg("Special"),
["Warning"] = Util.ui.fg("DiagnosticError"), ["Warning"] = LazyVim.ui.fg("DiagnosticError"),
["InProgress"] = Util.ui.fg("DiagnosticWarn"), ["InProgress"] = LazyVim.ui.fg("DiagnosticWarn"),
} }
table.insert(opts.sections.lualine_x, 2, { table.insert(opts.sections.lualine_x, 2, {
function() function()
@ -36,7 +35,7 @@ return {
if not package.loaded["copilot"] then if not package.loaded["copilot"] then
return return
end 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 if not ok then
return false return false
end end
@ -66,7 +65,7 @@ return {
copilot_cmp.setup(opts) copilot_cmp.setup(opts)
-- attach cmp source whenever copilot attaches -- attach cmp source whenever copilot attaches
-- fixes lazy-loading issues with the copilot cmp source -- 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 if client.name == "copilot" then
copilot_cmp._on_insert_enter({}) copilot_cmp._on_insert_enter({})
end end

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
return { return {
-- Tabnine cmp source -- Tabnine cmp source
{ {
@ -8,7 +6,7 @@ return {
{ {
"tzachar/cmp-tabnine", "tzachar/cmp-tabnine",
build = { build = {
Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh", LazyVim.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh",
":CmpTabnineHub", ":CmpTabnineHub",
}, },
dependencies = "hrsh7th/nvim-cmp", dependencies = "hrsh7th/nvim-cmp",
@ -30,7 +28,7 @@ return {
priority = 100, 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 -- Hide percentage in the menu
if entry.source.name == "cmp_tabnine" then if entry.source.name == "cmp_tabnine" then
item.menu = "" item.menu = ""
@ -45,7 +43,7 @@ return {
event = "VeryLazy", event = "VeryLazy",
opts = function(_, opts) opts = function(_, opts)
local icon = require("lazyvim.config").icons.kinds.TabNine 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, end,
}, },
} }

View file

@ -1,5 +1,4 @@
local Config = require("lazyvim.config") local Config = require("lazyvim.config")
local Util = require("lazyvim.util")
return { return {
desc = "Aerial Symbol Browser", desc = "Aerial Symbol Browser",
@ -55,7 +54,7 @@ return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
optional = true, optional = true,
opts = function() opts = function()
Util.on_load("telescope.nvim", function() LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("aerial") require("telescope").load_extension("aerial")
end) end)
end, end,
@ -73,11 +72,11 @@ return {
"folke/edgy.nvim", "folke/edgy.nvim",
optional = true, optional = true,
opts = function(_, opts) opts = function(_, opts)
local edgy_idx = Util.plugin.extra_idx("ui.edgy") local edgy_idx = LazyVim.plugin.extra_idx("ui.edgy")
local aerial_idx = Util.plugin.extra_idx("editor.aerial") local aerial_idx = LazyVim.plugin.extra_idx("editor.aerial")
if edgy_idx and edgy_idx > aerial_idx then 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", title = "LazyVim",
}) })
end end

View file

@ -57,7 +57,7 @@ return {
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename", pattern = "MiniFilesActionRename",
callback = function(event) 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,
}) })
end, end,

View file

@ -7,7 +7,7 @@ return {
lazy = true, lazy = true,
init = function() init = function()
vim.g.navic_silence = true 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 if client.supports_method("textDocument/documentSymbol") then
require("nvim-navic").attach(client, buffer) require("nvim-navic").attach(client, buffer)
end end

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
return { return {
{ {
"hedyhli/outline.nvim", "hedyhli/outline.nvim",
@ -37,11 +35,11 @@ return {
"folke/edgy.nvim", "folke/edgy.nvim",
optional = true, optional = true,
opts = function(_, opts) opts = function(_, opts)
local edgy_idx = Util.plugin.extra_idx("ui.edgy") local edgy_idx = LazyVim.plugin.extra_idx("ui.edgy")
local symbols_idx = Util.plugin.extra_idx("editor.outline") local symbols_idx = LazyVim.plugin.extra_idx("editor.outline")
if edgy_idx and edgy_idx > symbols_idx then 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.", "The `edgy.nvim` extra must be **imported** before the `outline.nvim` extra to work properly.",
{ title = "LazyVim" } { title = "LazyVim" }
) )

View file

@ -85,7 +85,7 @@ return {
}, },
setup = { setup = {
clangd = function(_, opts) 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 })) require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts }))
return false return false
end, end,

View file

@ -61,7 +61,7 @@ return {
gopls = function(_, opts) gopls = function(_, opts)
-- workaround for gopls not supporting semanticTokensProvider -- workaround for gopls not supporting semanticTokensProvider
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242 -- 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 client.name == "gopls" then
if not client.server_capabilities.semanticTokensProvider then if not client.server_capabilities.semanticTokensProvider then
local semantic = client.config.capabilities.textDocument.semanticTokens local semantic = client.config.capabilities.textDocument.semanticTokens

View file

@ -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 client.name == "yamlls" then
if vim.api.nvim_get_option_value("filetype", { buf = buffer }) == "helm" then if vim.api.nvim_get_option_value("filetype", { buf = buffer }) == "helm" then
vim.schedule(function() vim.schedule(function()

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
-- This is the same as in lspconfig.server_configurations.jdtls, but avoids -- This is the same as in lspconfig.server_configurations.jdtls, but avoids
-- needing to require that when this module loads. -- needing to require that when this module loads.
local java_filetypes = { "java" } local java_filetypes = { "java" }
@ -109,13 +107,13 @@ return {
} }
end, end,
config = function() 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 -- Find the extra bundles that should be passed on the jdtls command-line
-- if nvim-dap is enabled with java debug/test. -- if nvim-dap is enabled with java debug/test.
local mason_registry = require("mason-registry") local mason_registry = require("mason-registry")
local bundles = {} ---@type string[] 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_pkg = mason_registry.get_package("java-debug-adapter")
local java_dbg_path = java_dbg_pkg:get_install_path() local java_dbg_path = java_dbg_pkg:get_install_path()
local jar_patterns = { local jar_patterns = {
@ -196,7 +194,7 @@ return {
}, },
}, { mode = "v", buffer = args.buf }) }, { 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 -- custom init for Java debugger
require("jdtls").setup_dap(opts.dap) require("jdtls").setup_dap(opts.dap)
require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main) require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main)

View file

@ -43,7 +43,7 @@ return {
}, },
setup = { setup = {
ruff_lsp = function() ruff_lsp = function()
require("lazyvim.util").lsp.on_attach(function(client, _) LazyVim.lsp.on_attach(function(client, _)
if client.name == "ruff_lsp" then if client.name == "ruff_lsp" then
-- Disable hover in favor of Pyright -- Disable hover in favor of Pyright
client.server_capabilities.hoverProvider = false client.server_capabilities.hoverProvider = false
@ -89,7 +89,7 @@ return {
"linux-cultist/venv-selector.nvim", "linux-cultist/venv-selector.nvim",
cmd = "VenvSelect", cmd = "VenvSelect",
opts = function(_, opts) opts = function(_, opts)
if require("lazyvim.util").has("nvim-dap-python") then if LazyVim.has("nvim-dap-python") then
opts.dap_enabled = true opts.dap_enabled = true
end end
return vim.tbl_deep_extend("force", opts, { return vim.tbl_deep_extend("force", opts, {

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
return { return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
@ -58,7 +56,7 @@ return {
{ {
"ANGkeith/telescope-terraform-doc.nvim", "ANGkeith/telescope-terraform-doc.nvim",
config = function() config = function()
Util.on_load("telescope.nvim", function() LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("terraform_doc") require("telescope").load_extension("terraform_doc")
end) end)
end, end,
@ -66,7 +64,7 @@ return {
{ {
"cappyzawa/telescope-terraform.nvim", "cappyzawa/telescope-terraform.nvim",
config = function() config = function()
Util.on_load("telescope.nvim", function() LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("terraform") require("telescope").load_extension("terraform")
end) end)
end, end,

View file

@ -64,7 +64,7 @@ return {
yamlls = function() yamlls = function()
-- Neovim < 0.10 does not have dynamic registration for formatting -- Neovim < 0.10 does not have dynamic registration for formatting
if vim.fn.has("nvim-0.10") == 0 then 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 if client.name == "yamlls" then
client.server_capabilities.documentFormattingProvider = true client.server_capabilities.documentFormattingProvider = true
end end

View file

@ -23,11 +23,10 @@ vim.api.nvim_create_autocmd("User", {
once = true, once = true,
callback = function() callback = function()
local Config = require("lazy.core.config") local Config = require("lazy.core.config")
local Util = require("lazyvim.util") local lazyrc_idx = LazyVim.plugin.extra_idx("lazyrc")
local lazyrc_idx = Util.plugin.extra_idx("lazyrc")
if lazyrc_idx and lazyrc_idx ~= #Config.spec.modules then 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**. ", "The `lazyrc` extra must be the last plugin spec added to **lazy.nvim**. ",
"", "",
"Add `{ import = 'lazyvim.plugins.extras.lazyrc' }` to file `config.lazy`. ", "Add `{ import = 'lazyvim.plugins.extras.lazyrc' }` to file `config.lazy`. ",

View file

@ -15,10 +15,10 @@ return {
setup = { setup = {
eslint = function() eslint = function()
local function get_client(buf) 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 end
local formatter = require("lazyvim.util").lsp.formatter({ local formatter = LazyVim.lsp.formatter({
name = "eslint: lsp", name = "eslint: lsp",
primary = false, primary = false,
priority = 200, priority = 200,
@ -44,7 +44,7 @@ return {
end end
-- register the formatter with LazyVim -- register the formatter with LazyVim
require("lazyvim.util").format.register(formatter) LazyVim.format.register(formatter)
end, end,
}, },
}, },

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
return { return {
-- none-ls -- none-ls
{ {
@ -7,14 +5,14 @@ return {
event = "LazyFile", event = "LazyFile",
dependencies = { "mason.nvim" }, dependencies = { "mason.nvim" },
init = function() init = function()
Util.on_very_lazy(function() LazyVim.on_very_lazy(function()
-- register the formatter with LazyVim -- register the formatter with LazyVim
require("lazyvim.util").format.register({ LazyVim.format.register({
name = "none-ls.nvim", name = "none-ls.nvim",
priority = 200, -- set higher than conform, the builtin formatter priority = 200, -- set higher than conform, the builtin formatter
primary = true, primary = true,
format = function(buf) format = function(buf)
return Util.lsp.format({ return LazyVim.lsp.format({
bufnr = buf, bufnr = buf,
filter = function(client) filter = function(client)
return client.name == "null-ls" return client.name == "null-ls"

View file

@ -27,7 +27,7 @@ return {
output = { open_on_run = true }, output = { open_on_run = true },
quickfix = { quickfix = {
open = function() open = function()
if require("lazyvim.util").has("trouble.nvim") then if LazyVim.has("trouble.nvim") then
require("trouble").open({ mode = "quickfix", focus = false }) require("trouble").open({ mode = "quickfix", focus = false })
else else
vim.cmd("copen") vim.cmd("copen")
@ -47,7 +47,7 @@ return {
}, },
}, neotest_ns) }, neotest_ns)
if require("lazyvim.util").has("trouble.nvim") then if LazyVim.has("trouble.nvim") then
opts.consumers = opts.consumers or {} opts.consumers = opts.consumers or {}
-- Refresh and auto close trouble after running tests -- Refresh and auto close trouble after running tests
---@type neotest.Consumer ---@type neotest.Consumer

View file

@ -6,12 +6,12 @@ return {
keys = { keys = {
{ "<leader>gG", { "<leader>gG",
function() function()
require("lazyvim.util").terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false }) LazyVim.terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false })
end, end,
desc = "gitui (cwd)" }, desc = "gitui (cwd)" },
{ "<leader>gg", { "<leader>gg",
function() 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, end,
desc = "gitui (root dir)" } desc = "gitui (root dir)" }
}, },

View file

@ -11,7 +11,7 @@ return {
event = "VeryLazy", event = "VeryLazy",
config = function(_, opts) config = function(_, opts)
require("project_nvim").setup(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") require("telescope").load_extension("projects")
end) end)
end, end,

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
local M = {} local M = {}
---@param opts ConformOpts ---@param opts ConformOpts
@ -10,14 +8,17 @@ function M.setup(_, opts)
if formatter.extra_args then if formatter.extra_args then
---@diagnostic disable-next-line: undefined-field ---@diagnostic disable-next-line: undefined-field
formatter.prepend_args = formatter.extra_args 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 end
end end
for _, key in ipairs({ "format_on_save", "format_after_save" }) do for _, key in ipairs({ "format_on_save", "format_after_save" }) do
if opts[key] then 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( ("Don't set `opts.%s` for `conform.nvim`.\n**LazyVim** will use the conform formatter automatically"):format(
key key
) )
@ -47,8 +48,8 @@ return {
}, },
init = function() init = function()
-- Install the conform formatter on VeryLazy -- Install the conform formatter on VeryLazy
require("lazyvim.util").on_very_lazy(function() LazyVim.on_very_lazy(function()
require("lazyvim.util").format.register({ LazyVim.format.register({
name = "conform.nvim", name = "conform.nvim",
priority = 100, priority = 100,
primary = true, primary = true,
@ -56,7 +57,7 @@ return {
local plugin = require("lazy.core.config").plugins["conform.nvim"] local plugin = require("lazy.core.config").plugins["conform.nvim"]
local Plugin = require("lazy.core.plugin") local Plugin = require("lazy.core.plugin")
local opts = Plugin.values(plugin, "opts", false) 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, end,
sources = function(buf) sources = function(buf)
local ret = require("conform").list_formatters(buf) local ret = require("conform").list_formatters(buf)
@ -71,7 +72,7 @@ return {
opts = function() opts = function()
local plugin = require("lazy.core.config").plugins["conform.nvim"] local plugin = require("lazy.core.config").plugins["conform.nvim"]
if plugin.config ~= M.setup then if plugin.config ~= M.setup then
Util.error({ LazyVim.error({
"Don't set `plugin.config` for `conform.nvim`.\n", "Don't set `plugin.config` for `conform.nvim`.\n",
"This will break **LazyVim** formatting.\n", "This will break **LazyVim** formatting.\n",
"Please refer to the docs at https://www.lazyvim.org/plugins/formatting", "Please refer to the docs at https://www.lazyvim.org/plugins/formatting",

View file

@ -27,8 +27,6 @@ return {
}, },
}, },
config = function(_, opts) config = function(_, opts)
local Util = require("lazyvim.util")
local M = {} local M = {}
local lint = require("lint") local lint = require("lint")
@ -73,7 +71,7 @@ return {
names = vim.tbl_filter(function(name) names = vim.tbl_filter(function(name)
local linter = lint.linters[name] local linter = lint.linters[name]
if not linter then if not linter then
Util.warn("Linter not found: " .. name, { title = "nvim-lint" }) LazyVim.warn("Linter not found: " .. name, { title = "nvim-lint" })
end end
return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx))
end, names) end, names)

View file

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

View file

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

View file

@ -124,13 +124,12 @@ return {
{ {
"<leader>ut", "<leader>ut",
function() function()
local Util = require("lazyvim.util")
local tsc = require("treesitter-context") local tsc = require("treesitter-context")
tsc.toggle() tsc.toggle()
if Util.inject.get_upvalue(tsc.toggle, "enabled") then if LazyVim.inject.get_upvalue(tsc.toggle, "enabled") then
Util.info("Enabled Treesitter Context", { title = "Option" }) LazyVim.info("Enabled Treesitter Context", { title = "Option" })
else else
Util.warn("Disabled Treesitter Context", { title = "Option" }) LazyVim.warn("Disabled Treesitter Context", { title = "Option" })
end end
end, end,
desc = "Toggle Treesitter Context", desc = "Toggle Treesitter Context",

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
return { return {
-- Better `vim.notify()` -- Better `vim.notify()`
{ {
@ -27,8 +25,8 @@ return {
}, },
init = function() init = function()
-- when noice is not enabled, install notify on VeryLazy -- when noice is not enabled, install notify on VeryLazy
if not Util.has("noice.nvim") then if not LazyVim.has("noice.nvim") then
Util.on_very_lazy(function() LazyVim.on_very_lazy(function()
vim.notify = require("notify") vim.notify = require("notify")
end) end)
end end
@ -140,7 +138,7 @@ return {
lualine_b = { "branch" }, lualine_b = { "branch" },
lualine_c = { lualine_c = {
Util.lualine.root_dir(), LazyVim.lualine.root_dir(),
{ {
"diagnostics", "diagnostics",
symbols = { symbols = {
@ -151,31 +149,31 @@ return {
}, },
}, },
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{ Util.lualine.pretty_path() }, { LazyVim.lualine.pretty_path() },
}, },
lualine_x = { lualine_x = {
-- stylua: ignore -- stylua: ignore
{ {
function() return require("noice").api.status.command.get() end, function() return require("noice").api.status.command.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() 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 -- stylua: ignore
{ {
function() return require("noice").api.status.mode.get() end, function() return require("noice").api.status.mode.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() 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 -- stylua: ignore
{ {
function() return "" .. require("dap").status() end, function() return "" .. require("dap").status() end,
cond = function () return package.loaded["dap"] and 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, require("lazy.status").updates,
cond = require("lazy.status").has_updates, cond = require("lazy.status").has_updates,
color = Util.ui.fg("Special"), color = LazyVim.ui.fg("Special"),
}, },
{ {
"diff", "diff",
@ -278,7 +276,7 @@ return {
{ {
"folke/which-key.nvim", "folke/which-key.nvim",
opts = function(_, opts) opts = function(_, opts)
if require("lazyvim.util").has("noice.nvim") then if LazyVim.has("noice.nvim") then
opts.defaults["<leader>sn"] = { name = "+noice" } opts.defaults["<leader>sn"] = { name = "+noice" }
end end
end, end,
@ -338,7 +336,7 @@ return {
"goolord/alpha-nvim", "goolord/alpha-nvim",
optional = true, optional = true,
enabled = function() enabled = function()
require("lazyvim.util").warn({ LazyVim.warn({
"`dashboard.nvim` is now the default LazyVim starter plugin.", "`dashboard.nvim` is now the default LazyVim starter plugin.",
"", "",
"To keep using `alpha.nvim`, please enable the `lazyvim.plugins.extras.ui.alpha` extra.", "To keep using `alpha.nvim`, please enable the `lazyvim.plugins.extras.ui.alpha` extra.",
@ -373,11 +371,11 @@ return {
header = vim.split(logo, "\n"), header = vim.split(logo, "\n"),
-- stylua: ignore -- stylua: ignore
center = { 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 = "ene | startinsert", desc = " New file", icon = "", key = "n" },
{ action = "Telescope oldfiles", desc = " Recent files", icon = "", key = "r" }, { action = "Telescope oldfiles", desc = " Recent files", icon = "", key = "r" },
{ action = "Telescope live_grep", desc = " Find text", icon = "", key = "g" }, { 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 = 'lua require("persistence").load()', desc = " Restore Session", icon = "", key = "s" },
{ action = "LazyExtras", desc = " Lazy Extras", icon = "", key = "x" }, { action = "LazyExtras", desc = " Lazy Extras", icon = "", key = "x" },
{ action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" },

View file

@ -3,7 +3,6 @@ local Float = require("lazy.view.float")
local LazyConfig = require("lazy.core.config") local LazyConfig = require("lazy.core.config")
local Plugin = require("lazy.core.plugin") local Plugin = require("lazy.core.plugin")
local Text = require("lazy.view.text") local Text = require("lazy.view.text")
local Util = require("lazyvim.util")
---@class LazyExtraSource ---@class LazyExtraSource
---@field name string ---@field name string
@ -39,9 +38,9 @@ function M.get()
M.state = M.state or LazyConfig.spec.modules M.state = M.state or LazyConfig.spec.modules
local extras = {} ---@type LazyExtra[] local extras = {} ---@type LazyExtra[]
for _, source in ipairs(M.sources) do for _, source in ipairs(M.sources) do
local root = Util.find_root(source.module) local root = LazyVim.find_root(source.module)
if root then 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 if (type == "file" or type == "link") and name:match("%.lua$") then
name = path:sub(#root + 2, -5):gsub("/", ".") name = path:sub(#root + 2, -5):gsub("/", ".")
local ok, extra = pcall(M.get_extra, source, source.module .. "." .. name) 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 for _, extra in ipairs(self.extras) do
if extra.row == pos[1] then if extra.row == pos[1] then
if not extra.managed then if not extra.managed then
Util.error( LazyVim.error(
"Not managed by LazyExtras. Remove from your config to enable/disable here.", "Not managed by LazyExtras. Remove from your config to enable/disable here.",
{ title = "LazyExtras" } { title = "LazyExtras" }
) )
@ -137,8 +136,8 @@ function X:toggle()
M.state[#M.state + 1] = extra.module M.state[#M.state + 1] = extra.module
end end
table.sort(Config.json.data.extras) table.sort(Config.json.data.extras)
Util.json.save() LazyVim.json.save()
Util.info( LazyVim.info(
"`" "`"
.. extra.name .. extra.name
.. "`" .. "`"

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.format ---@class lazyvim.util.format
---@overload fun(opts?: {force?:boolean}) ---@overload fun(opts?: {force?:boolean})
local M = setmetatable({}, { local M = setmetatable({}, {
@ -26,7 +24,7 @@ function M.register(formatter)
end end
function M.formatexpr() function M.formatexpr()
if Util.has("conform.nvim") then if LazyVim.has("conform.nvim") then
return require("conform").formatexpr() return require("conform").formatexpr()
end end
return vim.lsp.formatexpr({ timeout_ms = 3000 }) return vim.lsp.formatexpr({ timeout_ms = 3000 })
@ -76,7 +74,7 @@ function M.info(buf)
if not have then if not have then
lines[#lines + 1] = "\n***No formatters available for this buffer.***" lines[#lines + 1] = "\n***No formatters available for this buffer.***"
end end
Util[enabled and "info" or "warn"]( LazyVim[enabled and "info" or "warn"](
table.concat(lines, "\n"), table.concat(lines, "\n"),
{ title = "LazyFormat (" .. (enabled and "enabled" or "disabled") .. ")" } { title = "LazyFormat (" .. (enabled and "enabled" or "disabled") .. ")" }
) )
@ -120,14 +118,14 @@ function M.format(opts)
for _, formatter in ipairs(M.resolve(buf)) do for _, formatter in ipairs(M.resolve(buf)) do
if formatter.active then if formatter.active then
done = true done = true
Util.try(function() LazyVim.try(function()
return formatter.format(buf) return formatter.format(buf)
end, { msg = "Formatter `" .. formatter.name .. "` failed" }) end, { msg = "Formatter `" .. formatter.name .. "` failed" })
end end
end end
if not done and opts and opts.force then 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
end end
@ -136,7 +134,7 @@ function M.health()
local has_plugin = Config.spec.plugins["none-ls.nvim"] local has_plugin = Config.spec.plugins["none-ls.nvim"]
local has_extra = vim.tbl_contains(Config.spec.modules, "lazyvim.plugins.extras.lsp.none-ls") local has_extra = vim.tbl_contains(Config.spec.modules, "lazyvim.plugins.extras.lsp.none-ls")
if has_plugin and not has_extra then 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.", "`conform.nvim` and `nvim-lint` are now the default formatters and linters in LazyVim.",
"", "",
"You can use those plugins together with `none-ls.nvim`,", "You can use those plugins together with `none-ls.nvim`,",

View file

@ -38,7 +38,7 @@ setmetatable(M, {
if dep then if dep then
local mod = type(dep) == "table" and dep[1] or dep local mod = type(dep) == "table" and dep[1] or dep
local key = type(dep) == "table" and dep[2] or k 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 ---@diagnostic disable-next-line: no-unknown
t[mod] = require("lazyvim.util." .. mod) -- load here to prevent loops t[mod] = require("lazyvim.util." .. mod) -- load here to prevent loops
return t[mod][key] return t[mod][key]

View file

@ -1,5 +1,4 @@
local Config = require("lazyvim.config") local Config = require("lazyvim.config")
local Util = require("lazyvim.util")
---@class lazyvim.util.json ---@class lazyvim.util.json
local M = {} local M = {}
@ -14,7 +13,7 @@ local function encode(value, indent)
elseif t == "number" or t == "boolean" then elseif t == "number" or t == "boolean" then
return tostring(value) return tostring(value)
elseif t == "table" then elseif t == "table" then
local is_list = Util.is_list(value) local is_list = LazyVim.is_list(value)
local parts = {} local parts = {}
local next_indent = indent .. " " local next_indent = indent .. " "
@ -51,13 +50,13 @@ function M.save()
local path = vim.fn.stdpath("config") .. "/lazyvim.json" local path = vim.fn.stdpath("config") .. "/lazyvim.json"
local f = io.open(path, "w") local f = io.open(path, "w")
if f then if f then
f:write(Util.json.encode(Config.json.data)) f:write(LazyVim.json.encode(Config.json.data))
f:close() f:close()
end end
end end
function M.migrate() 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 local json = Config.json
-- v0 -- v0

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.lsp ---@class lazyvim.util.lsp
local M = {} local M = {}
@ -87,10 +85,10 @@ function M.formatter(opts)
primary = true, primary = true,
priority = 1, priority = 1,
format = function(buf) format = function(buf)
M.format(Util.merge({}, filter, { bufnr = buf })) M.format(LazyVim.merge({}, filter, { bufnr = buf }))
end, end,
sources = function(buf) 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 ---@param client lsp.Client
local ret = vim.tbl_filter(function(client) local ret = vim.tbl_filter(function(client)
return client.supports_method("textDocument/formatting") return client.supports_method("textDocument/formatting")
@ -102,7 +100,7 @@ function M.formatter(opts)
end, ret) end, ret)
end, end,
} }
return Util.merge(ret, opts) --[[@as LazyFormatter]] return LazyVim.merge(ret, opts) --[[@as LazyFormatter]]
end end
---@alias lsp.Client.format {timeout_ms?: number, format_options?: table} | lsp.Client.filter ---@alias lsp.Client.format {timeout_ms?: number, format_options?: table} | lsp.Client.filter
@ -113,8 +111,8 @@ function M.format(opts)
"force", "force",
{}, {},
opts or {}, opts or {},
require("lazyvim.util").opts("nvim-lspconfig").format or {}, LazyVim.opts("nvim-lspconfig").format or {},
require("lazyvim.util").opts("conform.nvim").format or {} LazyVim.opts("conform.nvim").format or {}
) )
local ok, conform = pcall(require, "conform") local ok, conform = pcall(require, "conform")
-- use conform for formatting with LSP when available, -- use conform for formatting with LSP when available,

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.lualine ---@class lazyvim.util.lualine
local M = {} local M = {}
@ -25,9 +23,9 @@ function M.cmp_source(name, icon)
end end
local colors = { local colors = {
ok = Util.ui.fg("Special"), ok = LazyVim.ui.fg("Special"),
error = Util.ui.fg("DiagnosticError"), error = LazyVim.ui.fg("DiagnosticError"),
pending = Util.ui.fg("DiagnosticWarn"), pending = LazyVim.ui.fg("DiagnosticWarn"),
} }
return { return {
@ -90,8 +88,8 @@ function M.pretty_path(opts)
return "" return ""
end end
local root = Util.root.get({ normalize = true }) local root = LazyVim.root.get({ normalize = true })
local cwd = Util.root.cwd() local cwd = LazyVim.root.cwd()
if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then
path = path:sub(#cwd + 2) path = path:sub(#cwd + 2)
@ -130,12 +128,12 @@ function M.root_dir(opts)
parent = true, parent = true,
other = true, other = true,
icon = "󱉭 ", icon = "󱉭 ",
color = Util.ui.fg("Special"), color = LazyVim.ui.fg("Special"),
}, opts or {}) }, opts or {})
local function get() local function get()
local cwd = Util.root.cwd() local cwd = LazyVim.root.cwd()
local root = Util.root.get({ normalize = true }) local root = LazyVim.root.get({ normalize = true })
local name = vim.fs.basename(root) local name = vim.fs.basename(root)
if root == cwd then if root == cwd then

View file

@ -1,5 +1,4 @@
local Config = require("lazyvim.config") local Config = require("lazyvim.config")
local Util = require("lazyvim.util")
---@class lazyvim.util.news ---@class lazyvim.util.news
local M = {} local M = {}
@ -27,7 +26,7 @@ function M.setup()
end end
function M.welcome() function M.welcome()
Util.info("Welcome to LazyVim!") LazyVim.info("Welcome to LazyVim!")
end end
function M.changelog() function M.changelog()
@ -50,7 +49,7 @@ function M.open(file, opts)
if opts.plugin then if opts.plugin then
local plugin = require("lazy.core.config").plugins[opts.plugin] --[[@as LazyPlugin?]] local plugin = require("lazy.core.config").plugins[opts.plugin] --[[@as LazyPlugin?]]
if not plugin then if not plugin then
return Util.error("plugin not found: " .. opts.plugin) return LazyVim.error("plugin not found: " .. opts.plugin)
end end
file = plugin.dir .. "/" .. file file = plugin.dir .. "/" .. file
elseif opts.rtp then elseif opts.rtp then
@ -58,7 +57,7 @@ function M.open(file, opts)
end end
if not file then if not file then
return Util.error("File not found") return LazyVim.error("File not found")
end end
if opts.when_changed then if opts.when_changed then
@ -68,7 +67,7 @@ function M.open(file, opts)
return return
end end
Config.json.data.news[ref] = hash Config.json.data.news[ref] = hash
Util.json.save() LazyVim.json.save()
-- don't open if file has never been opened -- don't open if file has never been opened
if is_new then if is_new then
return return

View file

@ -1,5 +1,4 @@
local Plugin = require("lazy.core.plugin") local Plugin = require("lazy.core.plugin")
local Util = require("lazyvim.util")
---@class lazyvim.util.plugin ---@class lazyvim.util.plugin
local M = {} local M = {}
@ -35,7 +34,7 @@ function M.setup()
M.lazy_file() M.lazy_file()
table.insert(package.loaders, function(module) table.insert(package.loaders, function(module)
if M.deprecated_modules[module] then 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( ("`%s` is no longer included by default in **LazyVim**.\nPlease install the `%s` extra if you still want to use it."):format(
module, module,
M.deprecated_modules[module] M.deprecated_modules[module]
@ -125,21 +124,21 @@ function M.lazy_file()
end end
function M.fix_imports() 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] local dep = M.deprecated_extras[spec and spec.import]
if dep then if dep then
dep = dep .. "\n" .. "Please remove the extra to hide this warning." 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 return false
end end
end) end)
end end
function M.fix_renames() 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 type(plugin) == "table" then
if M.renames[plugin[1]] 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 `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format(
plugin[1], plugin[1],
M.renames[plugin[1]], M.renames[plugin[1]],

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.root ---@class lazyvim.util.root
---@overload fun(): string ---@overload fun(): string
local M = setmetatable({}, { local M = setmetatable({}, {
@ -31,7 +29,7 @@ function M.detectors.lsp(buf)
return {} return {}
end end
local roots = {} ---@type string[] 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 -- only check workspace folders, since we're not interested in clients
-- running in single file mode -- running in single file mode
local workspace = client.config.workspace_folders local workspace = client.config.workspace_folders
@ -40,7 +38,7 @@ function M.detectors.lsp(buf)
end end
end end
return vim.tbl_filter(function(path) return vim.tbl_filter(function(path)
path = Util.norm(path) path = LazyVim.norm(path)
return path and bufpath:find(path, 1, true) == 1 return path and bufpath:find(path, 1, true) == 1
end, roots) end, roots)
end end
@ -66,7 +64,7 @@ function M.realpath(path)
return nil return nil
end end
path = vim.uv.fs_realpath(path) or path path = vim.uv.fs_realpath(path) or path
return Util.norm(path) return LazyVim.norm(path)
end end
---@param spec LazyRootSpec ---@param spec LazyRootSpec
@ -132,7 +130,7 @@ function M.info()
lines[#lines + 1] = "```lua" lines[#lines + 1] = "```lua"
lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec) lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec)
lines[#lines + 1] = "```" 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() return roots[1] and roots[1].paths[1] or vim.uv.cwd()
end end
@ -141,7 +139,7 @@ M.cache = {}
function M.setup() function M.setup()
vim.api.nvim_create_user_command("LazyRoot", function() vim.api.nvim_create_user_command("LazyRoot", function()
Util.root.info() LazyVim.root.info()
end, { desc = "LazyVim roots for the current buffer" }) end, { desc = "LazyVim roots for the current buffer" })
vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged" }, { vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged" }, {
@ -170,7 +168,7 @@ function M.get(opts)
if opts and opts.normalize then if opts and opts.normalize then
return ret return ret
end end
return Util.is_win() and ret:gsub("/", "\\") or ret return LazyVim.is_win() and ret:gsub("/", "\\") or ret
end end
function M.git() function M.git()

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.telescope.opts ---@class lazyvim.util.telescope.opts
---@field cwd? string|boolean ---@field cwd? string|boolean
---@field show_untracked? boolean ---@field show_untracked? boolean
@ -22,7 +20,7 @@ function M.telescope(builtin, opts)
return function() return function()
builtin = params.builtin builtin = params.builtin
opts = params.opts 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 builtin == "files" then
if if
vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git") vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git")
@ -59,7 +57,7 @@ function M.telescope(builtin, opts)
end end
function M.config_files() 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 end
return M return M

View file

@ -1,5 +1,3 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.toggle ---@class lazyvim.util.toggle
local M = {} local M = {}
@ -14,15 +12,15 @@ function M.option(option, silent, values)
---@diagnostic disable-next-line: no-unknown ---@diagnostic disable-next-line: no-unknown
vim.opt_local[option] = values[1] vim.opt_local[option] = values[1]
end 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 end
---@diagnostic disable-next-line: no-unknown ---@diagnostic disable-next-line: no-unknown
vim.opt_local[option] = not vim.opt_local[option]:get() vim.opt_local[option] = not vim.opt_local[option]:get()
if not silent then if not silent then
if vim.opt_local[option]:get() then if vim.opt_local[option]:get() then
Util.info("Enabled " .. option, { title = "Option" }) LazyVim.info("Enabled " .. option, { title = "Option" })
else else
Util.warn("Disabled " .. option, { title = "Option" }) LazyVim.warn("Disabled " .. option, { title = "Option" })
end end
end end
end end
@ -33,11 +31,11 @@ function M.number()
nu = { number = vim.opt_local.number:get(), relativenumber = vim.opt_local.relativenumber:get() } nu = { number = vim.opt_local.number:get(), relativenumber = vim.opt_local.relativenumber:get() }
vim.opt_local.number = false vim.opt_local.number = false
vim.opt_local.relativenumber = false vim.opt_local.relativenumber = false
Util.warn("Disabled line numbers", { title = "Option" }) LazyVim.warn("Disabled line numbers", { title = "Option" })
else else
vim.opt_local.number = nu.number vim.opt_local.number = nu.number
vim.opt_local.relativenumber = nu.relativenumber vim.opt_local.relativenumber = nu.relativenumber
Util.info("Enabled line numbers", { title = "Option" }) LazyVim.info("Enabled line numbers", { title = "Option" })
end end
end end
@ -52,10 +50,10 @@ function M.diagnostics()
if enabled then if enabled then
vim.diagnostic.enable() vim.diagnostic.enable()
Util.info("Enabled diagnostics", { title = "Diagnostics" }) LazyVim.info("Enabled diagnostics", { title = "Diagnostics" })
else else
vim.diagnostic.disable() vim.diagnostic.disable()
Util.warn("Disabled diagnostics", { title = "Diagnostics" }) LazyVim.warn("Disabled diagnostics", { title = "Diagnostics" })
end end
end end