dotfiles

personal dotfiles
git clone anongit@rnpnr.xyz:dotfiles.git
Log | Files | Refs | Feed | Submodules

Commit: a81a3d5aa1cbf0079e28794bb93e8f0229b287b2
Parent: 8fe2d67d8d07a9054f3446c7dc33752d8c080cd9
Author: Randy Palamar
Date:   Wed, 23 Oct 2024 14:48:00 -0600

vis: build: print TODO/FIXMEs for all supported filetypes

Diffstat:
M.config/vis/build.lua | 40+++++++++++++++++++++-------------------
M.config/vis/goto-ref.lua | 2+-
2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/.config/vis/build.lua b/.config/vis/build.lua @@ -41,21 +41,10 @@ local function build_files(win) err = vis:pipe(cmd .. f.name) if err ~= 0 then return false end - -- check for FIXMEs - local pos = win.selection.pos - local info - vis:command("x/FIXME/") - -- pathological case: if cursor is on the end of a FIXME - if #win.selections and pos ~= win.selection.pos then - info = "FIXMEs: " .. tostring(#win.selections) - end - vis:feedkeys("<Escape><Escape>") - win.selection.pos = pos - -- reload pdf (zathura does this automatically) -- vis:command('!pkill -HUP mupdf') - return true, info + return true end local build_python = function (f) @@ -91,12 +80,25 @@ local function build_files(win) end win:map(vis.modes.NORMAL, " c", function () - vis:command('X/.*/w') - local s = "built: " .. win.file.name - local ret, info = builder(win.file) - if info then s = s .. " | info: " .. info end - if ret == true then vis:info(s) end - return ret - end, "build file in current window") + vis:command('X/.*/w') + local s = "built: " .. win.file.name + local ret, info = builder(win.file) + if info then s = s .. " | info: " .. info end + + -- check for FIXMEs/TODOs + local _, out = vis:pipe('ag --depth=0 --count "(FIXME|TODO)"') + if out then + local file_count_table = gf.generate_line_indices(out) + local count = 0 + for i = 1, #file_count_table do + local file, occurences = table.unpack(file_count_table[i]) + count = count + tonumber(occurences) + end + if count ~= 0 then s = s .. " | FIXME/TODOs: " .. tostring(count) end + end + + if ret == true then vis:info(s) end + return ret + end, "build file in current window") end vis.events.subscribe(vis.events.WIN_OPEN, build_files) diff --git a/.config/vis/goto-ref.lua b/.config/vis/goto-ref.lua @@ -38,7 +38,7 @@ M.generate_line_indices = function(data, filter) for s in data:gmatch("[^\n]*") do local skip = filter and filter(s) if not skip then - local found, _, file, line, col = s:find('^([^:]+):([%d]+):([%d]*):?') + local found, _, file, line, col = s:find('^([^:]+):([%d]+):?([%d]*):?') if found then table.insert(ret, {file, line, col}) end end end