X-Git-Url: https://git.r.bdr.sh/rbdr/nota.nvim/blobdiff_plain/503d09fc95a47c13141d097cf80dd243d1dce342..HEAD:/lua/tasks.lua diff --git a/lua/tasks.lua b/lua/tasks.lua deleted file mode 100644 index 618a688..0000000 --- a/lua/tasks.lua +++ /dev/null @@ -1,96 +0,0 @@ -------------------------------------------------------------------------------- --- Tools to deal with tasks -------------------------------------------------------------------------------- -local Tasks = {} -local Configuration = require('configuration') -local api = vim.api -------------------------------------------------------------------------------- --- Internal Functions -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- Public Interface -------------------------------------------------------------------------------- - ---- Toggles a task completion status -function Tasks.toggle() - local line_number = api.nvim_win_get_cursor(0)[1] - local line = api.nvim_get_current_line() - - local unchecked_pattern = '^(%s*)%- %[ %]' - local unchecked_important_pattern = '^(%s*)%* %[ %]' - local checked_pattern = '^(%s*)%- %[x%]' - local checked_important_pattern = '^(%s*)%* %[x%]' - - if line:match(unchecked_pattern) then - line = line:gsub(unchecked_pattern, '%1- [x]', 1) - elseif line:match(unchecked_important_pattern) then - line = line:gsub(unchecked_important_pattern, '%1* [x]', 1) - elseif line:match(checked_pattern) then - line = line:gsub(checked_pattern, '%1- [ ]', 1) - elseif line:match(checked_important_pattern) then - line = line:gsub(checked_important_pattern, '%1* [ ]', 1) - end - - api.nvim_buf_set_lines(0, line_number - 1, line_number, false, {line}) -end - ---- Toggles a task completion status -function Tasks.toggle_importance() - local line_number = api.nvim_win_get_cursor(0)[1] - local line = api.nvim_get_current_line() - - local unchecked_pattern = '^(%s*)%- %[ %]' - local unchecked_important_pattern = '^(%s*)%* %[ %]' - local checked_pattern = '^(%s*)%- %[x%]' - local checked_important_pattern = '^(%s*)%* %[x%]' - - if line:match(unchecked_pattern) then - line = line:gsub(unchecked_pattern, '%1* [ ]', 1) - elseif line:match(unchecked_important_pattern) then - line = line:gsub(unchecked_important_pattern, '%1- [ ]', 1) - elseif line:match(checked_pattern) then - line = line:gsub(checked_pattern, '%1* [x]', 1) - elseif line:match(checked_important_pattern) then - line = line:gsub(checked_important_pattern, '%1- [x]', 1) - end - - api.nvim_buf_set_lines(0, line_number - 1, line_number, false, {line}) -end - ---- Inserts a new task at the cursor location -function Tasks.insert() - vim.cmd('normal! o- [ ] ') - vim.cmd('startinsert!') -end - ---- Captures a new task into the inbox -function Tasks.capture() - error('Not yet implemented') -end - ---- Tag a task -function Tasks.tag() - error('Not yet implemented') -end - ---- Reschedule a task for today -function Tasks.reschedule_for_today() - error('Not yet implemented') -end - ---- Reschedule a task for tomorrow -function Tasks.reschedule_for_tomorrow() - error('Not yet implemented') -end - ---- Reschedule a task for someday -function Tasks.reschedule_for_someday() - error('Not yet implemented') -end - ---- Reschedule a task for an arbitrary date -function Tasks.reschedule(new_date) - error('Not yet implemented') -end - -return Tasks