feat: add todos component to lualine sections and apply conditional rendering
This commit is contained in:
+70
-29
@@ -5,8 +5,36 @@
|
||||
local utils = require("utils")
|
||||
local rootils = utils.rootiest
|
||||
|
||||
local function apply_todo_highlights(status_string)
|
||||
-- Define patterns and associated highlight groups
|
||||
local patterns = {
|
||||
{ icon = "", hl = "lualine_c_diagnostics_info_normal" },
|
||||
{ icon = "", hl = "lualine_c_diagnostics_warning_normal" },
|
||||
{ icon = "", hl = "lualine_c_diagnostics_warning_normal" },
|
||||
{ icon = "", hl = "lualine_c_diagnostics_hint_normal" },
|
||||
{ icon = "", hl = "lualine_c_diagnostics_hint_normal" },
|
||||
}
|
||||
|
||||
-- Apply the highlights
|
||||
for _, pattern in ipairs(patterns) do
|
||||
status_string = status_string:gsub(
|
||||
vim.pesc(pattern.icon),
|
||||
"%#" .. pattern.hl .. "#" .. pattern.icon
|
||||
)
|
||||
end
|
||||
|
||||
-- Reset highlight to normal after the string
|
||||
status_string = status_string .. "%#LualineNormal#"
|
||||
|
||||
return status_string
|
||||
end
|
||||
|
||||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
dependencies = {
|
||||
{ "bezhermoso/todos-lualine.nvim" },
|
||||
{ "folke/todo-comments.nvim" },
|
||||
},
|
||||
init = function()
|
||||
vim.g.lualine_laststatus = vim.o.laststatus
|
||||
if vim.fn.argc(-1) > 0 then
|
||||
@@ -22,6 +50,11 @@ return {
|
||||
|
||||
vim.o.laststatus = vim.g.lualine_laststatus
|
||||
|
||||
local todos_component =
|
||||
require("todos-lualine").component(require("data").types.todo.lualine())
|
||||
|
||||
-- todos_component = apply_todo_highlights(todos_component)
|
||||
|
||||
local opts = {
|
||||
options = {
|
||||
theme = "auto",
|
||||
@@ -34,14 +67,32 @@ return {
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {
|
||||
{ "mode" },
|
||||
{ -- Mode
|
||||
"mode",
|
||||
},
|
||||
},
|
||||
lualine_b = {
|
||||
{ "branch" },
|
||||
{ -- Branch
|
||||
"branch",
|
||||
},
|
||||
{ -- Arrow
|
||||
function()
|
||||
return require("arrow.statusline").text_for_statusline_with_icons()
|
||||
end,
|
||||
cond = function()
|
||||
return rootils.is_window_wide_enough(100)
|
||||
end,
|
||||
},
|
||||
{ -- Todo
|
||||
todos_component,
|
||||
cond = function()
|
||||
return rootils.is_window_wide_enough(100)
|
||||
end,
|
||||
},
|
||||
},
|
||||
lualine_c = {
|
||||
LazyVim.lualine.root_dir(),
|
||||
{
|
||||
{ -- Diagnostics
|
||||
"diagnostics",
|
||||
symbols = {
|
||||
error = icons.diagnostics.Error,
|
||||
@@ -50,7 +101,7 @@ return {
|
||||
hint = icons.diagnostics.Hint,
|
||||
},
|
||||
},
|
||||
{
|
||||
{ -- Filetype
|
||||
"filetype",
|
||||
icon_only = true,
|
||||
separator = "",
|
||||
@@ -60,7 +111,7 @@ return {
|
||||
},
|
||||
lualine_x = {
|
||||
-- stylua: ignore
|
||||
{
|
||||
{ -- Statement
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
function() return require("noice").api.status.command.get() end,
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
@@ -68,25 +119,25 @@ return {
|
||||
color = function() return LazyVim.ui.fg("Statement") end,
|
||||
},
|
||||
-- stylua: ignore
|
||||
{
|
||||
{ -- DAP Status
|
||||
function() return " " .. require("dap").status() end,
|
||||
cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end,
|
||||
color = function() return LazyVim.ui.fg("Debug") end,
|
||||
},
|
||||
-- stylua: ignore
|
||||
{
|
||||
{ -- Lazy Status
|
||||
require("lazy.status").updates,
|
||||
cond = require("lazy.status").has_updates,
|
||||
color = function() return LazyVim.ui.fg("Special") end,
|
||||
},
|
||||
{
|
||||
{ -- Diff
|
||||
"diff",
|
||||
symbols = {
|
||||
added = icons.git.added,
|
||||
modified = icons.git.modified,
|
||||
removed = icons.git.removed,
|
||||
},
|
||||
{
|
||||
{ -- GitSigns
|
||||
source = function()
|
||||
local gitsigns = vim.b.gitsigns_status_dict
|
||||
if gitsigns then
|
||||
@@ -99,7 +150,7 @@ return {
|
||||
end,
|
||||
},
|
||||
},
|
||||
{
|
||||
{ -- Wakatime
|
||||
function()
|
||||
return utils.wakatime_stats.get_icon_with_text()
|
||||
end,
|
||||
@@ -110,7 +161,7 @@ return {
|
||||
return rootils.is_window_wide_enough(100)
|
||||
end,
|
||||
},
|
||||
{
|
||||
{ -- Music
|
||||
function()
|
||||
return utils.music_stats.get_icon_with_text()
|
||||
end,
|
||||
@@ -120,7 +171,7 @@ return {
|
||||
},
|
||||
},
|
||||
lualine_y = {
|
||||
{
|
||||
{ -- Wordcount
|
||||
function()
|
||||
return vim.fn.wordcount().words
|
||||
end,
|
||||
@@ -129,7 +180,7 @@ return {
|
||||
return rootils.is_window_wide_enough(80)
|
||||
end,
|
||||
},
|
||||
{
|
||||
{ -- Progress
|
||||
"progress",
|
||||
separator = " ",
|
||||
padding = { left = 1, right = 0 },
|
||||
@@ -137,50 +188,40 @@ return {
|
||||
return rootils.is_window_wide_enough(60)
|
||||
end,
|
||||
},
|
||||
{
|
||||
{ -- Location
|
||||
"location",
|
||||
padding = { left = 0, right = 1 },
|
||||
cond = function()
|
||||
return rootils.is_window_wide_enough(40)
|
||||
end,
|
||||
},
|
||||
{
|
||||
{ -- Selection
|
||||
"selection_count",
|
||||
cond = function()
|
||||
return rootils.is_window_wide_enough(120)
|
||||
end,
|
||||
},
|
||||
{
|
||||
{ -- Filesize
|
||||
"filesize",
|
||||
cond = function()
|
||||
return rootils.is_window_wide_enough(100)
|
||||
end,
|
||||
},
|
||||
{
|
||||
function()
|
||||
return require("arrow.statusline").text_for_statusline_with_icons()
|
||||
end,
|
||||
cond = function()
|
||||
return rootils.is_window_wide_enough(100)
|
||||
end,
|
||||
separator = { left = "", right = "" },
|
||||
},
|
||||
},
|
||||
lualine_z = {
|
||||
{
|
||||
{ -- Recording
|
||||
require("recorder").recordingStatus,
|
||||
color = "CurSearch",
|
||||
separator = { left = "", right = "" },
|
||||
},
|
||||
{
|
||||
{ -- Search
|
||||
"searchcount",
|
||||
color = "CurSearch",
|
||||
separator = { left = "", right = "" },
|
||||
icon = " ",
|
||||
},
|
||||
{
|
||||
{ -- Time
|
||||
"datetime",
|
||||
-- options: default, us, uk, iso, or your own format string ("%H:%M", etc..)
|
||||
style = "%a %R",
|
||||
icon = " ",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user