@@ -2,29 +2,21 @@ local M = {}
22
33local utils_buffer = require (" debugprint.utils.buffer" )
44
5- --- @type string
6- local print_tag
7- --- @type string
8- local picker
5+ --- @type debugprint.GlobalOptions
6+ local global_opts
97
10- --- @param tag string
8+ --- @param opts debugprint.GlobalOptions
119--- @return nil
12- M .set_print_tag = function (tag )
13- print_tag = tag
14- end
15-
16- --- @param pick string
17- --- @return nil
18- M .set_picker = function (pick )
19- picker = pick
10+ M .set_global_opts = function (opts )
11+ global_opts = opts
2012end
2113
2214--- @param opts vim.api.keyset.create_user_command.command_args
2315--- @param action function (integer , integer )
2416--- @param action_present string
2517--- @param action_past string
2618local buffer_action = function (opts , action , action_present , action_past )
27- if print_tag == " " then
19+ if global_opts . print_tag == " " then
2820 vim .notify (
2921 " No print_tag set, cannot " .. action_present .. " lines." ,
3022 vim .log .levels .WARN
@@ -42,7 +34,7 @@ local buffer_action = function(opts, action, action_present, action_past)
4234 end
4335
4436 for count , line in ipairs (lines_to_consider ) do
45- if string.find (line , print_tag , 1 , true ) ~= nil then
37+ if string.find (line , global_opts . print_tag , 1 , true ) ~= nil then
4638 action (count , initial_line )
4739 actioned_count = actioned_count + 1
4840 end
@@ -97,7 +89,7 @@ local picker_handlers = {
9789 if ok_fzf then
9890 fzf .grep ({
9991 prompt = " Debug Prints> " ,
100- search = print_tag ,
92+ search = global_opts . print_tag ,
10193 })
10294 return true
10395 end
@@ -110,7 +102,7 @@ local picker_handlers = {
110102 if ok_telescope then
111103 telescope .live_grep ({
112104 prompt_title = " Debug Prints" ,
113- default_text = print_tag ,
105+ default_text = global_opts . print_tag ,
114106 })
115107 return true
116108 end
@@ -123,7 +115,7 @@ local picker_handlers = {
123115 if ok_snacks then
124116 snacks .picker .grep ({
125117 title = " Debug Prints" ,
126- search = print_tag ,
118+ search = global_opts . print_tag ,
127119 })
128120 return true
129121 end
@@ -133,19 +125,19 @@ local picker_handlers = {
133125}
134126
135127M .show_debug_prints_fuzzy_finder = function ()
136- if picker then
137- if picker_handlers [picker ] then
138- if not picker_handlers [picker ].call () then
128+ if global_opts . picker then
129+ if picker_handlers [global_opts . picker ] then
130+ if not picker_handlers [global_opts . picker ].call () then
139131 vim .notify (
140132 " Explicit picker "
141- .. picker
133+ .. global_opts . picker
142134 .. " was requested but is not available" ,
143135 vim .log .levels .ERROR
144136 )
145137 end
146138 else
147139 vim .notify (
148- " Picker " .. picker .. " is not a valid picker" ,
140+ " Picker " .. global_opts . picker .. " is not a valid picker" ,
149141 vim .log .levels .ERROR
150142 )
151143 end
166158--- @return nil
167159M .debug_print_qf_list = function ()
168160 local grep_cmd = vim .o .grepprg
169- local search_args = ' "' .. print_tag .. ' " ' .. vim .fn .getcwd ()
161+ local search_args = ' "' .. global_opts . print_tag .. ' " ' .. vim .fn .getcwd ()
170162
171163 local cannot_run = function ()
172164 vim .notify (
0 commit comments