refactor(icons): ascii defaults, checkbox overlays, and cleanup (#57)
* docs: remove unnecessary mini.ai recipe from vimdoc Problem: the `*pending-mini-ai*` section assumed mini.ai intercepts buffer-local `at`/`it`/`aC`/`iC` mappings, requiring a manual `vim.b.miniai_config` workaround. Solution: remove the section. Neovim's keymap resolver already prioritizes longer buffer-local mappings over mini.ai's global `a`/`i` handlers — no recipe needed. * refactor(icons): unify category/header icon and use checkbox overlays Problem: `header` and `category` were separate icons for the same concept. The icon overlay replaced `[ ]` with a bare character, hiding the markdown checkbox syntax. Header format `## ` produced a double-space with single-char icons. Solution: merge `header` into `category` (one icon for both header lines and EOL labels). Overlay renders `[icon]` preserving bracket syntax. Change header line format from `## ` to `# ` so the 2-char overlay (`# `) maps cleanly. * ci: remove empty `assets/` placeholder
This commit is contained in:
parent
ee8b660f7c
commit
3e8fd0a6a3
10 changed files with 61 additions and 152 deletions
105
doc/pending.txt
105
doc/pending.txt
|
|
@ -663,14 +663,18 @@ Fields: ~
|
|||
table. Currently only `gcal` is built-in.
|
||||
|
||||
{icons} (table) *pending.Icons*
|
||||
Icon characters displayed in the buffer. Fields:
|
||||
{pending} Uncompleted task icon. Default: '-'
|
||||
{done} Completed task icon. Default: 'x'
|
||||
{priority} Priority task icon. Default: '!'
|
||||
{header} Category header prefix. Default: '>'
|
||||
Icon characters displayed in the buffer. The
|
||||
{pending}, {done}, and {priority} characters
|
||||
appear inside brackets (`[icon]`) as an overlay
|
||||
on the checkbox. The {category} character
|
||||
prefixes both header lines and EOL category
|
||||
labels. Fields:
|
||||
{pending} Pending task character. Default: ' '
|
||||
{done} Done task character. Default: 'x'
|
||||
{priority} Priority task character. Default: '!'
|
||||
{due} Due date prefix. Default: '.'
|
||||
{recur} Recurrence prefix. Default: '~'
|
||||
{category} Category label prefix. Default: '#'
|
||||
{category} Category prefix. Default: '#'
|
||||
|
||||
==============================================================================
|
||||
STORE RESOLUTION *pending-store-resolution*
|
||||
|
|
@ -844,84 +848,9 @@ Event-driven statusline refresh: >lua
|
|||
})
|
||||
<
|
||||
|
||||
mini.ai integration: ~ *pending-mini-ai*
|
||||
mini.ai (from mini.nvim) maps `a` and `i` as single-key handlers in
|
||||
operator-pending and visual modes. It captures the next keystroke internally
|
||||
rather than routing it through Neovim's mapping system, which means the
|
||||
buffer-local `at`, `it`, `aC`, and `iC` maps never fire for users who have
|
||||
mini.ai installed.
|
||||
|
||||
The fix is to register pending.nvim's text objects as mini.ai custom
|
||||
textobjects via `vim.b.miniai_config` in a `FileType` autocmd. mini.ai's
|
||||
`custom_textobjects` spec expects each entry to be a function returning
|
||||
`{ from = { line, col }, to = { line, col } }` (1-indexed, col is
|
||||
byte-offset from 1).
|
||||
|
||||
pending.nvim's `textobj.inner_task_range(line)` returns the start and end
|
||||
column offsets within the current line. Combine it with the cursor row and
|
||||
the buffer line to build the region tables mini.ai expects: >lua
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'pending',
|
||||
callback = function()
|
||||
local function task_inner()
|
||||
local textobj = require('pending.textobj')
|
||||
local row = vim.api.nvim_win_get_cursor(0)[1]
|
||||
local line = vim.api.nvim_buf_get_lines(0, row - 1, row, false)[1]
|
||||
if not line then return end
|
||||
local s, e = textobj.inner_task_range(line)
|
||||
if s > e then return end
|
||||
return { from = { line = row, col = s }, to = { line = row, col = e } }
|
||||
end
|
||||
|
||||
local function category_inner()
|
||||
local textobj = require('pending.textobj')
|
||||
local buffer = require('pending.buffer')
|
||||
local meta = buffer.meta()
|
||||
if not meta then return end
|
||||
local row = vim.api.nvim_win_get_cursor(0)[1]
|
||||
local header_row, last_row = textobj.category_bounds(row, meta)
|
||||
if not header_row then return end
|
||||
local first_task, last_task
|
||||
for r = header_row + 1, last_row do
|
||||
if meta[r] and meta[r].type == 'task' then
|
||||
if not first_task then first_task = r end
|
||||
last_task = r
|
||||
end
|
||||
end
|
||||
if not first_task then return end
|
||||
local first_line = vim.api.nvim_buf_get_lines(0, first_task - 1, first_task, false)[1] or ''
|
||||
local last_line = vim.api.nvim_buf_get_lines(0, last_task - 1, last_task, false)[1] or ''
|
||||
return {
|
||||
from = { line = first_task, col = 1 },
|
||||
to = { line = last_task, col = #last_line },
|
||||
}
|
||||
end
|
||||
|
||||
vim.b.miniai_config = {
|
||||
custom_textobjects = { t = task_inner, C = category_inner },
|
||||
}
|
||||
end,
|
||||
})
|
||||
<
|
||||
|
||||
Note that the default `keymaps.a_task = 'at'` and friends still work in
|
||||
standard Neovim operator-pending mode for users who do not have mini.ai. The
|
||||
`vim.b.miniai_config` block is only needed when mini.ai is active.
|
||||
|
||||
`aC` (outer category) is not exposed here because mini.ai does not support
|
||||
the linewise selection that `aC` requires. Use the buffer-local `aC` key
|
||||
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
|
||||
spec allows it in your version.
|
||||
|
||||
Nerd font icons: >lua
|
||||
vim.g.pending = {
|
||||
icons = {
|
||||
pending = '',
|
||||
done = '',
|
||||
priority = '',
|
||||
header = '',
|
||||
due = '',
|
||||
recur = '',
|
||||
category = '',
|
||||
|
|
@ -929,20 +858,6 @@ Nerd font icons: >lua
|
|||
}
|
||||
<
|
||||
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue