mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-27 03:09:07 +02:00
refactor: move lualine fg function to Util
This commit is contained in:
parent
81ab5bed7a
commit
4042614005
2 changed files with 17 additions and 17 deletions
|
@ -85,14 +85,7 @@ return {
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = function()
|
opts = function()
|
||||||
local icons = require("lazyvim.config").icons
|
local icons = require("lazyvim.config").icons
|
||||||
|
local Util = require("lazyvim.util")
|
||||||
local function fg(name)
|
|
||||||
return function()
|
|
||||||
---@type {foreground?:number}?
|
|
||||||
local hl = vim.api.nvim_get_hl_by_name(name, true)
|
|
||||||
return hl and hl.foreground and { fg = string.format("#%06x", hl.foreground) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
options = {
|
options = {
|
||||||
|
@ -122,25 +115,25 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
-- stylua: ignore
|
|
||||||
{
|
|
||||||
function() return " " .. require("dap").status() end,
|
|
||||||
cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end,
|
|
||||||
color = fg("Debug"),
|
|
||||||
},
|
|
||||||
-- 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 = fg("Statement"),
|
color = Util.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 = fg("Constant"),
|
color = Util.fg("Constant"),
|
||||||
},
|
},
|
||||||
{ require("lazy.status").updates, cond = require("lazy.status").has_updates, color = fg("Special") },
|
-- stylua: ignore
|
||||||
|
{
|
||||||
|
function() return " " .. require("dap").status() end,
|
||||||
|
cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end,
|
||||||
|
color = Util.fg("Debug"),
|
||||||
|
},
|
||||||
|
{ require("lazy.status").updates, cond = require("lazy.status").has_updates, color = Util.fg("Special") },
|
||||||
{
|
{
|
||||||
"diff",
|
"diff",
|
||||||
symbols = {
|
symbols = {
|
||||||
|
|
|
@ -20,6 +20,13 @@ function M.has(plugin)
|
||||||
return require("lazy.core.config").plugins[plugin] ~= nil
|
return require("lazy.core.config").plugins[plugin] ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.fg(name)
|
||||||
|
---@type {foreground?:number}?
|
||||||
|
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true)
|
||||||
|
local fg = hl and hl.fg or hl.foreground
|
||||||
|
return fg and { fg = string.format("#%06x", fg) }
|
||||||
|
end
|
||||||
|
|
||||||
---@param fn fun()
|
---@param fn fun()
|
||||||
function M.on_very_lazy(fn)
|
function M.on_very_lazy(fn)
|
||||||
vim.api.nvim_create_autocmd("User", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue