Skip to content

Commit 0a8205b

Browse files
committed
feat: Implement SearchDebugPrintsFzfLua command
1 parent 5e14936 commit 0a8205b

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ return {
7777
-- opts = { … },
7878

7979
dependencies = {
80-
"echasnovski/mini.nvim" -- Needed for line highlighting (optional)
80+
"echasnovski/mini.nvim", -- Needed for line highlighting (optional)
81+
"ibhagwan/fzf-lua" -- If you want to use the :SearchDebugPrintsFzfLua command
8182
},
8283

8384
lazy = false, -- Required to make line highlighting work before debugprint is first used
@@ -127,6 +128,7 @@ following table.
127128
| Command | `:DeleteDebugPrints` | Delete debug lines in buffer | - |
128129
| Command | `:ToggleCommentDebugPrints` | Comment/uncomment debug lines in buffer | - |
129130
| Command | `:ResetDebugPrintsCounter` | Reset debug print persistent counter (only for built-in counter implementation) | - |
131+
| Command | `:SearchDebugPrintsFzfLua` | Search for all debug print lines in the current directory using fzf-lua | - |
130132

131133
Each of the keymappings (except for 'surround' keys and insert modes) can also
132134
be prefixed with a register, see the [showcase](SHOWCASE.md#register-usage) for
@@ -251,6 +253,7 @@ they are used to convert sections to ROT-13, which most folks don't use.
251253
| Comment/uncomment all debug lines in buffer | :+1: | :+1: | :x: | :x: | :x: | :x: | :x: |
252254
| Comment/uncomment all debug lines in selected range | :+1: | :x: | :x: | :x: | :x: | :x: | :x: |
253255
| Can put debugprint text into register | :+1: | :x: | :x: | :+1: | :x: | :x: | :x: |
256+
| Search for debugprint lines in the current directory using fzf-lua | :+1: | :x: | :x: | :x: | :x: | :x: | :x: |
254257
| Extra visual emphasis of log statements | :+1: Highlights inserted lines | :+1: Flashes to highlight lines on insertion | :+1: status line counter, signcolumn, line-highlight, scrollbar | :x: | :x: | :x: | :x: |
255258
| Can insert logs in batches | :+1: (using registers) | :+1: | :x: | :x: | :x: | :x: | :x: |
256259
| Log watcher mechanism | :x: | :+1: | :x: | :x: | :x: | :x: | :x: |

lua/debugprint/init.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,24 @@ M.add_custom_filetypes = function(filetypes)
410410
vim.tbl_deep_extend("force", global_opts.filetypes, filetypes)
411411
end
412412

413+
---@return nil
414+
M.show_debug_prints_fzf = function()
415+
local ok, fzf = pcall(require, "fzf-lua")
416+
417+
if not ok then
418+
vim.notify(
419+
"fzf-lua is required for :SearchDebugPrintsFzfLua but could not be loaded",
420+
vim.log.levels.WARN
421+
)
422+
return
423+
end
424+
425+
fzf.grep({
426+
prompt = "Debug Prints> ",
427+
search = global_opts.print_tag,
428+
})
429+
end
430+
413431
if vim.fn.has("nvim-0.10.0") ~= 1 then
414432
vim.notify_once(
415433
"debugprint.nvim is only compatible with NeoVim 0.10+",

lua/debugprint/options.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ local GLOBAL_OPTION_DEFAULTS = {
3232
toggle_comment_debug_prints = "ToggleCommentDebugPrints",
3333
delete_debug_prints = "DeleteDebugPrints",
3434
reset_debug_prints_counter = "ResetDebugPrintsCounter",
35+
search_debug_prints_fzflua = "SearchDebugPrintsFzfLua",
3536
},
3637
display_counter = true,
3738
display_location = true,

lua/debugprint/setup.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ M.map_keys_and_commands = function(global_opts)
202202
desc = "Reset the debugprint counter to 0",
203203
}
204204
)
205+
206+
create_command(
207+
global_opts.commands.search_debug_prints_fzflua,
208+
require("debugprint").show_debug_prints_fzf,
209+
{
210+
desc = "Search for debug prints using fzf-lua",
211+
}
212+
)
205213
end
206214

207215
return M

0 commit comments

Comments
 (0)