Compare commits
No commits in common. "d672d68c60a2a23be72b868b3bbe576910fedcf0" and "1748e5caa12b011d4db581eef1a6526805399232" have entirely different histories.
d672d68c60
...
1748e5caa1
9 changed files with 4 additions and 233 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Edit tasks like text. `:w` saves them.
|
Edit tasks like text. `:w` saves them.
|
||||||
|
|
||||||

|
<!-- insert preview -->
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -356,10 +356,6 @@ COMMANDS *pending-commands*
|
||||||
Equivalent to the `U` buffer-local key (see |pending-mappings|). Up to 20
|
Equivalent to the `U` buffer-local key (see |pending-mappings|). Up to 20
|
||||||
levels of undo are persisted across sessions.
|
levels of undo are persisted across sessions.
|
||||||
|
|
||||||
*:PendingTab*
|
|
||||||
:PendingTab
|
|
||||||
Open the task buffer in a new tab.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
MAPPINGS *pending-mappings*
|
MAPPINGS *pending-mappings*
|
||||||
|
|
||||||
|
|
@ -498,9 +494,6 @@ All motions support count: `3]]` jumps three headers forward. `]]` and
|
||||||
to the current buffer's file and the cursor's line number.
|
to the current buffer's file and the cursor's line number.
|
||||||
See |pending-file-token|.
|
See |pending-file-token|.
|
||||||
|
|
||||||
<Plug>(pending-tab) *<Plug>(pending-tab)*
|
|
||||||
Open the task buffer in a new tab. See |:PendingTab|.
|
|
||||||
|
|
||||||
Example configuration: >lua
|
Example configuration: >lua
|
||||||
vim.keymap.set('n', '<leader>t', '<Plug>(pending-open)')
|
vim.keymap.set('n', '<leader>t', '<Plug>(pending-open)')
|
||||||
vim.keymap.set('n', '<leader>T', '<Plug>(pending-toggle)')
|
vim.keymap.set('n', '<leader>T', '<Plug>(pending-toggle)')
|
||||||
|
|
@ -686,16 +679,6 @@ Fields: ~
|
||||||
automatically. New configs should use `sync.gcal`
|
automatically. New configs should use `sync.gcal`
|
||||||
instead. See |pending.GcalConfig|.
|
instead. See |pending.GcalConfig|.
|
||||||
|
|
||||||
{icons} (table) *pending.Icons*
|
|
||||||
Icon characters displayed in the buffer. Fields:
|
|
||||||
{pending} Uncompleted task icon. Default: '○'
|
|
||||||
{done} Completed task icon. Default: '✓'
|
|
||||||
{priority} Priority task icon. Default: '●'
|
|
||||||
{header} Category header prefix. Default: '▸'
|
|
||||||
{due} Due date prefix. Default: '·'
|
|
||||||
{recur} Recurrence prefix. Default: '↺'
|
|
||||||
{category} Category label prefix. Default: '#'
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
LUA API *pending-api*
|
LUA API *pending-api*
|
||||||
|
|
||||||
|
|
@ -877,41 +860,6 @@ directly, or disable `a_category` in `keymaps` and handle it via a
|
||||||
`vim.b.miniai_config` entry that returns a linewise region if mini.ai's
|
`vim.b.miniai_config` entry that returns a linewise region if mini.ai's
|
||||||
spec allows it in your version.
|
spec allows it in your version.
|
||||||
|
|
||||||
Nerd font icons: >lua
|
|
||||||
vim.g.pending = {
|
|
||||||
icons = {
|
|
||||||
pending = '',
|
|
||||||
done = '',
|
|
||||||
priority = '',
|
|
||||||
header = '',
|
|
||||||
due = '',
|
|
||||||
recur = '',
|
|
||||||
category = '',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
ASCII fallback icons: >lua
|
|
||||||
vim.g.pending = {
|
|
||||||
icons = {
|
|
||||||
pending = '-',
|
|
||||||
done = 'x',
|
|
||||||
priority = '!',
|
|
||||||
header = '>',
|
|
||||||
due = '@',
|
|
||||||
recur = '~',
|
|
||||||
category = '+',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
Open tasks in a new tab on startup: >lua
|
|
||||||
vim.api.nvim_create_autocmd('VimEnter', {
|
|
||||||
callback = function()
|
|
||||||
vim.cmd.PendingTab()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
<
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
GOOGLE CALENDAR *pending-gcal*
|
GOOGLE CALENDAR *pending-gcal*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,6 @@ end
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@param line_meta pending.LineMeta[]
|
---@param line_meta pending.LineMeta[]
|
||||||
local function apply_extmarks(bufnr, line_meta)
|
local function apply_extmarks(bufnr, line_meta)
|
||||||
local icons = config.get().icons
|
|
||||||
vim.api.nvim_buf_clear_namespace(bufnr, task_ns, 0, -1)
|
vim.api.nvim_buf_clear_namespace(bufnr, task_ns, 0, -1)
|
||||||
for i, m in ipairs(line_meta) do
|
for i, m in ipairs(line_meta) do
|
||||||
local row = i - 1
|
local row = i - 1
|
||||||
|
|
@ -157,13 +156,13 @@ local function apply_extmarks(bufnr, line_meta)
|
||||||
local due_hl = m.overdue and 'PendingOverdue' or 'PendingDue'
|
local due_hl = m.overdue and 'PendingOverdue' or 'PendingDue'
|
||||||
local virt_parts = {}
|
local virt_parts = {}
|
||||||
if m.show_category and m.category then
|
if m.show_category and m.category then
|
||||||
table.insert(virt_parts, { icons.category .. ' ' .. m.category, 'PendingHeader' })
|
table.insert(virt_parts, { m.category, 'PendingHeader' })
|
||||||
end
|
end
|
||||||
if m.recur then
|
if m.recur then
|
||||||
table.insert(virt_parts, { icons.recur .. ' ' .. m.recur, 'PendingRecur' })
|
table.insert(virt_parts, { '\u{21bb} ' .. m.recur, 'PendingRecur' })
|
||||||
end
|
end
|
||||||
if m.due then
|
if m.due then
|
||||||
table.insert(virt_parts, { icons.due .. ' ' .. m.due, due_hl })
|
table.insert(virt_parts, { m.due, due_hl })
|
||||||
end
|
end
|
||||||
if m.file then
|
if m.file then
|
||||||
local display = m.file:match('([^/]+:%d+)$') or m.file
|
local display = m.file:match('([^/]+:%d+)$') or m.file
|
||||||
|
|
@ -186,33 +185,12 @@ local function apply_extmarks(bufnr, line_meta)
|
||||||
hl_group = 'PendingDone',
|
hl_group = 'PendingDone',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
local line = vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false)[1] or ''
|
|
||||||
local bracket_col = (line:find('%[') or 1) - 1
|
|
||||||
local icon, icon_hl
|
|
||||||
if m.status == 'done' then
|
|
||||||
icon, icon_hl = icons.done, 'PendingDone'
|
|
||||||
elseif m.priority and m.priority > 0 then
|
|
||||||
icon, icon_hl = icons.priority, 'PendingPriority'
|
|
||||||
else
|
|
||||||
icon, icon_hl = icons.pending, 'Normal'
|
|
||||||
end
|
|
||||||
local icon_padded = icon .. ' '
|
|
||||||
vim.api.nvim_buf_set_extmark(bufnr, task_ns, row, bracket_col, {
|
|
||||||
virt_text = { { icon_padded, icon_hl } },
|
|
||||||
virt_text_pos = 'overlay',
|
|
||||||
priority = 100,
|
|
||||||
})
|
|
||||||
elseif m.type == 'header' then
|
elseif m.type == 'header' then
|
||||||
local line = vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false)[1] or ''
|
local line = vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false)[1] or ''
|
||||||
vim.api.nvim_buf_set_extmark(bufnr, task_ns, row, 0, {
|
vim.api.nvim_buf_set_extmark(bufnr, task_ns, row, 0, {
|
||||||
end_col = #line,
|
end_col = #line,
|
||||||
hl_group = 'PendingHeader',
|
hl_group = 'PendingHeader',
|
||||||
})
|
})
|
||||||
vim.api.nvim_buf_set_extmark(bufnr, task_ns, row, 0, {
|
|
||||||
virt_text = { { icons.header .. ' ', 'PendingHeader' } },
|
|
||||||
virt_text_pos = 'overlay',
|
|
||||||
priority = 100,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,3 @@
|
||||||
---@class pending.Icons
|
|
||||||
---@field pending string
|
|
||||||
---@field done string
|
|
||||||
---@field priority string
|
|
||||||
---@field header string
|
|
||||||
---@field due string
|
|
||||||
---@field recur string
|
|
||||||
---@field category string
|
|
||||||
|
|
||||||
---@class pending.GcalConfig
|
---@class pending.GcalConfig
|
||||||
---@field calendar? string
|
---@field calendar? string
|
||||||
---@field credentials_path? string
|
---@field credentials_path? string
|
||||||
|
|
@ -47,7 +38,6 @@
|
||||||
---@field keymaps pending.Keymaps
|
---@field keymaps pending.Keymaps
|
||||||
---@field sync? pending.SyncConfig
|
---@field sync? pending.SyncConfig
|
||||||
---@field gcal? pending.GcalConfig
|
---@field gcal? pending.GcalConfig
|
||||||
---@field icons pending.Icons
|
|
||||||
|
|
||||||
---@class pending.config
|
---@class pending.config
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
@ -81,15 +71,6 @@ local defaults = {
|
||||||
prev_task = '[t',
|
prev_task = '[t',
|
||||||
},
|
},
|
||||||
sync = {},
|
sync = {},
|
||||||
icons = {
|
|
||||||
pending = '○',
|
|
||||||
done = '✓',
|
|
||||||
priority = '●',
|
|
||||||
header = '▸',
|
|
||||||
due = '·',
|
|
||||||
recur = '↺',
|
|
||||||
category = '#',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type pending.Config?
|
---@type pending.Config?
|
||||||
|
|
|
||||||
|
|
@ -304,13 +304,3 @@ end)
|
||||||
vim.keymap.set('n', '<Plug>(pending-add-here)', function()
|
vim.keymap.set('n', '<Plug>(pending-add-here)', function()
|
||||||
require('pending').add_here()
|
require('pending').add_here()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vim.keymap.set('n', '<Plug>(pending-tab)', function()
|
|
||||||
vim.cmd.tabnew()
|
|
||||||
require('pending').open()
|
|
||||||
end)
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('PendingTab', function()
|
|
||||||
vim.cmd.tabnew()
|
|
||||||
require('pending').open()
|
|
||||||
end, {})
|
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
vim.opt.runtimepath:prepend(vim.fn.getcwd())
|
|
||||||
local tmpdir = vim.fn.tempname()
|
|
||||||
vim.fn.mkdir(tmpdir, 'p')
|
|
||||||
|
|
||||||
vim.g.pending = {
|
|
||||||
data_path = tmpdir .. '/tasks.json',
|
|
||||||
icons = {
|
|
||||||
pending = '○',
|
|
||||||
done = '✓',
|
|
||||||
priority = '●',
|
|
||||||
header = '▸',
|
|
||||||
due = '·',
|
|
||||||
recur = '↺',
|
|
||||||
category = '#',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
local store = require('pending.store')
|
|
||||||
store.load()
|
|
||||||
|
|
||||||
local today = os.date('%Y-%m-%d')
|
|
||||||
local yesterday = os.date('%Y-%m-%d', os.time() - 86400)
|
|
||||||
local tomorrow = os.date('%Y-%m-%d', os.time() + 86400)
|
|
||||||
|
|
||||||
store.add({
|
|
||||||
description = 'Finish quarterly report',
|
|
||||||
category = 'Work',
|
|
||||||
due = tomorrow,
|
|
||||||
recur = 'monthly',
|
|
||||||
priority = 1,
|
|
||||||
})
|
|
||||||
store.add({ description = 'Review pull requests', category = 'Work' })
|
|
||||||
store.add({ description = 'Update deployment docs', category = 'Work', status = 'done' })
|
|
||||||
store.add({ description = 'Buy groceries', category = 'Personal', due = today })
|
|
||||||
store.add({ description = 'Call dentist', category = 'Personal', due = yesterday, priority = 1 })
|
|
||||||
store.add({ description = 'Read chapter 5', category = 'Personal' })
|
|
||||||
store.add({ description = 'Learn a new language', category = 'Someday' })
|
|
||||||
store.add({ description = 'Plan hiking trip', category = 'Someday' })
|
|
||||||
store.save()
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
Output assets/demo.gif
|
|
||||||
|
|
||||||
Require nvim
|
|
||||||
|
|
||||||
Set Shell "bash"
|
|
||||||
Set FontSize 14
|
|
||||||
Set Width 900
|
|
||||||
Set Height 450
|
|
||||||
|
|
||||||
Type "nvim -u scripts/demo-init.lua -c 'autocmd VimEnter * Pending'"
|
|
||||||
Enter
|
|
||||||
|
|
||||||
Sleep 2s
|
|
||||||
|
|
||||||
Down
|
|
||||||
Down
|
|
||||||
Sleep 300ms
|
|
||||||
Down
|
|
||||||
Sleep 300ms
|
|
||||||
|
|
||||||
Enter
|
|
||||||
Sleep 500ms
|
|
||||||
|
|
||||||
Tab
|
|
||||||
Sleep 1s
|
|
||||||
|
|
||||||
Type "q"
|
|
||||||
Sleep 200ms
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
require('spec.helpers')
|
|
||||||
|
|
||||||
local config = require('pending.config')
|
|
||||||
|
|
||||||
describe('icons', function()
|
|
||||||
before_each(function()
|
|
||||||
vim.g.pending = nil
|
|
||||||
config.reset()
|
|
||||||
end)
|
|
||||||
|
|
||||||
after_each(function()
|
|
||||||
vim.g.pending = nil
|
|
||||||
config.reset()
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('has default icon values', function()
|
|
||||||
local icons = config.get().icons
|
|
||||||
assert.equals('○', icons.pending)
|
|
||||||
assert.equals('✓', icons.done)
|
|
||||||
assert.equals('●', icons.priority)
|
|
||||||
assert.equals('▸', icons.header)
|
|
||||||
assert.equals('·', icons.due)
|
|
||||||
assert.equals('↺', icons.recur)
|
|
||||||
assert.equals('#', icons.category)
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('allows overriding individual icons', function()
|
|
||||||
vim.g.pending = { icons = { pending = '-', done = 'x' } }
|
|
||||||
config.reset()
|
|
||||||
local icons = config.get().icons
|
|
||||||
assert.equals('-', icons.pending)
|
|
||||||
assert.equals('x', icons.done)
|
|
||||||
assert.equals('●', icons.priority)
|
|
||||||
assert.equals('▸', icons.header)
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('allows overriding all icons', function()
|
|
||||||
vim.g.pending = {
|
|
||||||
icons = {
|
|
||||||
pending = '-',
|
|
||||||
done = 'x',
|
|
||||||
priority = '!',
|
|
||||||
header = '>',
|
|
||||||
due = '@',
|
|
||||||
recur = '~',
|
|
||||||
category = '+',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
config.reset()
|
|
||||||
local icons = config.get().icons
|
|
||||||
assert.equals('-', icons.pending)
|
|
||||||
assert.equals('x', icons.done)
|
|
||||||
assert.equals('!', icons.priority)
|
|
||||||
assert.equals('>', icons.header)
|
|
||||||
assert.equals('@', icons.due)
|
|
||||||
assert.equals('~', icons.recur)
|
|
||||||
assert.equals('+', icons.category)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue