my neovim config, who would've thought

tasks: add archive cleaner

olexsmir.xyz d738900a dc0e9144

verified
Changed files
+17
after
ftplugin
lua
scratch
+1
after/ftplugin/markdown.lua
··· 7 7 8 8 map("n", "<localleader>v", "<cmd>RenderMarkdown toggle<cr>", true) 9 9 map("n", "<localleader>t", require("scratch.tasks").complete, true) 10 + map("n", "<localleader>c", require("scratch.tasks").clear_archive, true) 10 11 11 12 vim.b.minihipatterns_config = { 12 13 highlighters = {
+16
lua/scratch/tasks.lua
··· 142 142 vim.cmd.update() 143 143 end 144 144 145 + function tasks.clear_archive() 146 + local bufnr = vim.api.nvim_get_current_buf() 147 + local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) 148 + 149 + local archived_heading = find_archive_heading(lines) 150 + if not archived_heading then 151 + vim.notify("Looks like there's no archive of tasks", vim.log.levels.ERROR) 152 + end 153 + 154 + -- minus 2 because = 1(the archive heading) + 1(empty line before it) 155 + lines = vim.list_slice(lines, 1, archived_heading - 2) 156 + vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, lines) 157 + 158 + vim.cmd.update() 159 + end 160 + 145 161 return tasks