File tree 3 files changed +39
-29
lines changed
3 files changed +39
-29
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ return {
72
72
" andrewferrier/debugprint.nvim" ,
73
73
opts = { … },
74
74
dependencies = {
75
- " echasnovski/mini.nvim" -- Needed to enable :ToggleCommentDebugPrints
75
+ " echasnovski/mini.nvim" -- Needed to enable :ToggleCommentDebugPrints for NeoVim <= 0.9
76
76
" nvim-treesitter/nvim-treesitter" -- Only needed for NeoVim 0.8
77
77
},
78
78
-- Remove the following line to use development versions,
@@ -93,7 +93,7 @@ packer.startup(function(use)
93
93
require (" debugprint" ).setup (opts )
94
94
end ,
95
95
requires = {
96
- " echasnovski/mini.nvim" -- Needed to enable :ToggleCommentDebugPrints
96
+ " echasnovski/mini.nvim" -- Needed to enable :ToggleCommentDebugPrints for NeoVim <= 0.9
97
97
}
98
98
})
99
99
…
Original file line number Diff line number Diff line change @@ -257,34 +257,24 @@ M.deleteprints = function(opts)
257
257
end
258
258
259
259
M .toggle_comment_debugprints = function (opts )
260
- local status , comment = pcall (require , " mini.comment" )
261
-
262
- if status == true then
263
- local lines_to_consider
264
- local initial_line
265
-
266
- lines_to_consider , initial_line = get_lines_to_handle (opts )
267
-
268
- for count , line in ipairs (lines_to_consider ) do
269
- if string.find (line , global_opts .print_tag , 1 , true ) ~= nil then
270
- local line_to_toggle = count + initial_line - 1
271
- vim .api .nvim_buf_set_lines (
272
- 0 ,
273
- line_to_toggle ,
274
- line_to_toggle ,
275
- false ,
276
- {}
277
- )
278
-
279
- comment .toggle_lines (line_to_toggle , line_to_toggle , {})
280
- end
260
+ local lines_to_consider
261
+ local initial_line
262
+
263
+ lines_to_consider , initial_line = get_lines_to_handle (opts )
264
+
265
+ for count , line in ipairs (lines_to_consider ) do
266
+ if string.find (line , global_opts .print_tag , 1 , true ) ~= nil then
267
+ local line_to_toggle = count + initial_line - 1
268
+ vim .api .nvim_buf_set_lines (
269
+ 0 ,
270
+ line_to_toggle ,
271
+ line_to_toggle ,
272
+ false ,
273
+ {}
274
+ )
275
+
276
+ utils .toggle_comment_line (line_to_toggle )
281
277
end
282
- else
283
- vim .notify (
284
- " mini.nvim is required to toggle comment debugprint lines" ,
285
- vim .log .levels .ERROR ,
286
- {}
287
- )
288
278
end
289
279
end
290
280
Original file line number Diff line number Diff line change @@ -87,6 +87,26 @@ M.indent_line = function(line_nr, move_to_indented_line)
87
87
end
88
88
end
89
89
90
+ M .toggle_comment_line = function (line )
91
+ if vim .fn .has (" nvim-0.10.0" ) == 1 then
92
+ local pos = vim .api .nvim_win_get_cursor (0 )
93
+ vim .cmd (line .. " norm gcc" )
94
+ vim .api .nvim_win_set_cursor (0 , pos )
95
+ else
96
+ local status , comment = pcall (require , " mini.comment" )
97
+
98
+ if status == true then
99
+ comment .toggle_lines (line , line , {})
100
+ else
101
+ vim .notify_once (
102
+ " mini.nvim is required to toggle comment debugprint lines prior to NeoVim 0.10" ,
103
+ vim .log .levels .ERROR ,
104
+ {}
105
+ )
106
+ end
107
+ end
108
+ end
109
+
90
110
M .NOOP = function () end
91
111
92
112
M .set_callback = function (func_name )
You can’t perform that action at this time.
0 commit comments