diff --git a/lua/pending/buffer.lua b/lua/pending/buffer.lua index 4738830..a427b68 100644 --- a/lua/pending/buffer.lua +++ b/lua/pending/buffer.lua @@ -223,7 +223,8 @@ function M.render(bufnr) end current_view = current_view or config.get().default_view - vim.api.nvim_buf_set_name(bufnr, 'pending://' .. current_view) + local view_label = current_view == 'priority' and 'queue' or current_view + vim.api.nvim_buf_set_name(bufnr, 'pending://' .. view_label) local tasks = store.active_tasks() local lines, line_meta diff --git a/lua/pending/config.lua b/lua/pending/config.lua index a8feca6..ac98b64 100644 --- a/lua/pending/config.lua +++ b/lua/pending/config.lua @@ -30,6 +30,7 @@ ---@field someday_date string ---@field category_order? string[] ---@field drawer_height? integer +---@field debug? boolean ---@field keymaps pending.Keymaps ---@field gcal? pending.GcalConfig diff --git a/lua/pending/init.lua b/lua/pending/init.lua index 87f89f2..f3182fb 100644 --- a/lua/pending/init.lua +++ b/lua/pending/init.lua @@ -140,8 +140,15 @@ function M._setup_buf_mappings(bufnr) prev_task = textobj.prev_task, } + local dbg = config.get().debug for name, fn in pairs(motions) do local key = km[name] + if dbg then + vim.notify( + ('[pending] mapping motion %s → %s (buf=%d)'):format(name, key or 'nil', bufnr), + vim.log.levels.DEBUG + ) + end if key and key ~= false then vim.keymap.set({ 'n', 'x', 'o' }, key --[[@as string]], function() fn(vim.v.count1) diff --git a/lua/pending/textobj.lua b/lua/pending/textobj.lua index 77a6539..e978ad6 100644 --- a/lua/pending/textobj.lua +++ b/lua/pending/textobj.lua @@ -4,6 +4,14 @@ local config = require('pending.config') ---@class pending.textobj local M = {} +---@param ... any +---@return nil +local function dbg(...) + if config.get().debug then + vim.notify('[pending.textobj] ' .. string.format(...), vim.log.levels.DEBUG) + end +end + ---@param lnum integer ---@param meta pending.LineMeta[] ---@return string @@ -264,17 +272,29 @@ function M.next_header(count) end local row = vim.api.nvim_win_get_cursor(0)[1] + dbg('next_header: cursor=%d, meta_len=%d, view=%s', row, #meta, view or 'nil') local found = 0 count = math.max(1, count) for r = row + 1, #meta do if meta[r] and meta[r].type == 'header' then found = found + 1 + dbg( + 'next_header: found header at row=%d, cat=%s, found=%d/%d', + r, + meta[r].category or '?', + found, + count + ) if found == count then vim.api.nvim_win_set_cursor(0, { r, 0 }) + dbg('next_header: cursor set to row=%d, actual=%d', r, vim.api.nvim_win_get_cursor(0)[1]) return end + else + dbg('next_header: row=%d type=%s', r, meta[r] and meta[r].type or 'nil') end end + dbg('next_header: no header found after row=%d', row) end ---@param count integer @@ -290,11 +310,19 @@ function M.prev_header(count) end local row = vim.api.nvim_win_get_cursor(0)[1] + dbg('prev_header: cursor=%d, meta_len=%d', row, #meta) local found = 0 count = math.max(1, count) for r = row - 1, 1, -1 do if meta[r] and meta[r].type == 'header' then found = found + 1 + dbg( + 'prev_header: found header at row=%d, cat=%s, found=%d/%d', + r, + meta[r].category or '?', + found, + count + ) if found == count then vim.api.nvim_win_set_cursor(0, { r, 0 }) return @@ -312,17 +340,20 @@ function M.next_task(count) end local row = vim.api.nvim_win_get_cursor(0)[1] + dbg('next_task: cursor=%d, meta_len=%d', row, #meta) local found = 0 count = math.max(1, count) for r = row + 1, #meta do if meta[r] and meta[r].type == 'task' then found = found + 1 if found == count then + dbg('next_task: jumping to row=%d', r) vim.api.nvim_win_set_cursor(0, { r, 0 }) return end end end + dbg('next_task: no task found after row=%d', row) end ---@param count integer @@ -334,17 +365,20 @@ function M.prev_task(count) end local row = vim.api.nvim_win_get_cursor(0)[1] + dbg('prev_task: cursor=%d, meta_len=%d', row, #meta) local found = 0 count = math.max(1, count) for r = row - 1, 1, -1 do if meta[r] and meta[r].type == 'task' then found = found + 1 if found == count then + dbg('prev_task: jumping to row=%d', r) vim.api.nvim_win_set_cursor(0, { r, 0 }) return end end end + dbg('prev_task: no task found before row=%d', row) end return M