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 utils = require("utils")
|
||||||
local rootils = utils.rootiest
|
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 {
|
return {
|
||||||
"nvim-lualine/lualine.nvim",
|
"nvim-lualine/lualine.nvim",
|
||||||
|
dependencies = {
|
||||||
|
{ "bezhermoso/todos-lualine.nvim" },
|
||||||
|
{ "folke/todo-comments.nvim" },
|
||||||
|
},
|
||||||
init = function()
|
init = function()
|
||||||
vim.g.lualine_laststatus = vim.o.laststatus
|
vim.g.lualine_laststatus = vim.o.laststatus
|
||||||
if vim.fn.argc(-1) > 0 then
|
if vim.fn.argc(-1) > 0 then
|
||||||
@@ -22,6 +50,11 @@ return {
|
|||||||
|
|
||||||
vim.o.laststatus = vim.g.lualine_laststatus
|
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 = {
|
local opts = {
|
||||||
options = {
|
options = {
|
||||||
theme = "auto",
|
theme = "auto",
|
||||||
@@ -34,14 +67,32 @@ return {
|
|||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = {
|
lualine_a = {
|
||||||
{ "mode" },
|
{ -- Mode
|
||||||
|
"mode",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
lualine_b = {
|
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 = {
|
lualine_c = {
|
||||||
LazyVim.lualine.root_dir(),
|
LazyVim.lualine.root_dir(),
|
||||||
{
|
{ -- Diagnostics
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
symbols = {
|
symbols = {
|
||||||
error = icons.diagnostics.Error,
|
error = icons.diagnostics.Error,
|
||||||
@@ -50,7 +101,7 @@ return {
|
|||||||
hint = icons.diagnostics.Hint,
|
hint = icons.diagnostics.Hint,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{ -- Filetype
|
||||||
"filetype",
|
"filetype",
|
||||||
icon_only = true,
|
icon_only = true,
|
||||||
separator = "",
|
separator = "",
|
||||||
@@ -60,7 +111,7 @@ return {
|
|||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
{
|
{ -- Statement
|
||||||
---@diagnostic disable-next-line: undefined-field
|
---@diagnostic disable-next-line: undefined-field
|
||||||
function() return require("noice").api.status.command.get() end,
|
function() return require("noice").api.status.command.get() end,
|
||||||
---@diagnostic disable-next-line: undefined-field
|
---@diagnostic disable-next-line: undefined-field
|
||||||
@@ -68,25 +119,25 @@ return {
|
|||||||
color = function() return LazyVim.ui.fg("Statement") end,
|
color = function() return LazyVim.ui.fg("Statement") end,
|
||||||
},
|
},
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
{
|
{ -- DAP Status
|
||||||
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 = function() return LazyVim.ui.fg("Debug") end,
|
color = function() return LazyVim.ui.fg("Debug") end,
|
||||||
},
|
},
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
{
|
{ -- Lazy Status
|
||||||
require("lazy.status").updates,
|
require("lazy.status").updates,
|
||||||
cond = require("lazy.status").has_updates,
|
cond = require("lazy.status").has_updates,
|
||||||
color = function() return LazyVim.ui.fg("Special") end,
|
color = function() return LazyVim.ui.fg("Special") end,
|
||||||
},
|
},
|
||||||
{
|
{ -- Diff
|
||||||
"diff",
|
"diff",
|
||||||
symbols = {
|
symbols = {
|
||||||
added = icons.git.added,
|
added = icons.git.added,
|
||||||
modified = icons.git.modified,
|
modified = icons.git.modified,
|
||||||
removed = icons.git.removed,
|
removed = icons.git.removed,
|
||||||
},
|
},
|
||||||
{
|
{ -- GitSigns
|
||||||
source = function()
|
source = function()
|
||||||
local gitsigns = vim.b.gitsigns_status_dict
|
local gitsigns = vim.b.gitsigns_status_dict
|
||||||
if gitsigns then
|
if gitsigns then
|
||||||
@@ -99,7 +150,7 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{ -- Wakatime
|
||||||
function()
|
function()
|
||||||
return utils.wakatime_stats.get_icon_with_text()
|
return utils.wakatime_stats.get_icon_with_text()
|
||||||
end,
|
end,
|
||||||
@@ -110,7 +161,7 @@ return {
|
|||||||
return rootils.is_window_wide_enough(100)
|
return rootils.is_window_wide_enough(100)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{ -- Music
|
||||||
function()
|
function()
|
||||||
return utils.music_stats.get_icon_with_text()
|
return utils.music_stats.get_icon_with_text()
|
||||||
end,
|
end,
|
||||||
@@ -120,7 +171,7 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_y = {
|
lualine_y = {
|
||||||
{
|
{ -- Wordcount
|
||||||
function()
|
function()
|
||||||
return vim.fn.wordcount().words
|
return vim.fn.wordcount().words
|
||||||
end,
|
end,
|
||||||
@@ -129,7 +180,7 @@ return {
|
|||||||
return rootils.is_window_wide_enough(80)
|
return rootils.is_window_wide_enough(80)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{ -- Progress
|
||||||
"progress",
|
"progress",
|
||||||
separator = " ",
|
separator = " ",
|
||||||
padding = { left = 1, right = 0 },
|
padding = { left = 1, right = 0 },
|
||||||
@@ -137,50 +188,40 @@ return {
|
|||||||
return rootils.is_window_wide_enough(60)
|
return rootils.is_window_wide_enough(60)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{ -- Location
|
||||||
"location",
|
"location",
|
||||||
padding = { left = 0, right = 1 },
|
padding = { left = 0, right = 1 },
|
||||||
cond = function()
|
cond = function()
|
||||||
return rootils.is_window_wide_enough(40)
|
return rootils.is_window_wide_enough(40)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{ -- Selection
|
||||||
"selection_count",
|
"selection_count",
|
||||||
cond = function()
|
cond = function()
|
||||||
return rootils.is_window_wide_enough(120)
|
return rootils.is_window_wide_enough(120)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{ -- Filesize
|
||||||
"filesize",
|
"filesize",
|
||||||
cond = function()
|
cond = function()
|
||||||
return rootils.is_window_wide_enough(100)
|
return rootils.is_window_wide_enough(100)
|
||||||
end,
|
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 = {
|
lualine_z = {
|
||||||
{
|
{ -- Recording
|
||||||
require("recorder").recordingStatus,
|
require("recorder").recordingStatus,
|
||||||
color = "CurSearch",
|
color = "CurSearch",
|
||||||
separator = { left = "", right = "" },
|
separator = { left = "", right = "" },
|
||||||
},
|
},
|
||||||
{
|
{ -- Search
|
||||||
"searchcount",
|
"searchcount",
|
||||||
color = "CurSearch",
|
color = "CurSearch",
|
||||||
separator = { left = "", right = "" },
|
separator = { left = "", right = "" },
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
{
|
{ -- Time
|
||||||
"datetime",
|
"datetime",
|
||||||
-- options: default, us, uk, iso, or your own format string ("%H:%M", etc..)
|
|
||||||
style = "%a %R",
|
style = "%a %R",
|
||||||
icon = " ",
|
icon = " ",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user