Compare commits

..

No commits in common. "34a78e941d32483f66783f77f39f6528fb2dfb12" and "9e341ec60b5cb47a712b634babaa938b3c3828f2" have entirely different histories.

2 changed files with 30 additions and 55 deletions

View File

@ -39,7 +39,7 @@ M.setup = function()
opt.wrap = true opt.wrap = true
opt.breakat = " \t;,[]()" opt.breakat = " \t;,[]()"
opt.linebreak = true opt.linebreak = true
opt.formatlistpat = [[^\s*\(-\|\d\.\|+\)\s*]] opt.formatlistpat = [[^\s*\(-\|\d\.\)\s*]]
opt.breakindent = true opt.breakindent = true
opt.breakindentopt = "list:2" opt.breakindentopt = "list:2"

View File

@ -618,25 +618,20 @@ return {
} }
vim.opt.showcmdloc = "statusline" vim.opt.showcmdloc = "statusline"
local timer = vim.uv.new_timer()
timer:start(
1000,
500,
vim.schedule_wrap(function()
vim.api.nvim_exec_autocmds("User", { pattern = "HeirlineOrgUpdate" })
end)
)
local org = require("orgmode") local org = require("orgmode")
local OrgDate = require("orgmode.objects.date")
local Orgmode = { local Orgmode = {
condition = function() condition = function()
return org.initialized return org.initialized and org.clock.clocked_headline and org.clock.clocked_headline:is_clocked_in()
end,
update = function(self)
local time = os.time()
self.last_updated = self.last_updated or time
if time - self.last_updated >= 1 then
self.last_updated = time
return true
end
end, end,
update = {
"User",
pattern = "HeirlineOrgUpdate",
},
margin(1), margin(1),
{ {
provider = seps.full.left, provider = seps.full.left,
@ -665,48 +660,28 @@ return {
bg = colors.sumiInk4, bg = colors.sumiInk4,
}, },
provider = function() provider = function()
local clocked_in_task = function() local headline = org.clock.clocked_headline
local headline = org.clock.clocked_headline if not headline then
if not headline then return
return
end
local clocked_time = headline:get_logbook():get_total_with_active():to_string()
local effort = headline:get_property("effort")
local time_elapsed = ""
if effort then
time_elapsed = ("[%s/%s]"):format(clocked_time, effort)
else
time_elapsed = ("[%s]"):format(clocked_time)
end
-- Get the title and remove some org syntax from it
local title = headline:get_title():gsub("[~/*_=+]", "")
local message = ("%s %s"):format(time_elapsed, title)
if #message > 60 then
message = message:sub(1, 65) .. ""
end
return message
end end
local remaining_tasks_today = function()
local remaining_tasks_today = 0 local clocked_time = headline:get_logbook():get_total_with_active():to_string()
local today = OrgDate:today() local effort = headline:get_property("effort")
for _, orgfile in pairs(org.files.files) do local time_elapsed = ""
---@type OrgFile if effort then
orgfile = orgfile time_elapsed = ("[%s/%s]"):format(clocked_time, effort)
for _, headline in ipairs(orgfile:get_opened_unfinished_headlines()) do else
for _, date in ipairs(headline:get_deadline_and_scheduled_dates()) do time_elapsed = ("[%s]"):format(clocked_time)
if date:is_same_or_before(today, "day") then
remaining_tasks_today = remaining_tasks_today + 1
break
end
end
end
end
return ("Tasks Remaining: %d"):format(remaining_tasks_today)
end end
return clocked_in_task() or remaining_tasks_today()
-- Get the title and remove some org syntax from it
local title = headline:get_title():gsub("[~/*_=+]", "")
local message = ("%s %s"):format(time_elapsed, title)
if #message > 60 then
message = message:sub(1, 65) .. ""
end
return message
end, end,
}, },
{ {