Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow showing TodoQuickFix list in sorted order
Browse files Browse the repository at this point in the history
This is specially usefull when documenting  observations as
comments while working on a project in order to save the context for
future.

A keyword like PIN can be defined, with a search regexp as [[PIN \d{2}]]
and the comments can be numbered as # PIN: 00, # PIN: 01.. Then using
the TodoQuickFix command will show all the pins in the sorted order,
which makes it really easy to go over the past observations etc.
Sahil Gautam committed Nov 12, 2024
1 parent ae0a2af commit 75941e9
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -109,6 +109,7 @@ Todo comes with the following defaults:
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
sorted_quickfix = false,
},
}

1 change: 1 addition & 0 deletions lua/todo-comments/config.lua
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ local defaults = {
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
sorted_quickfix = false,
},
}

7 changes: 7 additions & 0 deletions lua/todo-comments/search.lua
Original file line number Diff line number Diff line change
@@ -39,6 +39,13 @@ function M.process(lines)
end
end
end

if Config.options.search.sorted_quickfix == true then
table.sort(results, function(a, b)
return a.line <= b.line
end)
end

return results
end

0 comments on commit 75941e9

Please sign in to comment.