+1
after/ftplugin/markdown.lua
+1
after/ftplugin/markdown.lua
+16
lua/scratch/tasks.lua
+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