all repos

init.lua @ d738900a765da4bb414f9e65f3f30d32192bef21

my nvim config
2 files changed, 17 insertions(+), 0 deletions(-)
tasks: add archive cleaner
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2025-10-12 23:30:34 +0300
Parent: dc0e914
M after/ftplugin/markdown.lua

@@ -7,6 +7,7 @@ vim.opt_local.concealcursor = "cv"

map("n", "<localleader>v", "<cmd>RenderMarkdown toggle<cr>", true) map("n", "<localleader>t", require("scratch.tasks").complete, true) +map("n", "<localleader>c", require("scratch.tasks").clear_archive, true) vim.b.minihipatterns_config = { highlighters = {
M lua/scratch/tasks.lua

@@ -142,4 +142,20 @@

vim.cmd.update() end +function tasks.clear_archive() + local bufnr = vim.api.nvim_get_current_buf() + local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) + + local archived_heading = find_archive_heading(lines) + if not archived_heading then + vim.notify("Looks like there's no archive of tasks", vim.log.levels.ERROR) + end + + -- minus 2 because = 1(the archive heading) + 1(empty line before it) + lines = vim.list_slice(lines, 1, archived_heading - 2) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, lines) + + vim.cmd.update() +end + return tasks