Problem: need user-facing :Todo command, buffer-local keymaps, Plug mappings, completion toggle, help float, archive, and syntax highlighting. Solution: add init.lua with command dispatcher, toggle complete/ priority, date prompt, archive purge, and help float. Add plugin/todo.lua entry point with :Todo command and Plug mappings. Add syntax/todo.vim for conceal and priority highlighting.
39 lines
918 B
Lua
39 lines
918 B
Lua
if vim.g.loaded_todo then
|
|
return
|
|
end
|
|
vim.g.loaded_todo = true
|
|
|
|
vim.api.nvim_create_user_command('Todo', function(opts)
|
|
require('todo').command(opts.args)
|
|
end, {
|
|
nargs = '*',
|
|
complete = function(arg_lead, cmd_line)
|
|
local subcmds = { 'add', 'sync', 'archive' }
|
|
if not cmd_line:match('^Todo%s+%S') then
|
|
return vim.tbl_filter(function(s)
|
|
return s:find(arg_lead, 1, true) == 1
|
|
end, subcmds)
|
|
end
|
|
return {}
|
|
end,
|
|
})
|
|
|
|
vim.keymap.set('n', '<Plug>(todo-open)', function()
|
|
require('todo').open()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(todo-toggle)', function()
|
|
require('todo').toggle_complete()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(todo-view)', function()
|
|
require('todo.buffer').toggle_view()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(todo-priority)', function()
|
|
require('todo').toggle_priority()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(todo-date)', function()
|
|
require('todo').prompt_date()
|
|
end)
|